formatting pass
This commit is contained in:
parent
c4b44a5109
commit
f332d61fb6
@ -124,7 +124,6 @@ const coinCheapCommon = (curr: string) => ({
|
||||
feeWithdraw: `${curr}:0.2`,
|
||||
});
|
||||
|
||||
|
||||
export function makeNoFeeCoinConfig(curr: string): CoinConfig[] {
|
||||
const cc: CoinConfig[] = [];
|
||||
|
||||
|
@ -908,9 +908,7 @@ export class ExchangeService implements ExchangeServiceInterface {
|
||||
|
||||
addCoinConfigList(ccs: CoinConfig[]) {
|
||||
const config = Configuration.load(this.configFilename);
|
||||
ccs.forEach((cc) =>
|
||||
setCoin(config, cc),
|
||||
);
|
||||
ccs.forEach((cc) => setCoin(config, cc));
|
||||
config.write(this.configFilename);
|
||||
}
|
||||
|
||||
@ -1545,8 +1543,9 @@ export class WalletCli {
|
||||
throw new OperationFailedError(resp.error);
|
||||
}
|
||||
|
||||
|
||||
async abortFailedPayWithRefund(req: AbortPayWithRefundRequest): Promise<void> {
|
||||
async abortFailedPayWithRefund(
|
||||
req: AbortPayWithRefundRequest,
|
||||
): Promise<void> {
|
||||
const resp = await this.apiRequest("abortFailedPayWithRefund", req);
|
||||
if (resp.type === "response") {
|
||||
return;
|
||||
|
@ -107,11 +107,13 @@ export const codecForCheckPaymentUnpaidResponse = (): Codec<
|
||||
.property("already_paid_order_id", codecOptional(codecForString()))
|
||||
.build("CheckPaymentPaidResponse");
|
||||
|
||||
export const codecForCheckPaymentClaimedResponse = (): Codec<CheckPaymentClaimedResponse> =>
|
||||
export const codecForCheckPaymentClaimedResponse = (): Codec<
|
||||
CheckPaymentClaimedResponse
|
||||
> =>
|
||||
buildCodecForObject<CheckPaymentClaimedResponse>()
|
||||
.property("order_status", codecForConstString("claimed"))
|
||||
.property("contract_terms", codecForContractTerms())
|
||||
.build("CheckPaymentClaimedResponse");
|
||||
.property("order_status", codecForConstString("claimed"))
|
||||
.property("contract_terms", codecForContractTerms())
|
||||
.build("CheckPaymentClaimedResponse");
|
||||
|
||||
export const codecForMerchantOrderPrivateStatusResponse = (): Codec<
|
||||
MerchantOrderPrivateStatusResponse
|
||||
@ -133,7 +135,7 @@ export interface CheckPaymentClaimedResponse {
|
||||
order_status: "claimed";
|
||||
|
||||
contract_terms: ContractTerms;
|
||||
}
|
||||
}
|
||||
|
||||
export interface CheckPaymentPaidResponse {
|
||||
// did the customer pay for this contract
|
||||
@ -179,7 +181,6 @@ export interface CheckPaymentPaidResponse {
|
||||
order_status_url: string;
|
||||
}
|
||||
|
||||
|
||||
export interface CheckPaymentUnpaidResponse {
|
||||
order_status: "unpaid";
|
||||
|
||||
@ -275,7 +276,6 @@ export interface ReserveStatusEntry {
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface TipCreateConfirmation {
|
||||
// Unique tip identifier for the tip that was created.
|
||||
tip_id: string;
|
||||
|
@ -116,7 +116,9 @@ runTest(async (t: GlobalTestState) => {
|
||||
|
||||
// Check that we got the sign-up bonus.
|
||||
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:100");
|
||||
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit);
|
||||
t.assertTrue(
|
||||
balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit,
|
||||
);
|
||||
|
||||
const res = createEddsaKeyPair();
|
||||
|
||||
@ -129,5 +131,7 @@ runTest(async (t: GlobalTestState) => {
|
||||
|
||||
balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
|
||||
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15");
|
||||
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit);
|
||||
t.assertTrue(
|
||||
balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit,
|
||||
);
|
||||
});
|
||||
|
@ -24,11 +24,11 @@ import {
|
||||
WalletCli,
|
||||
} from "./harness";
|
||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||
import { URL } from "url"
|
||||
import { URL } from "url";
|
||||
|
||||
/**
|
||||
* Run test for the merchant's order lifecycle.
|
||||
*
|
||||
*
|
||||
* FIXME: Is this test still necessary? We initially wrote if to confirm/document
|
||||
* assumptions about how the merchant should work.
|
||||
*/
|
||||
@ -50,27 +50,33 @@ runTest(async (t: GlobalTestState) => {
|
||||
summary: "Buy me!",
|
||||
amount: "TESTKUDOS:5",
|
||||
fulfillment_url: "taler://fulfillment-success/thx",
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
// Query private order status before claiming it.
|
||||
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
orderId: orderResp.order_id,
|
||||
});
|
||||
let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||
merchant,
|
||||
{
|
||||
orderId: orderResp.order_id,
|
||||
},
|
||||
);
|
||||
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
||||
let statusUrlBefore = new URL(orderStatusBefore.order_status_url);
|
||||
|
||||
// Make wallet claim the unpaid order.
|
||||
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
||||
t.assertTrue(orderStatusBefore.order_status === "unpaid");
|
||||
const talerPayUri = orderStatusBefore.taler_pay_uri;
|
||||
const y = await wallet.preparePay({
|
||||
talerPayUri
|
||||
talerPayUri,
|
||||
});
|
||||
|
||||
// Query private order status after claiming it.
|
||||
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
orderId: orderResp.order_id,
|
||||
});
|
||||
let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||
merchant,
|
||||
{
|
||||
orderId: orderResp.order_id,
|
||||
},
|
||||
);
|
||||
t.assertTrue(orderStatusAfter.order_status === "claimed");
|
||||
|
||||
await t.shutdown();
|
||||
|
@ -17,15 +17,22 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { defaultCoinConfig } from './denomStructures';
|
||||
import { runTest, GlobalTestState, BankService, ExchangeService, MerchantService, setupDb, WalletCli } from "./harness";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
import {
|
||||
runTest,
|
||||
GlobalTestState,
|
||||
BankService,
|
||||
ExchangeService,
|
||||
MerchantService,
|
||||
setupDb,
|
||||
WalletCli,
|
||||
} from "./harness";
|
||||
import {
|
||||
withdrawViaBank,
|
||||
makeTestPayment,
|
||||
SimpleTestEnvironment,
|
||||
} from "./helpers";
|
||||
|
||||
|
||||
/**
|
||||
* Run a test case with a simple TESTKUDOS Taler environment, consisting
|
||||
* of one exchange, one bank and one merchant.
|
||||
@ -83,42 +90,42 @@ export async function createMyTestkudosEnvironment(
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c1",
|
||||
value: "TESTKUDOS:1.28"
|
||||
value: "TESTKUDOS:1.28",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c2",
|
||||
value: "TESTKUDOS:0.64"
|
||||
value: "TESTKUDOS:0.64",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c3",
|
||||
value: "TESTKUDOS:0.32"
|
||||
value: "TESTKUDOS:0.32",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c4",
|
||||
value: "TESTKUDOS:0.16"
|
||||
value: "TESTKUDOS:0.16",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c5",
|
||||
value: "TESTKUDOS:0.08"
|
||||
value: "TESTKUDOS:0.08",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c5",
|
||||
value: "TESTKUDOS:0.04"
|
||||
value: "TESTKUDOS:0.04",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c6",
|
||||
value: "TESTKUDOS:0.02"
|
||||
value: "TESTKUDOS:0.02",
|
||||
},
|
||||
{
|
||||
...coinCommon,
|
||||
name: "c7",
|
||||
value: "TESTKUDOS:0.01"
|
||||
value: "TESTKUDOS:0.01",
|
||||
},
|
||||
]);
|
||||
|
||||
@ -171,7 +178,12 @@ runTest(async (t: GlobalTestState) => {
|
||||
|
||||
// Withdraw digital cash into the wallet.
|
||||
|
||||
await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:1.92" });
|
||||
await withdrawViaBank(t, {
|
||||
wallet,
|
||||
bank,
|
||||
exchange,
|
||||
amount: "TESTKUDOS:1.92",
|
||||
});
|
||||
|
||||
const coins = await wallet.dumpCoins();
|
||||
|
||||
|
@ -39,11 +39,7 @@ import {
|
||||
FaultInjectionRequestContext,
|
||||
FaultInjectionResponseContext,
|
||||
} from "./faultInjection";
|
||||
import {
|
||||
PreparePayResultType,
|
||||
URL,
|
||||
TalerErrorCode,
|
||||
} from "taler-wallet-core";
|
||||
import { PreparePayResultType, URL, TalerErrorCode } from "taler-wallet-core";
|
||||
import { defaultCoinConfig } from "./denomStructures";
|
||||
import { withdrawViaBank, makeTestPayment } from "./helpers";
|
||||
|
||||
|
@ -34,7 +34,7 @@ import { FaultInjectionRequestContext } from "./faultInjection";
|
||||
/**
|
||||
* Run test for the wallets repurchase detection mechanism
|
||||
* based on the fulfillment URL.
|
||||
*
|
||||
*
|
||||
* FIXME: This test is now almost the same as test-paywall-flow,
|
||||
* since we can't initiate payment via a "claimed" private order status
|
||||
* response.
|
||||
@ -150,7 +150,10 @@ runTest(async (t: GlobalTestState) => {
|
||||
sessionId: "mysession-two",
|
||||
});
|
||||
|
||||
console.log("order status under mysession-two:", JSON.stringify(orderStatus, undefined, 2));
|
||||
console.log(
|
||||
"order status under mysession-two:",
|
||||
JSON.stringify(orderStatus, undefined, 2),
|
||||
);
|
||||
|
||||
// Should be claimed (not paid!) because of a new session ID
|
||||
t.assertTrue(orderStatus.order_status === "claimed");
|
||||
@ -169,7 +172,6 @@ runTest(async (t: GlobalTestState) => {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", {
|
||||
order: {
|
||||
summary: "Buy me!",
|
||||
@ -178,10 +180,13 @@ runTest(async (t: GlobalTestState) => {
|
||||
},
|
||||
});
|
||||
|
||||
let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
orderId: orderRespTwo.order_id,
|
||||
sessionId: "mysession-two",
|
||||
});
|
||||
let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(
|
||||
merchant,
|
||||
{
|
||||
orderId: orderRespTwo.order_id,
|
||||
sessionId: "mysession-two",
|
||||
},
|
||||
);
|
||||
|
||||
t.assertTrue(orderStatusTwo.order_status === "unpaid");
|
||||
|
||||
|
@ -25,7 +25,6 @@ import {
|
||||
ExchangeService,
|
||||
MerchantService,
|
||||
WalletCli,
|
||||
|
||||
MerchantPrivateApi,
|
||||
} from "./harness";
|
||||
import { withdrawViaBank } from "./helpers";
|
||||
|
@ -32,7 +32,10 @@ import {
|
||||
TalerErrorCode,
|
||||
} from "taler-wallet-core";
|
||||
import axios from "axios";
|
||||
import { FaultInjectionRequestContext, FaultInjectionResponseContext } from "./faultInjection";
|
||||
import {
|
||||
FaultInjectionRequestContext,
|
||||
FaultInjectionResponseContext,
|
||||
} from "./faultInjection";
|
||||
|
||||
/**
|
||||
* Run test for a payment where the merchant has a transient
|
||||
@ -134,7 +137,7 @@ runTest(async (t: GlobalTestState) => {
|
||||
};
|
||||
ctx.responseBody = Buffer.from(JSON.stringify(err));
|
||||
ctx.statusCode = 500;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const confirmPayResp = await wallet.confirmPay({
|
||||
|
@ -48,7 +48,7 @@ runTest(async (t: GlobalTestState) => {
|
||||
d_ms: 3000,
|
||||
},
|
||||
},
|
||||
refund_delay: durationFromSpec({ minutes: 5}),
|
||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||
});
|
||||
|
||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
|
@ -51,7 +51,7 @@ runTest(async (t: GlobalTestState) => {
|
||||
amount: "TESTKUDOS:10",
|
||||
fulfillment_url: "taler://fulfillment-success/thx",
|
||||
},
|
||||
refund_delay: durationFromSpec({ minutes: 5}),
|
||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||
});
|
||||
|
||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { durationFromSpec } from 'taler-wallet-core';
|
||||
import { durationFromSpec } from "taler-wallet-core";
|
||||
import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness";
|
||||
import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers";
|
||||
|
||||
@ -46,7 +46,7 @@ runTest(async (t: GlobalTestState) => {
|
||||
amount: "TESTKUDOS:5",
|
||||
fulfillment_url: "taler://fulfillment-success/thx",
|
||||
},
|
||||
refund_delay: durationFromSpec({ minutes: 5}),
|
||||
refund_delay: durationFromSpec({ minutes: 5 }),
|
||||
});
|
||||
|
||||
let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, {
|
||||
|
@ -126,7 +126,9 @@ export class AndroidHttpLib implements HttpRequestLibrary {
|
||||
requestMethod: "FIXME",
|
||||
json: async () => JSON.parse(msg.responseText),
|
||||
text: async () => msg.responseText,
|
||||
bytes: async () => { throw Error("bytes() not supported for tunnel response") },
|
||||
bytes: async () => {
|
||||
throw Error("bytes() not supported for tunnel response");
|
||||
},
|
||||
};
|
||||
p.resolve(resp);
|
||||
} else {
|
||||
|
@ -654,8 +654,8 @@ testCli.subcommand("vectors", "vectors").action(async (args) => {
|
||||
|
||||
async function read(stream: NodeJS.ReadStream) {
|
||||
const chunks = [];
|
||||
for await (const chunk of stream) chunks.push(chunk);
|
||||
return Buffer.concat(chunks).toString('utf8');
|
||||
for await (const chunk of stream) chunks.push(chunk);
|
||||
return Buffer.concat(chunks).toString("utf8");
|
||||
}
|
||||
|
||||
testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||
@ -667,7 +667,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||
throw Error("can't split lines");
|
||||
}
|
||||
|
||||
const vals: Record<string, string> = {}
|
||||
const vals: Record<string, string> = {};
|
||||
|
||||
let inBlindSigningSection = false;
|
||||
|
||||
@ -684,7 +684,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||
const m = line.match(/ (\w+) (\w+)/);
|
||||
if (!m) {
|
||||
console.log("bad format");
|
||||
process.exit(2)
|
||||
process.exit(2);
|
||||
}
|
||||
vals[m[1]] = m[2];
|
||||
}
|
||||
@ -697,7 +697,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => {
|
||||
throw Error(`no value for ${k}`);
|
||||
}
|
||||
return decodeCrock(vals[k]);
|
||||
}
|
||||
};
|
||||
|
||||
const myBm = rsaBlind(
|
||||
req("message_hash"),
|
||||
|
@ -22,8 +22,6 @@
|
||||
*/
|
||||
|
||||
export enum TalerErrorCode {
|
||||
|
||||
|
||||
/**
|
||||
* Special code to indicate success (no error).
|
||||
* Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0).
|
||||
@ -1668,5 +1666,4 @@ export enum TalerErrorCode {
|
||||
* (A value of 0 indicates that the error is generated client-side).
|
||||
*/
|
||||
END = 9999,
|
||||
|
||||
}
|
||||
|
@ -187,4 +187,3 @@ test("taler-exchange-tvg eddsa_ecdh #2", (t) => {
|
||||
);
|
||||
t.deepEqual(encodeCrock(myKm2), key_material);
|
||||
});
|
||||
|
||||
|
@ -76,7 +76,10 @@ export function openTalerDatabase(
|
||||
if ((si as any)[indexName] instanceof Index) {
|
||||
const ii: Index<string, string, any, any> = (si as any)[indexName];
|
||||
const indexVersionAdded = ii.options?.versionAdded ?? 0;
|
||||
if (indexVersionAdded > oldVersion || storeVersionAdded > oldVersion) {
|
||||
if (
|
||||
indexVersionAdded > oldVersion ||
|
||||
storeVersionAdded > oldVersion
|
||||
) {
|
||||
s.createIndex(ii.indexName, ii.keyPath, ii.options);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import { OperationFailedError, makeErrorDetails } from "../operations/errors";
|
||||
import { TalerErrorCode } from "../TalerErrorCode";
|
||||
import { URL } from "../util/url";
|
||||
import { Logger } from "../util/logging";
|
||||
import { bytesToString } from '../crypto/talerCrypto';
|
||||
import { bytesToString } from "../crypto/talerCrypto";
|
||||
|
||||
const logger = new Logger("NodeHttpLib.ts");
|
||||
|
||||
@ -92,10 +92,10 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
||||
);
|
||||
}
|
||||
|
||||
const makeText = async(): Promise<string> => {
|
||||
const makeText = async (): Promise<string> => {
|
||||
const respText = new Uint8Array(resp.data);
|
||||
return bytesToString(respText);
|
||||
}
|
||||
};
|
||||
|
||||
const makeJson = async (): Promise<any> => {
|
||||
let responseJson;
|
||||
@ -152,7 +152,6 @@ export class NodeHttpLib implements HttpRequestLibrary {
|
||||
json: makeJson,
|
||||
bytes: makeBytes,
|
||||
};
|
||||
|
||||
}
|
||||
async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
|
||||
return this.fetch(url, {
|
||||
|
@ -64,8 +64,7 @@ export interface DefaultNodeWalletArgs {
|
||||
*/
|
||||
function makeId(length: number): string {
|
||||
let result = "";
|
||||
const characters =
|
||||
"abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
const characters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
@ -129,7 +128,9 @@ export async function getDefaultNodeWallet(
|
||||
|
||||
const myVersionChange = (): Promise<void> => {
|
||||
logger.error("version change requested, should not happen");
|
||||
throw Error("BUG: wallet DB version change event can't happen with memory IDB");
|
||||
throw Error(
|
||||
"BUG: wallet DB version change event can't happen with memory IDB",
|
||||
);
|
||||
};
|
||||
|
||||
shimIndexedDB(myBridgeIdbFactory);
|
||||
|
@ -120,7 +120,7 @@ async function provideBackupState(
|
||||
key: WALLET_BACKUP_STATE_KEY,
|
||||
value: {
|
||||
deviceId,
|
||||
clocks: { [deviceId]: 1},
|
||||
clocks: { [deviceId]: 1 },
|
||||
walletRootPub: k.pub,
|
||||
walletRootPriv: k.priv,
|
||||
lastBackupHash: undefined,
|
||||
@ -152,7 +152,9 @@ export async function exportBackup(
|
||||
|
||||
const exchanges: BackupExchange[] = [];
|
||||
const coinsByDenom: { [dph: string]: BackupCoin[] } = {};
|
||||
const denominationsByExchange: { [url: string]: BackupDenomination[] } = {};
|
||||
const denominationsByExchange: {
|
||||
[url: string]: BackupDenomination[];
|
||||
} = {};
|
||||
const reservesByExchange: { [url: string]: BackupReserve[] } = {};
|
||||
|
||||
await tx.iter(Stores.coins).forEach((coin) => {
|
||||
@ -193,7 +195,9 @@ export async function exportBackup(
|
||||
});
|
||||
|
||||
await tx.iter(Stores.denominations).forEach((denom) => {
|
||||
const backupDenoms = (denominationsByExchange[denom.exchangeBaseUrl] ??= []);
|
||||
const backupDenoms = (denominationsByExchange[
|
||||
denom.exchangeBaseUrl
|
||||
] ??= []);
|
||||
backupDenoms.push({
|
||||
coins: coinsByDenom[denom.denomPubHash] ?? [],
|
||||
denom_pub: denom.denomPub,
|
||||
@ -401,7 +405,7 @@ export async function runBackupCycle(ws: InternalWalletState): Promise<void> {
|
||||
|
||||
if (resp.status === HttpResponseStatus.PaymentRequired) {
|
||||
logger.trace("payment required for backup");
|
||||
logger.trace(`headers: ${j2s(resp.headers)}`)
|
||||
logger.trace(`headers: ${j2s(resp.headers)}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,9 @@ export class OperationFailedAndReportedError extends Error {
|
||||
message: string,
|
||||
details: Record<string, unknown>,
|
||||
): OperationFailedAndReportedError {
|
||||
return new OperationFailedAndReportedError(makeErrorDetails(ec, message, details));
|
||||
return new OperationFailedAndReportedError(
|
||||
makeErrorDetails(ec, message, details),
|
||||
);
|
||||
}
|
||||
|
||||
constructor(public operationError: TalerErrorDetails) {
|
||||
|
@ -289,24 +289,21 @@ async function updateExchangeFinalize(
|
||||
if (exchange.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) {
|
||||
return;
|
||||
}
|
||||
await ws.db.runWithWriteTransaction(
|
||||
[Stores.exchanges],
|
||||
async (tx) => {
|
||||
const r = await tx.get(Stores.exchanges, exchangeBaseUrl);
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) {
|
||||
return;
|
||||
}
|
||||
r.addComplete = true;
|
||||
r.updateStatus = ExchangeUpdateStatus.Finished;
|
||||
// Reset time to next auto refresh check,
|
||||
// as now new denominations might be available.
|
||||
r.nextRefreshCheck = undefined;
|
||||
await tx.put(Stores.exchanges, r);
|
||||
},
|
||||
);
|
||||
await ws.db.runWithWriteTransaction([Stores.exchanges], async (tx) => {
|
||||
const r = await tx.get(Stores.exchanges, exchangeBaseUrl);
|
||||
if (!r) {
|
||||
return;
|
||||
}
|
||||
if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) {
|
||||
return;
|
||||
}
|
||||
r.addComplete = true;
|
||||
r.updateStatus = ExchangeUpdateStatus.Finished;
|
||||
// Reset time to next auto refresh check,
|
||||
// as now new denominations might be available.
|
||||
r.nextRefreshCheck = undefined;
|
||||
await tx.put(Stores.exchanges, r);
|
||||
});
|
||||
}
|
||||
|
||||
async function updateExchangeWithTermsOfService(
|
||||
@ -547,7 +544,9 @@ export async function getExchangeTrust(
|
||||
);
|
||||
if (currencyRecord) {
|
||||
for (const trustedExchange of currencyRecord.exchanges) {
|
||||
if (trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey) {
|
||||
if (
|
||||
trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey
|
||||
) {
|
||||
isTrusted = true;
|
||||
break;
|
||||
}
|
||||
|
@ -435,7 +435,9 @@ async function recordConfirmPay(
|
||||
} else {
|
||||
sessionId = proposal.downloadSessionId;
|
||||
}
|
||||
logger.trace(`recording payment on ${proposal.orderId} with session ID ${sessionId}`);
|
||||
logger.trace(
|
||||
`recording payment on ${proposal.orderId} with session ID ${sessionId}`,
|
||||
);
|
||||
const payCostInfo = await getTotalPaymentCost(ws, coinSelection);
|
||||
const t: PurchaseRecord = {
|
||||
abortStatus: AbortStatus.None,
|
||||
@ -943,7 +945,10 @@ async function submitPay(
|
||||
session_id: purchase.lastSessionId,
|
||||
};
|
||||
|
||||
logger.trace("making pay request ... ", JSON.stringify(reqBody, undefined, 2));
|
||||
logger.trace(
|
||||
"making pay request ... ",
|
||||
JSON.stringify(reqBody, undefined, 2),
|
||||
);
|
||||
|
||||
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () =>
|
||||
ws.http.postJson(payUrl, reqBody, {
|
||||
@ -971,7 +976,7 @@ async function submitPay(
|
||||
lastError: err,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const merchantResp = await readSuccessResponseJsonOrThrow(
|
||||
resp,
|
||||
codecForMerchantPayResponse(),
|
||||
@ -1208,10 +1213,7 @@ export async function confirmPay(
|
||||
throw Error("proposal is in invalid state");
|
||||
}
|
||||
|
||||
let purchase = await ws.db.get(
|
||||
Stores.purchases,
|
||||
proposalId,
|
||||
);
|
||||
let purchase = await ws.db.get(Stores.purchases, proposalId);
|
||||
|
||||
if (purchase) {
|
||||
if (
|
||||
|
@ -38,10 +38,7 @@ import {
|
||||
|
||||
import { codecForRecoupConfirmation } from "../types/talerTypes";
|
||||
import { NotificationType } from "../types/notifications";
|
||||
import {
|
||||
getReserveRequestTimeout,
|
||||
processReserve,
|
||||
} from "./reserves";
|
||||
import { getReserveRequestTimeout, processReserve } from "./reserves";
|
||||
|
||||
import { Amounts } from "../util/amounts";
|
||||
import { createRefreshGroup, processRefreshGroup } from "./refresh";
|
||||
|
@ -286,7 +286,10 @@ async function storeFailedRefund(
|
||||
}
|
||||
if (contrib) {
|
||||
coin.currentAmount = Amounts.add(coin.currentAmount, contrib).amount;
|
||||
coin.currentAmount = Amounts.sub(coin.currentAmount, denom.feeRefund).amount;
|
||||
coin.currentAmount = Amounts.sub(
|
||||
coin.currentAmount,
|
||||
denom.feeRefund,
|
||||
).amount;
|
||||
}
|
||||
refreshCoinsMap[coin.coinPub] = { coinPub: coin.coinPub };
|
||||
await tx.put(Stores.coins, coin);
|
||||
@ -325,7 +328,8 @@ async function acceptRefunds(
|
||||
|
||||
const isPermanentFailure =
|
||||
refundStatus.type === "failure" &&
|
||||
refundStatus.exchange_status >= 400 && refundStatus.exchange_status < 500 ;
|
||||
refundStatus.exchange_status >= 400 &&
|
||||
refundStatus.exchange_status < 500;
|
||||
|
||||
// Already failed.
|
||||
if (existingRefundInfo?.type === RefundState.Failed) {
|
||||
@ -536,7 +540,7 @@ export async function applyRefund(
|
||||
fulfillmentMessage: purchase.contractData.fulfillmentMessage,
|
||||
summary_i18n: purchase.contractData.summaryI18n,
|
||||
fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n,
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,10 @@ import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
|
||||
import { guardOperationException, makeErrorDetails } from "./errors";
|
||||
import { NotificationType } from "../types/notifications";
|
||||
import { getTimestampNow } from "../util/time";
|
||||
import { getHttpResponseErrorDetails, readSuccessResponseJsonOrThrow } from "../util/http";
|
||||
import {
|
||||
getHttpResponseErrorDetails,
|
||||
readSuccessResponseJsonOrThrow,
|
||||
} from "../util/http";
|
||||
import { URL } from "../util/url";
|
||||
import { Logger } from "../util/logging";
|
||||
import { checkDbInvariant } from "../util/invariants";
|
||||
|
@ -43,7 +43,10 @@ import { InternalWalletState } from "./state";
|
||||
import { parseWithdrawUri } from "../util/taleruri";
|
||||
import { Logger } from "../util/logging";
|
||||
import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
|
||||
import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_BANK_INTEGRATION_PROTOCOL_VERSION } from "./versions";
|
||||
import {
|
||||
WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||
} from "./versions";
|
||||
|
||||
import * as LibtoolVersion from "../util/libtoolVersion";
|
||||
import {
|
||||
@ -155,10 +158,7 @@ export async function getBankWithdrawalInfo(
|
||||
throw Error(`can't parse URL ${talerWithdrawUri}`);
|
||||
}
|
||||
|
||||
const configReqUrl = new URL(
|
||||
"config",
|
||||
uriResult.bankIntegrationApiBaseUrl,
|
||||
)
|
||||
const configReqUrl = new URL("config", uriResult.bankIntegrationApiBaseUrl);
|
||||
|
||||
const configResp = await ws.http.get(configReqUrl.href);
|
||||
const config = await readSuccessResponseJsonOrThrow(
|
||||
@ -166,7 +166,10 @@ export async function getBankWithdrawalInfo(
|
||||
codecForTalerConfigResponse(),
|
||||
);
|
||||
|
||||
const versionRes = compare(WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, config.version);
|
||||
const versionRes = compare(
|
||||
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
|
||||
config.version,
|
||||
);
|
||||
if (versionRes?.compatible != true) {
|
||||
const opErr = makeErrorDetails(
|
||||
TalerErrorCode.WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE,
|
||||
|
@ -23,6 +23,7 @@
|
||||
* Current limitations:
|
||||
* 1. Exchange/auditor trust isn't exported yet
|
||||
* (see https://bugs.gnunet.org/view.php?id=6448)
|
||||
* 2. Reports to the auditor (cryptographic proofs and/or diagnostics) aren't exported yet
|
||||
*
|
||||
* General considerations / decisions:
|
||||
* 1. Information about previously occurring errors and
|
||||
@ -196,7 +197,7 @@ export interface WalletBackupContentV1 {
|
||||
|
||||
/**
|
||||
* Interning table for forgettable values of contract terms.
|
||||
*
|
||||
*
|
||||
* Used to reduce storage space, as many forgettable items (product image,
|
||||
* addresses, etc.) might be shared among many contract terms.
|
||||
*/
|
||||
@ -205,7 +206,7 @@ export interface WalletBackupContentV1 {
|
||||
|
||||
/**
|
||||
* Trust declaration for an auditor.
|
||||
*
|
||||
*
|
||||
* The trust applies based on the public key of
|
||||
* the auditor, irrespective of what base URL the exchange
|
||||
* is referencing.
|
||||
@ -223,7 +224,7 @@ export interface BackupTrustAuditor {
|
||||
|
||||
/**
|
||||
* Clock when the auditor trust has been added.
|
||||
*
|
||||
*
|
||||
* Can be undefined if this entry represents a removal delta
|
||||
* from the wallet's defaults.
|
||||
*/
|
||||
@ -237,7 +238,7 @@ export interface BackupTrustAuditor {
|
||||
|
||||
/**
|
||||
* Trust declaration for an exchange.
|
||||
*
|
||||
*
|
||||
* The trust only applies for the combination of base URL
|
||||
* and public key. If the master public key changes while the base
|
||||
* URL stays the same, the exchange has to be re-added by a wallet update
|
||||
@ -256,12 +257,12 @@ export interface BackupTrustExchange {
|
||||
|
||||
/**
|
||||
* Clock when the exchange trust has been added.
|
||||
*
|
||||
*
|
||||
* Can be undefined if this entry represents a removal delta
|
||||
* from the wallet's defaults.
|
||||
*/
|
||||
clock_added?: ClockValue;
|
||||
|
||||
|
||||
/**
|
||||
* Clock for when the exchange trust has been removed.
|
||||
*/
|
||||
|
@ -223,7 +223,7 @@ export interface ReserveRegisteredWithBankNotification {
|
||||
|
||||
/**
|
||||
* Notification sent when a pay (or pay replay) operation succeeded.
|
||||
*
|
||||
*
|
||||
* We send this notification because the confirmPay request can return
|
||||
* a "confirmed" response that indicates that the payment has been confirmed
|
||||
* by the user, but we're still waiting for the payment to succeed or fail.
|
||||
|
@ -54,7 +54,6 @@ test("contract terms validation", (t) => {
|
||||
t.fail();
|
||||
});
|
||||
|
||||
|
||||
test("contract terms validation (locations)", (t) => {
|
||||
const c = {
|
||||
nonce: "123123123",
|
||||
@ -69,7 +68,7 @@ test("contract terms validation (locations)", (t) => {
|
||||
name: "Foo",
|
||||
address: {
|
||||
country: "DE",
|
||||
}
|
||||
},
|
||||
},
|
||||
order_id: "test_order",
|
||||
pay_deadline: { t_ms: 42 },
|
||||
@ -83,7 +82,7 @@ test("contract terms validation (locations)", (t) => {
|
||||
delivery_location: {
|
||||
country: "FR",
|
||||
town: "Rennes",
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const r = codecForContractTerms().decode(c);
|
||||
|
@ -365,13 +365,13 @@ export interface PrepareTipResult {
|
||||
* Amount that the merchant gave.
|
||||
*/
|
||||
tipAmountRaw: AmountString;
|
||||
|
||||
|
||||
/**
|
||||
* Amount that arrived at the wallet.
|
||||
* Might be lower than the raw amount due to fees.
|
||||
*/
|
||||
tipAmountEffective: AmountString;
|
||||
|
||||
|
||||
/**
|
||||
* Base URL of the merchant backend giving then tip.
|
||||
*/
|
||||
@ -382,7 +382,7 @@ export interface PrepareTipResult {
|
||||
* Determined by the merchant, the wallet/user has no choice here.
|
||||
*/
|
||||
exchangeBaseUrl: string;
|
||||
|
||||
|
||||
/**
|
||||
* Time when the tip will expire. After it expired, it can't be picked
|
||||
* up anymore.
|
||||
@ -392,13 +392,13 @@ export interface PrepareTipResult {
|
||||
|
||||
export const codecForPrepareTipResult = (): Codec<PrepareTipResult> =>
|
||||
buildCodecForObject<PrepareTipResult>()
|
||||
.property("accepted", codecForBoolean())
|
||||
.property("tipAmountRaw", codecForAmountString())
|
||||
.property("tipAmountEffective", codecForAmountString())
|
||||
.property("exchangeBaseUrl", codecForString())
|
||||
.property("merchantBaseUrl", codecForString())
|
||||
.property("expirationTimestamp", codecForTimestamp)
|
||||
.property("walletTipId", codecForString())
|
||||
.property("accepted", codecForBoolean())
|
||||
.property("tipAmountRaw", codecForAmountString())
|
||||
.property("tipAmountEffective", codecForAmountString())
|
||||
.property("exchangeBaseUrl", codecForString())
|
||||
.property("merchantBaseUrl", codecForString())
|
||||
.property("expirationTimestamp", codecForTimestamp)
|
||||
.property("walletTipId", codecForString())
|
||||
.build("PrepareTipResult");
|
||||
|
||||
export interface BenchmarkResult {
|
||||
@ -974,7 +974,9 @@ export interface AbortPayWithRefundRequest {
|
||||
proposalId: string;
|
||||
}
|
||||
|
||||
export const codecForAbortPayWithRefundRequest = (): Codec<AbortPayWithRefundRequest> =>
|
||||
export const codecForAbortPayWithRefundRequest = (): Codec<
|
||||
AbortPayWithRefundRequest
|
||||
> =>
|
||||
buildCodecForObject<AbortPayWithRefundRequest>()
|
||||
.property("proposalId", codecForString())
|
||||
.build("AbortPayWithRefundRequest");
|
||||
|
@ -21,7 +21,11 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { getTimestampNow, timestampDifference, timestampCmp } from "../util/time";
|
||||
import {
|
||||
getTimestampNow,
|
||||
timestampDifference,
|
||||
timestampCmp,
|
||||
} from "../util/time";
|
||||
import { URL } from "./url";
|
||||
import { Logger } from "./logging";
|
||||
|
||||
|
@ -149,4 +149,4 @@ export function strcmp(s1: string, s2: string): number {
|
||||
|
||||
export function j2s(x: any): string {
|
||||
return JSON.stringify(x, undefined, 2);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
* Helpers for doing XMLHttpRequest-s that are based on ES6 promises.
|
||||
* Allows for easy mocking for test cases.
|
||||
*
|
||||
*
|
||||
* The API is inspired by the HTML5 fetch API.
|
||||
*/
|
||||
|
||||
@ -91,7 +91,7 @@ export class Headers {
|
||||
|
||||
toJSON(): any {
|
||||
const m: Record<string, string> = {};
|
||||
this.headerMap.forEach((v, k) => m[k] = v);
|
||||
this.headerMap.forEach((v, k) => (m[k] = v));
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@ -120,10 +120,7 @@ export interface HttpRequestLibrary {
|
||||
/**
|
||||
* Make an HTTP POST request with a JSON body.
|
||||
*/
|
||||
fetch(
|
||||
url: string,
|
||||
opt?: HttpRequestOptions,
|
||||
): Promise<HttpResponse>;
|
||||
fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
|
||||
}
|
||||
|
||||
type TalerErrorResponse = {
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
import { openPromise } from "./promiseUtils";
|
||||
import {
|
||||
IDBObjectStoreParameters,
|
||||
IDBRequest,
|
||||
IDBTransaction,
|
||||
IDBValidKey,
|
||||
@ -574,7 +573,7 @@ export class Database {
|
||||
|
||||
async get<N extends string, T>(
|
||||
store: Store<N, T>,
|
||||
key: any,
|
||||
key: IDBValidKey,
|
||||
): Promise<T | undefined> {
|
||||
const tx = this.db.transaction([store.name], "readonly");
|
||||
const req = tx.objectStore(store.name).get(key);
|
||||
@ -585,7 +584,7 @@ export class Database {
|
||||
|
||||
async getIndexed<Ind extends Index<string, string, any, any>>(
|
||||
index: InferIndex<Ind>,
|
||||
key: any,
|
||||
key: IDBValidKey,
|
||||
): Promise<IndexRecord<Ind> | undefined> {
|
||||
const tx = this.db.transaction([index.storeName], "readonly");
|
||||
const req = tx.objectStore(index.storeName).index(index.indexName).get(key);
|
||||
@ -597,7 +596,7 @@ export class Database {
|
||||
async put<St extends Store<string, any>>(
|
||||
store: St,
|
||||
value: StoreContent<St>,
|
||||
key?: any,
|
||||
key?: IDBValidKey,
|
||||
): Promise<any> {
|
||||
const tx = this.db.transaction([store.name], "readwrite");
|
||||
const req = tx.objectStore(store.name).put(value, key);
|
||||
@ -608,7 +607,7 @@ export class Database {
|
||||
|
||||
async mutate<N extends string, T>(
|
||||
store: Store<N, T>,
|
||||
key: any,
|
||||
key: IDBValidKey,
|
||||
f: (x: T) => T | undefined,
|
||||
): Promise<void> {
|
||||
const tx = this.db.transaction([store.name], "readwrite");
|
||||
|
@ -89,4 +89,4 @@ export function initRetryInfo(
|
||||
};
|
||||
updateRetryInfoTimeout(info, p);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
import { canonicalizeBaseUrl } from './helpers';
|
||||
import { canonicalizeBaseUrl } from "./helpers";
|
||||
import { URLSearchParams } from "./url";
|
||||
|
||||
export interface PayUriResult {
|
||||
|
@ -132,7 +132,11 @@ import {
|
||||
PendingOperationType,
|
||||
} from "./types/pending";
|
||||
import { WalletNotification, NotificationType } from "./types/notifications";
|
||||
import { processPurchaseQueryRefund, applyRefund, abortFailedPayWithRefund } from "./operations/refund";
|
||||
import {
|
||||
processPurchaseQueryRefund,
|
||||
applyRefund,
|
||||
abortFailedPayWithRefund,
|
||||
} from "./operations/refund";
|
||||
import { durationMin, Duration } from "./util/time";
|
||||
import { processRecoupGroup } from "./operations/recoup";
|
||||
import {
|
||||
@ -152,7 +156,12 @@ import {
|
||||
testPay,
|
||||
} from "./operations/testing";
|
||||
import { TalerErrorCode } from ".";
|
||||
import { addBackupProvider, codecForAddBackupProviderRequest, runBackupCycle, exportBackup } from './operations/backup';
|
||||
import {
|
||||
addBackupProvider,
|
||||
codecForAddBackupProviderRequest,
|
||||
runBackupCycle,
|
||||
exportBackup,
|
||||
} from "./operations/backup";
|
||||
|
||||
const builtinCurrencies: CurrencyRecord[] = [
|
||||
{
|
||||
@ -721,9 +730,7 @@ export class Wallet {
|
||||
* Accept a refund, return the contract hash for the contract
|
||||
* that was involved in the refund.
|
||||
*/
|
||||
async applyRefund(
|
||||
talerRefundUri: string,
|
||||
): Promise<ApplyRefundResponse> {
|
||||
async applyRefund(talerRefundUri: string): Promise<ApplyRefundResponse> {
|
||||
return applyRefund(this.ws, talerRefundUri);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user