diff options
author | Sebastian <sebasjm@gmail.com> | 2023-10-22 14:47:50 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-10-22 14:47:50 -0300 |
commit | 5e160a2d4d1d77c87600f28f806bc94c086267c7 (patch) | |
tree | ec8475a39d7aa4565b490e259d787b195fb98bb3 /packages/taler-wallet-webextension | |
parent | 2005273d1286819e68d3ea7a3290f8c357be5e40 (diff) |
update the amountString definitionv0.9.3-dev.34
Diffstat (limited to 'packages/taler-wallet-webextension')
19 files changed, 324 insertions, 311 deletions
diff --git a/packages/taler-wallet-webextension/src/components/Amount.stories.tsx b/packages/taler-wallet-webextension/src/components/Amount.stories.tsx index 095c9be24..fa28088eb 100644 --- a/packages/taler-wallet-webextension/src/components/Amount.stories.tsx +++ b/packages/taler-wallet-webextension/src/components/Amount.stories.tsx @@ -22,6 +22,7 @@ import { styled } from "@linaria/react"; import { Fragment, h, VNode } from "preact"; import { Amount } from "./Amount.js"; +import { AmountString } from "@gnu-taler/taler-util"; export default { title: "amount", @@ -39,7 +40,7 @@ const Table = styled.table` function ProductTable( prods: string[], - AmountRender: (p: { value: string; index: number }) => VNode = Amount, + AmountRender: (p: { value: AmountString; index: number }) => VNode = Amount, ): VNode { return ( <Table> @@ -52,7 +53,7 @@ function ProductTable( <tr key={i}> <td>p{i}</td> <td> - <AmountRender value={value} index={i} /> + <AmountRender value={value as AmountString} index={i} /> {/* <Amount value={value} fracSize={fracSize} /> */} </td> </tr> diff --git a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.stories.tsx b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.stories.tsx index 1b1802b8c..555b300c2 100644 --- a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.stories.tsx +++ b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.stories.tsx @@ -25,14 +25,14 @@ import { LoadingView, ShowView, } from "./ShowFullContractTermPopup.js"; -import { WalletContractData } from "@gnu-taler/taler-util"; +import { AmountString, WalletContractData } from "@gnu-taler/taler-util"; export default { title: "ShowFullContractTermPopup", }; const cd: WalletContractData = { - amount: "ARS:2", + amount: "ARS:2" as AmountString, contractTermsHash: "92X0KSJPZ8XS2XECCGFWTCGW8XMFCXTT2S6WHZDP6H9Y3TSKMTHY94WXEWDERTNN5XWCYGW4VN5CF2D4846HXTW7P06J4CZMHCWKC9G", fulfillmentUrl: "", @@ -42,7 +42,7 @@ const cd: WalletContractData = { "0YA1WETV15R6K8QKS79QA3QMT16010F42Q49VSKYQ71HVQKAG0A4ZJCA4YTKHE9EA5SP156TJSKZEJJJ87305N6PS80PC48RNKYZE08", orderId: "2022.220-0281XKKB8W7YE", summary: "w", - maxWireFee: "ARS:1", + maxWireFee: "ARS:1" as AmountString, payDeadline: { t_s: 1660002673, }, @@ -62,7 +62,7 @@ const cd: WalletContractData = { wireMethod: "x-taler-bank", wireInfoHash: "QDT28374ZHYJ59WQFZ3TW1D5WKJVDYHQT86VHED3TNMB15ANJSKXDYPPNX01348KDYCX6T4WXA5A8FJJ8YWNEB1JW726C1JPKHM89DR", - maxDepositFee: "ARS:1", + maxDepositFee: "ARS:1" as AmountString, merchant: { name: "Default", address: { diff --git a/packages/taler-wallet-webextension/src/cta/Deposit/test.ts b/packages/taler-wallet-webextension/src/cta/Deposit/test.ts index 144bdccf4..100929918 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Deposit/test.ts @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { Amounts } from "@gnu-taler/taler-util"; +import { AmountString, Amounts } from "@gnu-taler/taler-util"; import { expect } from "chai"; import { createWalletApiMock } from "../../test-utils.js"; import { useComponentState } from "./state.js"; @@ -72,19 +72,19 @@ describe("Deposit CTA states", () => { WalletApiOperation.PrepareDeposit, undefined, { - effectiveDepositAmount: "EUR:1", - totalDepositCost: "EUR:1.2", + effectiveDepositAmount: "EUR:1" as AmountString, + totalDepositCost: "EUR:1.2" as AmountString, fees: { - coin: "EUR:0", - refresh: "EUR:0.2", - wire: "EUR:0", + coin: "EUR:0" as AmountString, + refresh: "EUR:0.2" as AmountString, + wire: "EUR:0" as AmountString, }, }, ); const props = { talerDepositUri: "payto://refund/asdasdas", - amountStr: "EUR:1", + amountStr: "EUR:1" as AmountString, cancel: async () => { null; }, diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts index b8aaed3f2..fd3fb52f8 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { AmountJson } from "@gnu-taler/taler-util"; +import { AmountJson, AmountString } from "@gnu-taler/taler-util"; import { ErrorAlertView } from "../../components/CurrentAlerts.js"; import { Loading } from "../../components/Loading.js"; import { ErrorAlert } from "../../context/alert.js"; @@ -27,7 +27,7 @@ import { useComponentState } from "./state.js"; import { ReadyView } from "./views.js"; export interface Props { - amount: string; + amount: AmountString; onClose: () => Promise<void>; onSuccess: (tx: string) => Promise<void>; } diff --git a/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx b/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx index f030fa219..eee5fb684 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx @@ -20,6 +20,7 @@ */ import { + AmountString, Amounts, MerchantContractTerms as ContractTerms, PreparePayResultType, @@ -52,13 +53,13 @@ export const NoEnoughBalanceAvailable = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:9", - balanceMaterial: "USD:9", - balanceAgeAcceptable: "USD:9", - balanceMerchantAcceptable: "USD:9", - balanceMerchantDepositable: "USD:9", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:9" as AmountString, + balanceMaterial: "USD:9" as AmountString, + balanceAgeAcceptable: "USD:9" as AmountString, + balanceMerchantAcceptable: "USD:9" as AmountString, + balanceMerchantDepositable: "USD:9" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -73,7 +74,7 @@ export const NoEnoughBalanceAvailable = tests.createExample(BaseView, { summary: "some beers", amount: "USD:10", } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }); @@ -92,13 +93,13 @@ export const NoEnoughBalanceMaterial = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:10", - balanceMaterial: "USD:9", - balanceAgeAcceptable: "USD:9", - balanceMerchantAcceptable: "USD:9", - balanceMerchantDepositable: "USD:0", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:10" as AmountString, + balanceMaterial: "USD:9" as AmountString, + balanceAgeAcceptable: "USD:9" as AmountString, + balanceMerchantAcceptable: "USD:9" as AmountString, + balanceMerchantDepositable: "USD:0" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -111,9 +112,9 @@ export const NoEnoughBalanceMaterial = tests.createExample(BaseView, { email: "contact@merchant.taler", }, summary: "some beers", - amount: "USD:10", + amount: "USD:10" as AmountString, } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }); @@ -132,13 +133,13 @@ export const NoEnoughBalanceAgeAcceptable = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:10", - balanceMaterial: "USD:10", - balanceAgeAcceptable: "USD:9", - balanceMerchantAcceptable: "USD:9", - balanceMerchantDepositable: "USD:9", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:10" as AmountString, + balanceMaterial: "USD:10" as AmountString, + balanceAgeAcceptable: "USD:9" as AmountString, + balanceMerchantAcceptable: "USD:9" as AmountString, + balanceMerchantDepositable: "USD:9" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -154,7 +155,7 @@ export const NoEnoughBalanceAgeAcceptable = tests.createExample(BaseView, { summary: "some beers", amount: "USD:10", } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }); @@ -173,13 +174,13 @@ export const NoEnoughBalanceMerchantAcceptable = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:10", - balanceMaterial: "USD:10", - balanceAgeAcceptable: "USD:10", - balanceMerchantAcceptable: "USD:9", - balanceMerchantDepositable: "USD:9", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:10" as AmountString, + balanceMaterial: "USD:10" as AmountString, + balanceAgeAcceptable: "USD:10" as AmountString, + balanceMerchantAcceptable: "USD:9" as AmountString, + balanceMerchantDepositable: "USD:9" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -192,9 +193,9 @@ export const NoEnoughBalanceMerchantAcceptable = tests.createExample(BaseView, { email: "contact@merchant.taler", }, summary: "some beers", - amount: "USD:10", + amount: "USD:10" as AmountString, } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }); @@ -215,13 +216,13 @@ export const NoEnoughBalanceMerchantDepositable = tests.createExample( transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:10", - balanceMaterial: "USD:10", - balanceAgeAcceptable: "USD:10", - balanceMerchantAcceptable: "USD:10", - balanceMerchantDepositable: "USD:9", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:10" as AmountString, + balanceMaterial: "USD:10" as AmountString, + balanceAgeAcceptable: "USD:10" as AmountString, + balanceMerchantAcceptable: "USD:10" as AmountString, + balanceMerchantDepositable: "USD:9" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -234,9 +235,9 @@ export const NoEnoughBalanceMerchantDepositable = tests.createExample( email: "contact@merchant.taler", }, summary: "some beers", - amount: "USD:10", + amount: "USD:10" as AmountString, } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }, ); @@ -256,13 +257,13 @@ export const NoEnoughBalanceFeeGap = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.InsufficientBalance, balanceDetails: { - amountRequested: "USD:10", - balanceAvailable: "USD:10", - balanceMaterial: "USD:10", - balanceAgeAcceptable: "USD:10", - balanceMerchantAcceptable: "USD:10", - balanceMerchantDepositable: "USD:10", - feeGapEstimate: "USD:1", + amountRequested: "USD:10" as AmountString, + balanceAvailable: "USD:10" as AmountString, + balanceMaterial: "USD:10" as AmountString, + balanceAgeAcceptable: "USD:10" as AmountString, + balanceMerchantAcceptable: "USD:10" as AmountString, + balanceMerchantDepositable: "USD:10" as AmountString, + feeGapEstimate: "USD:1" as AmountString, }, talerUri: "taler://pay/..", @@ -276,9 +277,9 @@ export const NoEnoughBalanceFeeGap = tests.createExample(BaseView, { }, minimum_age: 18, summary: "some beers", - amount: "USD:10", + amount: "USD:10" as AmountString, } as Partial<ContractTerms> as any, - amountRaw: "USD:10", + amountRaw: "USD:10" as AmountString, }, }); @@ -300,8 +301,8 @@ export const PaymentPossible = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.PaymentPossible, talerUri: "taler://pay/..", - amountEffective: "USD:10", - amountRaw: "USD:10", + amountEffective: "USD:10" as AmountString, + amountRaw: "USD:10" as AmountString, contractTerms: { nonce: "123213123", @@ -314,7 +315,7 @@ export const PaymentPossible = tests.createExample(BaseView, { pay_deadline: { t_s: new Date().getTime() / 1000 + 60 * 60 * 3, }, - amount: "USD:10", + amount: "USD:10" as AmountString, summary: "some beers", } as Partial<ContractTerms> as any, contractTermsHash: "123456", @@ -340,8 +341,8 @@ export const PaymentPossibleWithFee = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.PaymentPossible, talerUri: "taler://pay/..", - amountEffective: "USD:10.20", - amountRaw: "USD:10", + amountEffective: "USD:10.20" as AmountString, + amountRaw: "USD:10" as AmountString, contractTerms: { nonce: "123213123", @@ -351,7 +352,7 @@ export const PaymentPossibleWithFee = tests.createExample(BaseView, { website: "https://www.themerchant.taler", email: "contact@merchant.taler", }, - amount: "USD:10", + amount: "USD:10" as AmountString, summary: "some beers", } as Partial<ContractTerms> as any, contractTermsHash: "123456", @@ -377,8 +378,8 @@ export const TicketWithAProductList = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.PaymentPossible, talerUri: "taler://pay/..", - amountEffective: "USD:10.20", - amountRaw: "USD:10", + amountEffective: "USD:10.20" as AmountString, + amountRaw: "USD:10" as AmountString, contractTerms: { nonce: "123213123", @@ -433,8 +434,8 @@ export const TicketWithShipping = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.PaymentPossible, talerUri: "taler://pay/..", - amountEffective: "USD:10.20", - amountRaw: "USD:10", + amountEffective: "USD:10.20" as AmountString, + amountRaw: "USD:10" as AmountString, contractTerms: { nonce: "123213123", @@ -481,8 +482,8 @@ export const AlreadyConfirmedByOther = tests.createExample(BaseView, { transactionId: " " as TransactionIdStr, status: PreparePayResultType.AlreadyConfirmed, talerUri: "taler://pay/..", - amountEffective: "USD:10", - amountRaw: "USD:10", + amountEffective: "USD:10" as AmountString, + amountRaw: "USD:10" as AmountString, contractTerms: { merchant: { name: "the merchant", diff --git a/packages/taler-wallet-webextension/src/cta/Payment/test.ts b/packages/taler-wallet-webextension/src/cta/Payment/test.ts index e2935fc4e..213382efc 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Payment/test.ts @@ -20,6 +20,7 @@ */ import { + AmountString, Amounts, ConfirmPayResult, ConfirmPayResultType, @@ -139,10 +140,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:5", + available: "USD:5" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -199,10 +200,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:15", + available: "USD:15" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -262,10 +263,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:15", + available: "USD:15" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -323,10 +324,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:15", + available: "USD:15" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -392,10 +393,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:15", + available: "USD:15" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -480,10 +481,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:10", + available: "USD:10" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", @@ -511,10 +512,10 @@ describe("Payment CTA states", () => { { balances: [ { - available: "USD:15", + available: "USD:15" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "USD", diff --git a/packages/taler-wallet-webextension/src/cta/Reward/test.ts b/packages/taler-wallet-webextension/src/cta/Reward/test.ts index 6d7bad0c8..0e378f366 100644 --- a/packages/taler-wallet-webextension/src/cta/Reward/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Reward/test.ts @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { Amounts } from "@gnu-taler/taler-util"; +import { AmountString, Amounts } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { expect } from "chai"; import * as tests from "@gnu-taler/web-util/testing"; @@ -66,13 +66,13 @@ describe("Tip CTA states", () => { accepted: false, exchangeBaseUrl: "exchange url", merchantBaseUrl: "merchant url", - rewardAmountEffective: "EUR:1", + rewardAmountEffective: "EUR:1" as AmountString, walletRewardId: "tip_id", transactionId: "txn:tip:ABC1234", expirationTimestamp: { t_s: 1, }, - rewardAmountRaw: "", + rewardAmountRaw: "EUR:0" as AmountString, }); const props: Props = { @@ -110,13 +110,13 @@ describe("Tip CTA states", () => { accepted: true, exchangeBaseUrl: "exchange url", merchantBaseUrl: "merchant url", - rewardAmountEffective: "EUR:1", + rewardAmountEffective: "EUR:1" as AmountString, walletRewardId: "tip_id", transactionId: "txn:tip:ABC1234", expirationTimestamp: { t_s: 1, }, - rewardAmountRaw: "", + rewardAmountRaw: "EUR:0" as AmountString, }, ); }, @@ -140,14 +140,14 @@ describe("Tip CTA states", () => { handler.addWalletCallResponse(WalletApiOperation.PrepareReward, undefined, { exchangeBaseUrl: "exchange url", merchantBaseUrl: "merchant url", - rewardAmountEffective: "EUR:1", + rewardAmountEffective: "EUR:1" as AmountString, walletRewardId: "tip_id", transactionId: "txn:tip:ABC1234", accepted: false, expirationTimestamp: { t_s: 1, }, - rewardAmountRaw: "", + rewardAmountRaw: "EUR:0" as AmountString, }); const props: Props = { @@ -188,13 +188,13 @@ describe("Tip CTA states", () => { accepted: true, exchangeBaseUrl: "exchange url", merchantBaseUrl: "merchant url", - rewardAmountEffective: "EUR:1", + rewardAmountEffective: "EUR:1" as AmountString, walletRewardId: "tip_id", transactionId: "txn:tip:ABC1234", expirationTimestamp: { t_s: 1, }, - rewardAmountRaw: "", + rewardAmountRaw: "EUR:0" as AmountString, }); const props: Props = { diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts index 654b03b7f..794d2ad1c 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { AmountJson, TalerErrorDetail } from "@gnu-taler/taler-util"; +import { AmountJson, AmountString, TalerErrorDetail } from "@gnu-taler/taler-util"; import { ErrorAlertView } from "../../components/CurrentAlerts.js"; import { Loading } from "../../components/Loading.js"; import { ErrorAlert } from "../../context/alert.js"; @@ -24,7 +24,7 @@ import { useComponentState } from "./state.js"; import { ReadyView } from "./views.js"; export interface Props { - amount: string; + amount: AmountString; onClose: () => Promise<void>; onSuccess: (tx: string) => Promise<void>; } diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts index 77333e15c..297e8a56b 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts @@ -15,6 +15,7 @@ */ import { + AmountString, Amounts, TalerError, TalerErrorCode, @@ -141,7 +142,7 @@ export function useComponentState({ async function checkPeerPushDebitAndCheckMax( api: WxApiType, - amountState: string, + amountState: AmountString, ) { // FIXME : https://bugs.gnunet.org/view.php?id=7872 try { diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts index ab3b2e316..e5eaa3c14 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts @@ -20,6 +20,7 @@ */ import { + AmountString, Amounts, ExchangeEntryStatus, ExchangeListItem, @@ -109,7 +110,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForUri, undefined, { - amount: "EUR:2", + amount: "EUR:2" as AmountString, possibleExchanges: [], }, ); @@ -145,7 +146,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForUri, undefined, { - amount: "ARS:2", + amount: "ARS:2" as AmountString, possibleExchanges: exchanges, defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl, }, @@ -154,8 +155,8 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForAmount, undefined, { - amountRaw: "ARS:2", - amountEffective: "ARS:2", + amountRaw: "ARS:2" as AmountString, + amountEffective: "ARS:2" as AmountString, paytoUris: ["payto://"], tosAccepted: true, ageRestrictionOptions: [], @@ -209,7 +210,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForUri, undefined, { - amount: "ARS:2", + amount: "ARS:2" as AmountString, possibleExchanges: exchangeWithNewTos, defaultExchangeBaseUrl: exchangeWithNewTos[0].exchangeBaseUrl, }, @@ -218,8 +219,8 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForAmount, undefined, { - amountRaw: "ARS:2", - amountEffective: "ARS:2", + amountRaw: "ARS:2" as AmountString, + amountEffective: "ARS:2" as AmountString, paytoUris: ["payto://"], tosAccepted: false, ageRestrictionOptions: [], @@ -231,7 +232,7 @@ describe("Withdraw CTA states", () => { WalletApiOperation.GetWithdrawalDetailsForUri, undefined, { - amount: "ARS:2", + amount: "ARS:2" as AmountString, possibleExchanges: exchanges, defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl, }, diff --git a/packages/taler-wallet-webextension/src/popup/Balance.stories.tsx b/packages/taler-wallet-webextension/src/popup/Balance.stories.tsx index d2c074d32..dd8142b68 100644 --- a/packages/taler-wallet-webextension/src/popup/Balance.stories.tsx +++ b/packages/taler-wallet-webextension/src/popup/Balance.stories.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { ScopeType } from "@gnu-taler/taler-util"; +import { AmountString, ScopeType } from "@gnu-taler/taler-util"; import * as tests from "@gnu-taler/web-util/testing"; import { BalanceView as TestedComponent } from "./BalancePage.js"; @@ -35,10 +35,10 @@ export const EmptyBalance = tests.createExample(TestedComponent, { export const SomeCoins = tests.createExample(TestedComponent, { balances: [ { - available: "USD:10.5", + available: "USD:10.5" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -54,10 +54,10 @@ export const SomeCoins = tests.createExample(TestedComponent, { export const SomeCoinsInTreeCurrencies = tests.createExample(TestedComponent, { balances: [ { - available: "EUR:1", + available: "EUR:1" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -66,10 +66,10 @@ export const SomeCoinsInTreeCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "TESTKUDOS:2000", + available: "TESTKUDOS:2000" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -78,10 +78,10 @@ export const SomeCoinsInTreeCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "JPY:4", + available: "JPY:4" as AmountString, hasPendingTransactions: false, - pendingIncoming: "EUR:15", - pendingOutgoing: "EUR:0", + pendingIncoming: "EUR:15" as AmountString, + pendingOutgoing: "EUR:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -97,10 +97,10 @@ export const SomeCoinsInTreeCurrencies = tests.createExample(TestedComponent, { export const NoCoinsInTreeCurrencies = tests.createExample(TestedComponent, { balances: [ { - available: "EUR:3", + available: "EUR:3" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -109,10 +109,10 @@ export const NoCoinsInTreeCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "USD:2", + available: "USD:2" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -121,10 +121,10 @@ export const NoCoinsInTreeCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "ARS:1", + available: "ARS:1" as AmountString, hasPendingTransactions: false, - pendingIncoming: "EUR:15", - pendingOutgoing: "EUR:0", + pendingIncoming: "EUR:15" as AmountString, + pendingOutgoing: "EUR:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -140,10 +140,10 @@ export const NoCoinsInTreeCurrencies = tests.createExample(TestedComponent, { export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { balances: [ { - available: "USD:0", + available: "USD:0" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -152,10 +152,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "ARS:13451", + available: "ARS:13451" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -164,10 +164,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "EUR:202.02", + available: "EUR:202.02" as AmountString, hasPendingTransactions: false, - pendingIncoming: "EUR:0", - pendingOutgoing: "EUR:0", + pendingIncoming: "EUR:0" as AmountString, + pendingOutgoing: "EUR:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -176,10 +176,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "JPY:0", + available: "JPY:0" as AmountString, hasPendingTransactions: false, - pendingIncoming: "EUR:0", - pendingOutgoing: "EUR:0", + pendingIncoming: "EUR:0" as AmountString, + pendingOutgoing: "EUR:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -188,10 +188,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "JPY:51223233", + available: "JPY:51223233" as AmountString, hasPendingTransactions: false, - pendingIncoming: "EUR:0", - pendingOutgoing: "EUR:0", + pendingIncoming: "EUR:0" as AmountString, + pendingOutgoing: "EUR:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -200,10 +200,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "DEMOKUDOS:6", + available: "DEMOKUDOS:6" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", @@ -212,10 +212,10 @@ export const SomeCoinsInFiveCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "TESTKUDOS:6", + available: "TESTKUDOS:6" as AmountString, hasPendingTransactions: false, - pendingIncoming: "USD:5", - pendingOutgoing: "USD:0", + pendingIncoming: "USD:5" as AmountString, + pendingOutgoing: "USD:0" as AmountString, requiresUserInput: false, scopeInfo: { currency: "TESTKUDOS", diff --git a/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/stories.tsx b/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/stories.tsx index 736de11f4..7ac92c6c9 100644 --- a/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/stories.tsx @@ -21,6 +21,7 @@ import * as tests from "@gnu-taler/web-util/testing"; import { ConfirmProviderView, SelectProviderView } from "./views.js"; +import { AmountString } from "@gnu-taler/taler-util"; export default { title: "add backup provider", @@ -29,7 +30,7 @@ export default { export const DemoService = tests.createExample(ConfirmProviderView, { url: "https://sync.demo.taler.net/", provider: { - annual_fee: "KUDOS:0.1", + annual_fee: "KUDOS:0.1" as AmountString, storage_limit_in_megabytes: 20, version: "1", }, @@ -43,7 +44,7 @@ export const DemoService = tests.createExample(ConfirmProviderView, { export const FreeService = tests.createExample(ConfirmProviderView, { url: "https://sync.taler:9667/", provider: { - annual_fee: "ARS:0", + annual_fee: "ARS:0" as AmountString, storage_limit_in_megabytes: 20, version: "1", }, diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx index 18291a25a..4c4ba1855 100644 --- a/packages/taler-wallet-webextension/src/wallet/Application.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx @@ -21,6 +21,7 @@ */ import { + Amounts, TalerUri, TranslatedString, stringifyTalerUri, @@ -426,7 +427,7 @@ export function Application(): VNode { }) => ( <CallToActionTemplate title={i18n.str`Digital cash deposit`}> <DepositPageCTA - amountStr={amount} + amountStr={Amounts.stringify(Amounts.parseOrThrow(amount))} talerDepositUri={decodeURIComponent(talerUri)} cancel={() => redirectTo(Pages.balance)} onSuccess={(tid: string) => @@ -441,7 +442,7 @@ export function Application(): VNode { component={({ amount }: { amount: string }) => ( <CallToActionTemplate title={i18n.str`Digital cash invoice`}> <InvoiceCreatePage - amount={amount} + amount={Amounts.stringify(Amounts.parseOrThrow(amount))} onClose={() => redirectTo(Pages.balance)} onSuccess={(tid: string) => redirectTo(Pages.balanceTransaction({ tid })) @@ -455,7 +456,7 @@ export function Application(): VNode { component={({ amount }: { amount: string }) => ( <CallToActionTemplate title={i18n.str`Digital cash transfer`}> <TransferCreatePage - amount={amount} + amount={Amounts.stringify(Amounts.parseOrThrow(amount))} onClose={() => redirectTo(Pages.balance)} onSuccess={(tid: string) => redirectTo(Pages.balanceTransaction({ tid })) diff --git a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx index 59bcd5ce9..ae160a30c 100644 --- a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx @@ -28,6 +28,7 @@ import { import * as tests from "@gnu-taler/web-util/testing"; import { AbsoluteTime, + AmountString, TalerPreciseTimestamp, TalerProtocolTimestamp, } from "@gnu-taler/taler-util"; @@ -52,7 +53,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { paidUntil: AbsoluteTime.fromMilliseconds(1656599921000), }, terms: { - annualFee: "ARS:1", + annualFee: "ARS:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -73,7 +74,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { ), }, terms: { - annualFee: "ARS:1", + annualFee: "ARS:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -88,7 +89,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { talerUri: "taler://", }, terms: { - annualFee: "KUDOS:0.1", + annualFee: "KUDOS:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -100,10 +101,10 @@ export const LotOfProviders = tests.createExample(TestedComponent, { paymentProposalIds: [], paymentStatus: { type: ProviderPaymentType.InsufficientBalance, - amount: "KUDOS:10", + amount: "KUDOS:10" as AmountString, }, terms: { - annualFee: "KUDOS:0.1", + annualFee: "KUDOS:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -116,19 +117,19 @@ export const LotOfProviders = tests.createExample(TestedComponent, { paymentStatus: { type: ProviderPaymentType.TermsChanged, newTerms: { - annualFee: "USD:2", + annualFee: "USD:2" as AmountString, storageLimitInMegabytes: 8, supportedProtocolVersion: "2", }, oldTerms: { - annualFee: "USD:1", + annualFee: "USD:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "1", }, paidUntil: AbsoluteTime.never(), }, terms: { - annualFee: "KUDOS:0.1", + annualFee: "KUDOS:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -142,7 +143,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { type: ProviderPaymentType.Unpaid, }, terms: { - annualFee: "KUDOS:0.1", + annualFee: "KUDOS:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -156,7 +157,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { type: ProviderPaymentType.Unpaid, }, terms: { - annualFee: "KUDOS:0.1", + annualFee: "KUDOS:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -180,7 +181,7 @@ export const OneProvider = tests.createExample(TestedComponent, { paidUntil: AbsoluteTime.fromMilliseconds(1656599921000), }, terms: { - annualFee: "ARS:1", + annualFee: "ARS:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts index 4d09d2549..5384fe4c5 100644 --- a/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts +++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts @@ -21,6 +21,7 @@ import { Amounts, + AmountString, DepositGroupFees, parsePaytoUri, PrepareDepositResponse, @@ -38,8 +39,8 @@ import { useComponentState } from "./state.js"; const currency = "EUR"; const amount = `${currency}:0`; const withoutFee = (): PrepareDepositResponse => ({ - effectiveDepositAmount: `${currency}:5`, - totalDepositCost: `${currency}:5`, + effectiveDepositAmount: `${currency}:5` as AmountString, + totalDepositCost: `${currency}:5` as AmountString, fees: { coin: Amounts.stringify(`${currency}:0`), wire: Amounts.stringify(`${currency}:0`), @@ -48,8 +49,8 @@ const withoutFee = (): PrepareDepositResponse => ({ }); const withSomeFee = (): PrepareDepositResponse => ({ - effectiveDepositAmount: `${currency}:5`, - totalDepositCost: `${currency}:5`, + effectiveDepositAmount: `${currency}:5` as AmountString, + totalDepositCost: `${currency}:5` as AmountString, fees: { coin: Amounts.stringify(`${currency}:1`), wire: Amounts.stringify(`${currency}:1`), @@ -65,10 +66,10 @@ describe("DepositPage states", () => { handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, { balances: [ { - available: `${currency}:0`, + available: `${currency}:0` as AmountString, hasPendingTransactions: false, - pendingIncoming: `${currency}:0`, - pendingOutgoing: `${currency}:0`, + pendingIncoming: `${currency}:0` as AmountString, + pendingOutgoing: `${currency}:0` as AmountString, requiresUserInput: false, scopeInfo: { currency, @@ -111,10 +112,10 @@ describe("DepositPage states", () => { handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, { balances: [ { - available: `${currency}:1`, + available: `${currency}:1` as AmountString, hasPendingTransactions: false, - pendingIncoming: `${currency}:0`, - pendingOutgoing: `${currency}:0`, + pendingIncoming: `${currency}:0` as AmountString, + pendingOutgoing: `${currency}:0` as AmountString, requiresUserInput: false, scopeInfo: { currency, @@ -170,10 +171,10 @@ describe("DepositPage states", () => { handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, { balances: [ { - available: `${currency}:1`, + available: `${currency}:1` as AmountString, hasPendingTransactions: false, - pendingIncoming: `${currency}:0`, - pendingOutgoing: `${currency}:0`, + pendingIncoming: `${currency}:0` as AmountString, + pendingOutgoing: `${currency}:0` as AmountString, requiresUserInput: false, scopeInfo: { currency, @@ -229,10 +230,10 @@ describe("DepositPage states", () => { handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, { balances: [ { - available: `${currency}:5`, + available: `${currency}:5` as AmountString, hasPendingTransactions: false, - pendingIncoming: `${currency}:0`, - pendingOutgoing: `${currency}:0`, + pendingIncoming: `${currency}:0` as AmountString, + pendingOutgoing: `${currency}:0` as AmountString, requiresUserInput: false, scopeInfo: { currency, @@ -318,10 +319,10 @@ describe("DepositPage states", () => { handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, { balances: [ { - available: `${currency}:10`, + available: `${currency}:10` as AmountString, hasPendingTransactions: false, - pendingIncoming: `${currency}:0`, - pendingOutgoing: `${currency}:0`, + pendingIncoming: `${currency}:0` as AmountString, + pendingOutgoing: `${currency}:0` as AmountString, requiresUserInput: false, scopeInfo: { currency, diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx index 1ddb24b02..9bf39b8ae 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx @@ -20,6 +20,7 @@ */ import { + AmountString, PaymentStatus, RefreshReason, ScopeType, @@ -49,17 +50,17 @@ export default { let count = 0; const commonTransaction = (): TransactionCommon => - ({ - amountRaw: "USD:10", - amountEffective: "USD:9", - txState: { - major: TransactionMajorState.Done, - }, - timestamp: TalerProtocolTimestamp.fromSeconds( - new Date().getTime() / 1000 - count++ * 60 * 60 * 7, - ), - transactionId: String(count), - } as TransactionCommon); +({ + amountRaw: "USD:10", + amountEffective: "USD:9", + txState: { + major: TransactionMajorState.Done, + }, + timestamp: TalerProtocolTimestamp.fromSeconds( + new Date().getTime() / 1000 - count++ * 60 * 60 * 7, + ), + transactionId: String(count), +} as TransactionCommon); const exampleData = { withdraw: { @@ -76,7 +77,7 @@ const exampleData = { } as TransactionWithdrawal, payment: { ...commonTransaction(), - amountEffective: "USD:11", + amountEffective: "USD:11" as AmountString, type: TransactionType.Payment, posConfirmation: undefined, info: { @@ -91,8 +92,8 @@ const exampleData = { }, refunds: [], refundPending: undefined, - totalRefundEffective: "USD:0", - totalRefundRaw: "USD:0", + totalRefundEffective: "USD:0" as AmountString, + totalRefundRaw: "USD:0" as AmountString, proposalId: "1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0", status: PaymentStatus.Accepted, refundQueryActive: false, @@ -106,8 +107,8 @@ const exampleData = { refresh: { ...commonTransaction(), type: TransactionType.Refresh, - refreshInputAmount: "USD:1", - refreshOutputAmount: "USD:0.5", + refreshInputAmount: "USD:1" as AmountString, + refreshOutputAmount: "USD:0.5" as AmountString, exchangeBaseUrl: "http://exchange.taler", refreshReason: RefreshReason.PayMerchant, } as TransactionRefresh, @@ -178,9 +179,9 @@ export const SomeBalanceWithNoTransactions = tests.createExample( transactions: [], balances: [ { - available: "TESTKUDOS:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "TESTKUDOS:10" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -197,9 +198,9 @@ export const OneSimpleTransaction = tests.createExample(TestedComponent, { transactions: [exampleData.withdraw], balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -217,9 +218,9 @@ export const TwoTransactionsAndZeroBalance = tests.createExample( transactions: [exampleData.withdraw, exampleData.deposit], balances: [ { - available: "USD:0", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:0" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -243,9 +244,9 @@ export const OneTransactionPending = tests.createExample(TestedComponent, { ], balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -277,9 +278,9 @@ export const SomeTransactions = tests.createExample(TestedComponent, { ], balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -370,9 +371,9 @@ export const SomeTransactionsInDifferentStates = tests.createExample( ], balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -400,9 +401,9 @@ export const SomeTransactionsWithTwoCurrencies = tests.createExample( ], balances: [ { - available: "USD:0", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:0" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -412,9 +413,9 @@ export const SomeTransactionsWithTwoCurrencies = tests.createExample( }, }, { - available: "TESTKUDOS:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "TESTKUDOS:10" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -431,9 +432,9 @@ export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { transactions: [exampleData.withdraw], balances: [ { - available: "USD:1000", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:1000" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -443,9 +444,9 @@ export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "EUR:881", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "EUR:881" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -455,9 +456,9 @@ export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "COL:4043000.5", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "COL:4043000.5" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -467,9 +468,9 @@ export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "JPY:11564450.6", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "JPY:11564450.6" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -479,9 +480,9 @@ export const FiveOfficialCurrencies = tests.createExample(TestedComponent, { }, }, { - available: "GBP:736", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "GBP:736" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -499,9 +500,9 @@ export const FiveOfficialCurrenciesWithHighValue = tests.createExample( transactions: [exampleData.withdraw], balances: [ { - available: "USD:881001321230000", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:881001321230000" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -511,9 +512,9 @@ export const FiveOfficialCurrenciesWithHighValue = tests.createExample( }, }, { - available: "EUR:10", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "EUR:10" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -523,9 +524,9 @@ export const FiveOfficialCurrenciesWithHighValue = tests.createExample( }, }, { - available: "COL:443000123123000.5123123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "COL:443000123123000.5123123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, scopeInfo: { currency: "Ásd", @@ -535,9 +536,9 @@ export const FiveOfficialCurrenciesWithHighValue = tests.createExample( requiresUserInput: false, }, { - available: "JPY:1564450000000.6123123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "JPY:1564450000000.6123123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -547,9 +548,9 @@ export const FiveOfficialCurrenciesWithHighValue = tests.createExample( }, }, { - available: "GBP:736001231231200.23123", - pendingIncoming: "TESTKUDOS:0", - pendingOutgoing: "TESTKUDOS:0", + available: "GBP:736001231231200.23123" as AmountString, + pendingIncoming: "TESTKUDOS:0" as AmountString, + pendingOutgoing: "TESTKUDOS:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { @@ -571,9 +572,9 @@ export const PeerToPeer = tests.createExample(TestedComponent, { ], balances: [ { - available: "USD:10", - pendingIncoming: "USD:0", - pendingOutgoing: "USD:0", + available: "USD:10" as AmountString, + pendingIncoming: "USD:0" as AmountString, + pendingOutgoing: "USD:0" as AmountString, hasPendingTransactions: false, requiresUserInput: false, scopeInfo: { diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx index fbaa0b0ea..f81a86b9d 100644 --- a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx @@ -21,6 +21,7 @@ import { AbsoluteTime, + AmountString, TalerPreciseTimestamp, TalerProtocolTimestamp, } from "@gnu-taler/taler-util"; @@ -53,7 +54,7 @@ export const Active = tests.createExample(TestedComponent, { paidUntil: AbsoluteTime.fromMilliseconds(1656599921000), }, terms: { - annualFee: "EUR:1", + annualFee: "EUR:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -84,7 +85,7 @@ export const ActiveErrorSync = tests.createExample(TestedComponent, { message: "message", }, terms: { - annualFee: "EUR:1", + annualFee: "EUR:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -111,7 +112,7 @@ export const ActiveBackupProblemUnreadable = tests.createExample( type: "backup-unreadable", }, terms: { - annualFee: "EUR:1", + annualFee: "EUR:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -140,7 +141,7 @@ export const ActiveBackupProblemDevice = tests.createExample(TestedComponent, { backupTimestamp: AbsoluteTime.fromMilliseconds(1656599921000), }, terms: { - annualFee: "EUR:1", + annualFee: "EUR:1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -157,7 +158,7 @@ export const InactiveUnpaid = tests.createExample(TestedComponent, { type: ProviderPaymentType.Unpaid, }, terms: { - annualFee: "EUR:0.1", + annualFee: "EUR:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -174,10 +175,10 @@ export const InactiveInsufficientBalance = tests.createExample( paymentProposalIds: [], paymentStatus: { type: ProviderPaymentType.InsufficientBalance, - amount: "EUR:123", + amount: "EUR:123" as AmountString, }, terms: { - annualFee: "EUR:0.1", + annualFee: "EUR:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -196,7 +197,7 @@ export const InactivePending = tests.createExample(TestedComponent, { talerUri: "taler://pay/sad", }, terms: { - annualFee: "EUR:0.1", + annualFee: "EUR:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, @@ -213,18 +214,18 @@ export const ActiveTermsChanged = tests.createExample(TestedComponent, { type: ProviderPaymentType.TermsChanged, paidUntil: AbsoluteTime.fromMilliseconds(1656599921000), newTerms: { - annualFee: "EUR:10", + annualFee: "EUR:10" as AmountString, storageLimitInMegabytes: 8, supportedProtocolVersion: "0.0", }, oldTerms: { - annualFee: "EUR:0.1", + annualFee: "EUR:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, }, terms: { - annualFee: "EUR:0.1", + annualFee: "EUR:0.1" as AmountString, storageLimitInMegabytes: 16, supportedProtocolVersion: "0.0", }, diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx index f1ae84ed3..09f7c4dc1 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx @@ -21,6 +21,7 @@ import { AbsoluteTime, + AmountString, PaymentStatus, RefreshReason, TalerPreciseTimestamp, @@ -60,8 +61,8 @@ export default { const commonTransaction: TransactionCommon = { error: undefined, - amountRaw: "KUDOS:11", - amountEffective: "KUDOS:9.2", + amountRaw: "KUDOS:11" as AmountString, + amountEffective: "KUDOS:9.2" as AmountString, txState: { major: TransactionMajorState.Done, }, @@ -91,7 +92,7 @@ const exampleData = { } as TransactionWithdrawal, payment: { ...commonTransaction, - amountEffective: "KUDOS:12", + amountEffective: "KUDOS:12" as AmountString, type: TransactionType.Payment, posConfirmation: undefined, info: { @@ -113,8 +114,8 @@ const exampleData = { }, refunds: [], refundPending: undefined, - totalRefundEffective: "KUDOS:0", - totalRefundRaw: "KUDOS:0", + totalRefundEffective: "KUDOS:0" as AmountString, + totalRefundRaw: "KUDOS:0" as AmountString, proposalId: "1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0", status: PaymentStatus.Accepted, refundQueryActive: false, @@ -131,8 +132,8 @@ const exampleData = { refresh: { ...commonTransaction, type: TransactionType.Refresh, - refreshInputAmount: "KUDOS:1", - refreshOutputAmount: "KUDOS:0.5", + refreshInputAmount: "KUDOS:1" as AmountString, + refreshOutputAmount: "KUDOS:0.5" as AmountString, exchangeBaseUrl: "http://exchange.taler", refreshReason: RefreshReason.Manual, } as TransactionRefresh, @@ -358,14 +359,14 @@ export const PaymentError = tests.createExample(TestedComponent, { export const PaymentWithRefund = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", - totalRefundEffective: "KUDOS:1", - totalRefundRaw: "KUDOS:1", + amountRaw: "KUDOS:12" as AmountString, + totalRefundEffective: "KUDOS:1" as AmountString, + totalRefundRaw: "KUDOS:1" as AmountString, refunds: [ { transactionId: "1123123", - amountRaw: "KUDOS:1", - amountEffective: "KUDOS:1", + amountRaw: "KUDOS:1" as AmountString, + amountEffective: "KUDOS:1" as AmountString, timestamp: TalerProtocolTimestamp.fromSeconds(1546546544), }, ], @@ -375,7 +376,7 @@ export const PaymentWithRefund = tests.createExample(TestedComponent, { export const PaymentWithDeliveryDate = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", + amountRaw: "KUDOS:12" as AmountString, info: { ...exampleData.payment.info, // delivery_date: { @@ -388,7 +389,7 @@ export const PaymentWithDeliveryDate = tests.createExample(TestedComponent, { export const PaymentWithDeliveryAddr = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", + amountRaw: "KUDOS:12" as AmountString, info: { ...exampleData.payment.info, // delivery_location: { @@ -404,7 +405,7 @@ export const PaymentWithDeliveryAddr = tests.createExample(TestedComponent, { export const PaymentWithDeliveryFull = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", + amountRaw: "KUDOS:12" as AmountString, info: { ...exampleData.payment.info, // delivery_date: { @@ -423,35 +424,35 @@ export const PaymentWithDeliveryFull = tests.createExample(TestedComponent, { export const PaymentWithRefundPending = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", - refundPending: "KUDOS:3", - totalRefundEffective: "KUDOS:1", - totalRefundRaw: "KUDOS:1", + amountRaw: "KUDOS:12" as AmountString, + refundPending: "KUDOS:3" as AmountString, + totalRefundEffective: "KUDOS:1" as AmountString, + totalRefundRaw: "KUDOS:1" as AmountString, }, }); export const PaymentWithFeeAndRefund = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:11", - totalRefundEffective: "KUDOS:1", - totalRefundRaw: "KUDOS:1", + amountRaw: "KUDOS:11" as AmountString, + totalRefundEffective: "KUDOS:1" as AmountString, + totalRefundRaw: "KUDOS:1" as AmountString, }, }); export const PaymentWithFeeAndRefundFee = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:11", - totalRefundEffective: "KUDOS:1", - totalRefundRaw: "KUDOS:2", + amountRaw: "KUDOS:11" as AmountString, + totalRefundEffective: "KUDOS:1" as AmountString, + totalRefundRaw: "KUDOS:2" as AmountString, }, }); export const PaymentWithoutFee = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - amountRaw: "KUDOS:12", + amountRaw: "KUDOS:12" as AmountString, }, }); @@ -537,8 +538,8 @@ export const DepositTalerBank = tests.createExample(TestedComponent, { export const DepositBitcoin = tests.createExample(TestedComponent, { transaction: { ...exampleData.deposit, - amountRaw: "BITCOINBTC:0.0000011", - amountEffective: "BITCOINBTC:0.00000092", + amountRaw: "BITCOINBTC:0.0000011" as AmountString, + amountEffective: "BITCOINBTC:0.00000092" as AmountString, targetPaytoUri: "payto://bitcoin/bcrt1q6ps8qs6v8tkqrnru4xqqqa6rfwcx5ufpdfqht4?amount=BTC:0.1&subject=0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00", }, diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 3b76558ce..422695367 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -18,6 +18,7 @@ import { AbsoluteTime, AmountJson, Amounts, + AmountString, Location, MerchantInfo, NotificationType, @@ -1655,7 +1656,7 @@ function RefundDetails({ amount }: { amount: AmountWithFee }): VNode { type AmountAmountByWireTransferByWire = { id: string; - amount: string; + amount: AmountString; }[]; function calculateAmountByWireTransfer( |