diff options
author | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
commit | cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854 (patch) | |
tree | 423ed7c6fc42ec5e05f655eb093b3b4bdc885996 /packages/taler-wallet-webextension | |
parent | 557dcec30db6573c5d11ca26432008ac6621642e (diff) |
taler-util,wallet-core: implement TalerPreciseTimestamp
Fixes #7703
Diffstat (limited to 'packages/taler-wallet-webextension')
12 files changed, 41 insertions, 39 deletions
diff --git a/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx b/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx index 3866fc991..9c11170cd 100644 --- a/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx +++ b/packages/taler-wallet-webextension/src/components/PendingTransactions.tsx @@ -136,7 +136,7 @@ export function PendingTransactionsView({ </Typography> - <Time - timestamp={AbsoluteTime.fromTimestamp(t.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(t.timestamp)} format="dd MMMM yyyy" /> </Grid> diff --git a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx index 9cbc2899f..392a7d0e8 100644 --- a/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx +++ b/packages/taler-wallet-webextension/src/components/ShowFullContractTermPopup.tsx @@ -179,7 +179,7 @@ export function HiddenView({ showHandler }: States.Hidden): VNode { } export function ShowView({ contractTerms, hideHandler }: States.Show): VNode { - const createdAt = AbsoluteTime.fromTimestamp(contractTerms.timestamp); + const createdAt = AbsoluteTime.fromProtocolTimestamp(contractTerms.timestamp); const { i18n } = useTranslationContext(); return ( @@ -266,7 +266,7 @@ export function ShowView({ contractTerms, hideHandler }: States.Show): VNode { <td> {contractTerms.deliveryDate && ( <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( contractTerms.deliveryDate, )} format="dd MMMM yyyy, HH:mm" @@ -299,7 +299,7 @@ export function ShowView({ contractTerms, hideHandler }: States.Show): VNode { <td> {contractTerms.timestamp && ( <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( contractTerms.timestamp, )} format="dd MMMM yyyy, HH:mm" @@ -314,7 +314,7 @@ export function ShowView({ contractTerms, hideHandler }: States.Show): VNode { <td> { <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( contractTerms.refundDeadline, )} format="dd MMMM yyyy, HH:mm" @@ -349,7 +349,7 @@ export function ShowView({ contractTerms, hideHandler }: States.Show): VNode { <td> { <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( contractTerms.payDeadline, )} format="dd MMMM yyyy, HH:mm" diff --git a/packages/taler-wallet-webextension/src/components/TransactionItem.tsx b/packages/taler-wallet-webextension/src/components/TransactionItem.tsx index 124729349..15669e63d 100644 --- a/packages/taler-wallet-webextension/src/components/TransactionItem.tsx +++ b/packages/taler-wallet-webextension/src/components/TransactionItem.tsx @@ -53,7 +53,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={new URL(tx.exchangeBaseUrl).hostname} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"W"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -76,7 +76,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={new URL(tx.exchangeBaseUrl).hostname} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"I"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -100,7 +100,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { debitCreditIndicator={"debit"} title={tx.info.merchant.name} subtitle={tx.info.summary} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"P"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -121,7 +121,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { ? tx.paymentInfo.merchant.name : "--unknown merchant--" } //FIXME: DD37 wallet-core is not returning this value - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"R"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -137,7 +137,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={new URL(tx.merchantBaseUrl).hostname} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"T"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -153,7 +153,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={"Refresh"} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"R"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -169,7 +169,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"debit"} title={tx.targetPaytoUri} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"D"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -185,7 +185,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={tx.info.summary || "Invoice"} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"I"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -201,7 +201,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"debit"} title={tx.info.summary || "Invoice"} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"I"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -217,7 +217,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"credit"} title={tx.info.summary || "Transfer"} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"T"} pending={ tx.txState.major === TransactionMajorState.Pending @@ -233,7 +233,7 @@ export function TransactionItem(props: { tx: Transaction }): VNode { amount={tx.amountEffective} debitCreditIndicator={"debit"} title={tx.info.summary || "Transfer"} - timestamp={AbsoluteTime.fromTimestamp(tx.timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(tx.timestamp)} iconPath={"T"} pending={ tx.txState.major === TransactionMajorState.Pending diff --git a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts index 690474a86..10f1ee849 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts +++ b/packages/taler-wallet-webextension/src/cta/InvoicePay/state.ts @@ -123,7 +123,7 @@ export function useComponentState({ raw, goToWalletManualWithdraw, summary, - expiration: expiration ? AbsoluteTime.fromTimestamp(expiration) : undefined, + expiration: expiration ? AbsoluteTime.fromProtocolTimestamp(expiration) : undefined, }; if (!foundBalance) { diff --git a/packages/taler-wallet-webextension/src/cta/Payment/views.tsx b/packages/taler-wallet-webextension/src/cta/Payment/views.tsx index ea3d93f3f..764036dad 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/Payment/views.tsx @@ -93,7 +93,7 @@ export function BaseView(state: SupportedStates): VNode { title={i18n.str`Valid until`} text={ <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( contractTerms.pay_deadline, )} format="dd MMMM yyyy, HH:mm" diff --git a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts index 9b309ce2f..7711498e1 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts @@ -86,7 +86,7 @@ export function useComponentState({ onClick: pushAlertOnError(accept), }, summary, - expiration: expiration ? AbsoluteTime.fromTimestamp(expiration) : undefined, + expiration: expiration ? AbsoluteTime.fromProtocolTimestamp(expiration) : undefined, cancel: { onClick: pushAlertOnError(onClose), }, diff --git a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx index b927ffbae..ddcba6fae 100644 --- a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx @@ -26,7 +26,7 @@ import { ShowRecoveryInfo, } from "./BackupPage.js"; import * as tests from "@gnu-taler/web-util/testing"; -import { TalerProtocolTimestamp } from "@gnu-taler/taler-util"; +import { TalerPreciseTimestamp, TalerProtocolTimestamp } from "@gnu-taler/taler-util"; export default { title: "backup", @@ -39,7 +39,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], @@ -60,7 +60,7 @@ export const LotOfProviders = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], @@ -171,7 +171,7 @@ export const OneProvider = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], diff --git a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx index 8acfe3ecf..5ae52db6f 100644 --- a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx @@ -199,7 +199,7 @@ export function BackupView({ status={provider.paymentStatus} timestamp={ provider.lastSuccessfulBackupTimestamp - ? AbsoluteTime.fromTimestamp( + ? AbsoluteTime.fromPreciseTimestamp( provider.lastSuccessfulBackupTimestamp, ) : undefined diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx index 682f03f39..9c03d18f6 100644 --- a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { AbsoluteTime, TalerProtocolTimestamp } from "@gnu-taler/taler-util"; +import { AbsoluteTime, TalerPreciseTimestamp, TalerProtocolTimestamp } from "@gnu-taler/taler-util"; import { ProviderPaymentType } from "@gnu-taler/taler-wallet-core"; import * as tests from "@gnu-taler/web-util/testing"; import { ProviderView as TestedComponent } from "./ProviderDetailPage.js"; @@ -40,7 +40,7 @@ export const Active = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], @@ -64,9 +64,9 @@ export const ActiveErrorSync = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), lastAttemptedBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925078), + TalerPreciseTimestamp.fromSeconds(1625063925078), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], @@ -99,7 +99,7 @@ export const ActiveBackupProblemUnreadable = tests.createExample( name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925), + TalerPreciseTimestamp.fromSeconds(1625063925), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], @@ -127,7 +127,7 @@ export const ActiveBackupProblemDevice = tests.createExample(TestedComponent, { name: "sync.demo", syncProviderBaseUrl: "http://sync.taler:9967/", lastSuccessfulBackupTimestamp: - TalerProtocolTimestamp.fromSeconds(1625063925078), + TalerPreciseTimestamp.fromSeconds(1625063925078), paymentProposalIds: [ "43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG", ], diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx index bf7bc0669..19ae39106 100644 --- a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx @@ -151,7 +151,7 @@ export function ProviderView({ }: ViewProps): VNode { const { i18n } = useTranslationContext(); const lb = info.lastSuccessfulBackupTimestamp - ? AbsoluteTime.fromTimestamp(info.lastSuccessfulBackupTimestamp) + ? AbsoluteTime.fromPreciseTimestamp(info.lastSuccessfulBackupTimestamp) : undefined; const isPaid = info.paymentStatus.type === ProviderPaymentType.Paid || diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx index b2a8de014..c2bceb067 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx @@ -23,6 +23,7 @@ import { AbsoluteTime, PaymentStatus, RefreshReason, + TalerPreciseTimestamp, TalerProtocolTimestamp, TransactionCommon, TransactionDeposit, @@ -245,7 +246,7 @@ export const WithdrawFiveMinutesAgo = tests.createExample( () => ({ transaction: { ...exampleData.withdraw, - timestamp: TalerProtocolTimestamp.fromSeconds( + timestamp: TalerPreciseTimestamp.fromSeconds( new Date().getTime() / 1000 - 60 * 5, ), }, @@ -257,7 +258,7 @@ export const WithdrawFiveMinutesAgoAndPending = tests.createExample( () => ({ transaction: { ...exampleData.withdraw, - timestamp: TalerProtocolTimestamp.fromSeconds( + timestamp: TalerPreciseTimestamp.fromSeconds( new Date().getTime() / 1000 - 60 * 5, ), txState: { diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 9541cc33f..39175186f 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -25,6 +25,7 @@ import { parsePaytoUri, PaytoUri, stringifyPaytoUri, + TalerPreciseTimestamp, TalerProtocolTimestamp, Transaction, TransactionDeposit, @@ -585,7 +586,7 @@ export function TransactionView({ on{" "} { <Time - timestamp={AbsoluteTime.fromTimestamp( + timestamp={AbsoluteTime.fromProtocolTimestamp( r.timestamp, )} format="dd MMMM yyyy" @@ -671,7 +672,7 @@ export function TransactionView({ if (transaction.type === TransactionType.Deposit) { const payto = parsePaytoUri(transaction.targetPaytoUri); - const wireTime = AbsoluteTime.fromTimestamp( + const wireTime = AbsoluteTime.fromProtocolTimestamp( transaction.wireTransferDeadline, ); const shouldBeWired = wireTime.t_ms !== "never" && isPast(wireTime.t_ms); @@ -1204,7 +1205,7 @@ function DeliveryDetails({ </td> <td> <Time - timestamp={AbsoluteTime.fromTimestamp(date)} + timestamp={AbsoluteTime.fromProtocolTimestamp(date)} format="dd MMMM yyyy, HH:mm" /> </td> @@ -1768,7 +1769,7 @@ function Header({ kind, type, }: { - timestamp: TalerProtocolTimestamp; + timestamp: TalerPreciseTimestamp; total: AmountJson; children: ComponentChildren; kind: Kind; @@ -1785,7 +1786,7 @@ function Header({ <div> <SubTitle>{children}</SubTitle> <Time - timestamp={AbsoluteTime.fromTimestamp(timestamp)} + timestamp={AbsoluteTime.fromPreciseTimestamp(timestamp)} format="dd MMMM yyyy, HH:mm" /> </div> |