diff options
Diffstat (limited to 'packages/taler-wallet-core/src/util')
| -rw-r--r-- | packages/taler-wallet-core/src/util/coinSelection.test.ts | 17 | ||||
| -rw-r--r-- | packages/taler-wallet-core/src/util/coinSelection.ts | 1 | ||||
| -rw-r--r-- | packages/taler-wallet-core/src/util/query.ts | 15 | 
3 files changed, 25 insertions, 8 deletions
| diff --git a/packages/taler-wallet-core/src/util/coinSelection.test.ts b/packages/taler-wallet-core/src/util/coinSelection.test.ts index 3c6ad0d82..fe9672116 100644 --- a/packages/taler-wallet-core/src/util/coinSelection.test.ts +++ b/packages/taler-wallet-core/src/util/coinSelection.test.ts @@ -18,7 +18,12 @@   * Imports.   */  import test from "ava"; -import { AmountJson, Amounts, DenomKeyType } from "@gnu-taler/taler-util"; +import { +  AgeRestriction, +  AmountJson, +  Amounts, +  DenomKeyType, +} from "@gnu-taler/taler-util";  import { AvailableCoinInfo, selectPayCoinsLegacy } from "./coinSelection.js";  function a(x: string): AmountJson { @@ -41,10 +46,14 @@ function fakeAci(current: string, feeDeposit: string): AvailableCoinInfo {      },      feeDeposit: a(feeDeposit),      exchangeBaseUrl: "https://example.com/", +    maxAge: AgeRestriction.AGE_UNRESTRICTED,    };  } -function fakeAciWithAgeRestriction(current: string, feeDeposit: string): AvailableCoinInfo { +function fakeAciWithAgeRestriction( +  current: string, +  feeDeposit: string, +): AvailableCoinInfo {    return {      value: a(current),      availableAmount: a(current), @@ -56,6 +65,7 @@ function fakeAciWithAgeRestriction(current: string, feeDeposit: string): Availab      },      feeDeposit: a(feeDeposit),      exchangeBaseUrl: "https://example.com/", +    maxAge: AgeRestriction.AGE_UNRESTRICTED,    };  } @@ -284,7 +294,6 @@ test("coin selection 9", (t) => {    t.pass();  }); -  test("it should be able to use unrestricted coins for age restricted contract", (t) => {    const acis: AvailableCoinInfo[] = [      fakeAciWithAgeRestriction("EUR:1.0", "EUR:0.2"), @@ -299,7 +308,7 @@ test("it should be able to use unrestricted coins for age restricted contract",      depositFeeLimit: a("EUR:0.4"),      wireFeeLimit: a("EUR:0"),      wireFeeAmortization: 1, -    requiredMinimumAge: 13 +    requiredMinimumAge: 13,    });    if (!res) {      t.fail(); diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts index 9622b3a76..d2f12baf5 100644 --- a/packages/taler-wallet-core/src/util/coinSelection.ts +++ b/packages/taler-wallet-core/src/util/coinSelection.ts @@ -72,6 +72,7 @@ export interface AvailableCoinInfo {    exchangeBaseUrl: string; +  maxAge: number;    ageCommitmentProof?: AgeCommitmentProof;  } diff --git a/packages/taler-wallet-core/src/util/query.ts b/packages/taler-wallet-core/src/util/query.ts index 17b713659..8b8c30f35 100644 --- a/packages/taler-wallet-core/src/util/query.ts +++ b/packages/taler-wallet-core/src/util/query.ts @@ -33,6 +33,7 @@ import {    IDBVersionChangeEvent,    IDBCursor,    IDBKeyPath, +  IDBKeyRange,  } from "@gnu-taler/idb-bridge";  import { Logger } from "@gnu-taler/taler-util";  import { performanceNow } from "./timer.js"; @@ -309,9 +310,12 @@ export function describeIndex(  }  interface IndexReadOnlyAccessor<RecordType> { -  iter(query?: IDBValidKey): ResultStream<RecordType>; +  iter(query?: IDBKeyRange | IDBValidKey): ResultStream<RecordType>;    get(query: IDBValidKey): Promise<RecordType | undefined>; -  getAll(query: IDBValidKey, count?: number): Promise<RecordType[]>; +  getAll( +    query: IDBKeyRange | IDBValidKey, +    count?: number, +  ): Promise<RecordType[]>;  }  type GetIndexReadOnlyAccess<RecordType, IndexMap> = { @@ -319,9 +323,12 @@ type GetIndexReadOnlyAccess<RecordType, IndexMap> = {  };  interface IndexReadWriteAccessor<RecordType> { -  iter(query: IDBValidKey): ResultStream<RecordType>; +  iter(query: IDBKeyRange | IDBValidKey): ResultStream<RecordType>;    get(query: IDBValidKey): Promise<RecordType | undefined>; -  getAll(query: IDBValidKey, count?: number): Promise<RecordType[]>; +  getAll( +    query: IDBKeyRange | IDBValidKey, +    count?: number, +  ): Promise<RecordType[]>;  }  type GetIndexReadWriteAccess<RecordType, IndexMap> = { | 
