summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-10-22 14:47:50 -0300
committerSebastian <sebasjm@gmail.com>2023-10-22 14:47:50 -0300
commit5e160a2d4d1d77c87600f28f806bc94c086267c7 (patch)
treeec8475a39d7aa4565b490e259d787b195fb98bb3 /packages/taler-wallet-core
parent2005273d1286819e68d3ea7a3290f8c357be5e40 (diff)
downloadwallet-core-5e160a2d4d1d77c87600f28f806bc94c086267c7.tar.gz
wallet-core-5e160a2d4d1d77c87600f28f806bc94c086267c7.tar.bz2
wallet-core-5e160a2d4d1d77c87600f28f806bc94c086267c7.zip
update the amountString definitionv0.9.3-dev.34
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/operations/testing.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.test.ts12
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.test.ts22
-rw-r--r--packages/taler-wallet-core/src/util/denominations.test.ts2
-rw-r--r--packages/taler-wallet-core/src/wallet.ts11
5 files changed, 26 insertions, 25 deletions
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts
index f5bed13dd..3fff9ccaa 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -680,7 +680,7 @@ export async function runIntegrationTest2(
const peerPushInit = await initiatePeerPushDebit(ws, {
partialContractTerms: {
- amount: `${currency}:1`,
+ amount: `${currency}:1` as AmountString,
summary: "Payment Peer Push Test",
purse_expiration: AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
@@ -703,7 +703,7 @@ export async function runIntegrationTest2(
const peerPullInit = await initiatePeerPullPayment(ws, {
partialContractTerms: {
- amount: `${currency}:1`,
+ amount: `${currency}:1` as AmountString,
summary: "Payment Peer Pull Test",
purse_expiration: AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
diff --git a/packages/taler-wallet-core/src/operations/withdraw.test.ts b/packages/taler-wallet-core/src/operations/withdraw.test.ts
index cb8aa5e81..97a80ec26 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.test.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.test.ts
@@ -14,7 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Amounts, DenomKeyType } from "@gnu-taler/taler-util";
+import { AmountString, Amounts, DenomKeyType } from "@gnu-taler/taler-util";
import test from "ava";
import {
DenominationRecord,
@@ -82,7 +82,7 @@ test("withdrawal selection bug repro", (t) => {
}),
verificationStatus: DenominationVerificationStatus.Unverified,
currency: "KUDOS",
- value: "KUDOS:1000",
+ value: "KUDOS:1000" as AmountString,
listIssueDate: timestampProtocolToDb({ t_s: 0 }),
},
{
@@ -136,7 +136,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
}),
verificationStatus: DenominationVerificationStatus.Unverified,
- value: "KUDOS:10",
+ value: "KUDOS:10" as AmountString,
currency: "KUDOS",
listIssueDate: timestampProtocolToDb({ t_s: 0 }),
},
@@ -190,7 +190,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
}),
verificationStatus: DenominationVerificationStatus.Unverified,
- value: "KUDOS:5",
+ value: "KUDOS:5" as AmountString,
currency: "KUDOS",
listIssueDate: timestampProtocolToDb({ t_s: 0 }),
},
@@ -245,7 +245,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
}),
verificationStatus: DenominationVerificationStatus.Unverified,
- value: "KUDOS:1",
+ value: "KUDOS:1" as AmountString,
currency: "KUDOS",
listIssueDate: timestampProtocolToDb({ t_s: 0 }),
},
@@ -357,7 +357,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
}),
verificationStatus: DenominationVerificationStatus.Unverified,
- value: "KUDOS:2",
+ value: "KUDOS:2" as AmountString,
currency: "KUDOS",
listIssueDate: timestampProtocolToDb({ t_s: 0 }),
},
diff --git a/packages/taler-wallet-core/src/util/coinSelection.test.ts b/packages/taler-wallet-core/src/util/coinSelection.test.ts
index 81a656f8a..69c25a2fa 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.test.ts
+++ b/packages/taler-wallet-core/src/util/coinSelection.test.ts
@@ -48,9 +48,9 @@ test("p2p: should select the coin", (t) => {
const coins = testing_greedySelectPeer(
createCandidates([
{
- amount: "LOCAL:10",
+ amount: "LOCAL:10" as AmountString,
numAvailable: 5,
- depositFee: "LOCAL:0.1",
+ depositFee: "LOCAL:0.1" as AmountString,
fromExchange: "http://exchange.localhost/",
},
]),
@@ -86,9 +86,9 @@ test("p2p: should select 3 coins", (t) => {
const coins = testing_greedySelectPeer(
createCandidates([
{
- amount: "LOCAL:10",
+ amount: "LOCAL:10" as AmountString,
numAvailable: 5,
- depositFee: "LOCAL:0.1",
+ depositFee: "LOCAL:0.1" as AmountString,
fromExchange: "http://exchange.localhost/",
},
]),
@@ -126,9 +126,9 @@ test("p2p: can't select since the instructed amount is too high", (t) => {
const coins = testing_greedySelectPeer(
createCandidates([
{
- amount: "LOCAL:10",
+ amount: "LOCAL:10" as AmountString,
numAvailable: 5,
- depositFee: "LOCAL:0.1",
+ depositFee: "LOCAL:0.1" as AmountString,
fromExchange: "http://exchange.localhost/",
},
]),
@@ -176,9 +176,9 @@ test("pay: select one coin to pay with fee", (t) => {
},
createCandidates([
{
- amount: "LOCAL:10",
+ amount: "LOCAL:10" as AmountString,
numAvailable: 5,
- depositFee: "LOCAL:0.1",
+ depositFee: "LOCAL:0.1" as AmountString,
fromExchange: "http://exchange.localhost/",
},
]),
@@ -224,9 +224,9 @@ function createCandidates(
denomPubHash: `hash${idx}`,
value: r.amount,
feeDeposit: r.depositFee,
- feeRefresh: "LOCAL:0",
- feeRefund: "LOCAL:0",
- feeWithdraw: "LOCAL:0",
+ feeRefresh: "LOCAL:0" as AmountString,
+ feeRefund: "LOCAL:0" as AmountString,
+ feeWithdraw: "LOCAL:0" as AmountString,
stampExpireDeposit: inTheDistantFuture,
stampExpireLegal: inTheDistantFuture,
stampExpireWithdraw: inTheDistantFuture,
diff --git a/packages/taler-wallet-core/src/util/denominations.test.ts b/packages/taler-wallet-core/src/util/denominations.test.ts
index 25dbda081..98af5d1a4 100644
--- a/packages/taler-wallet-core/src/util/denominations.test.ts
+++ b/packages/taler-wallet-core/src/util/denominations.test.ts
@@ -39,7 +39,7 @@ import test, { ExecutionContext } from "ava";
* Create some constants to be used as reference in the tests
*/
const VALUES: AmountString[] = Array.from({ length: 10 }).map(
- (undef, t) => `USD:${t}`,
+ (undef, t) => `USD:${t}` as AmountString,
);
const TIMESTAMPS = Array.from({ length: 20 }).map((undef, t_s) => ({ t_s }));
const ABS_TIME = TIMESTAMPS.map((m) => AbsoluteTime.fromProtocolTimestamp(m));
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 6600aa799..fe77fecc1 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -132,6 +132,7 @@ import {
codecForListExchangesForScopedCurrencyRequest,
ListExchangesForScopedCurrencyRequest,
ExchangesShortListResponse,
+ AmountString,
} from "@gnu-taler/taler-util";
import type { HttpRequestLibrary } from "@gnu-taler/taler-util/http";
import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
@@ -931,9 +932,9 @@ async function dumpCoins(ws: InternalWalletState): Promise<CoinDumpJson> {
ageCommitmentProof: c.ageCommitmentProof,
spend_allocation: c.spendAllocation
? {
- amount: c.spendAllocation.amount,
- id: c.spendAllocation.id,
- }
+ amount: c.spendAllocation.amount,
+ id: c.spendAllocation.id,
+ }
: undefined,
});
}
@@ -1076,7 +1077,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
}
case WalletApiOperation.WithdrawTestkudos: {
await withdrawTestBalance(ws, {
- amount: "TESTKUDOS:10",
+ amount: "TESTKUDOS:10" as AmountString,
corebankApiBaseUrl: "https://bank.test.taler.net/",
exchangeBaseUrl: "https://exchange.test.taler.net/",
});
@@ -1278,7 +1279,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
typeof url.templateParams.amount === "string"
) {
templateDetails.amount =
- req.templateParams.amount ?? url.templateParams.amount;
+ (req.templateParams.amount ?? url.templateParams.amount) as AmountString | undefined;
}
if (
url.templateParams.summary !== undefined &&