fixing txId reference based on nominal type
This commit is contained in:
parent
708cf016e4
commit
9181c1e81b
@ -80,28 +80,3 @@ function setValueDeeper(object: any, names: string[], value: any): any {
|
|||||||
}
|
}
|
||||||
return { ...object, [head]: setValueDeeper(object[head] ?? {}, rest, value) };
|
return { ...object, [head]: setValueDeeper(object[head] ?? {}, rest, value) };
|
||||||
}
|
}
|
||||||
|
|
||||||
type TTT<T extends object, K extends keyof T, R> = K extends keyof T
|
|
||||||
? R extends T[K]
|
|
||||||
? number
|
|
||||||
: never
|
|
||||||
: never;
|
|
||||||
|
|
||||||
function impl<T extends object, K extends keyof T, R extends T[K]>(
|
|
||||||
obj: T,
|
|
||||||
name: K,
|
|
||||||
): T[K] {
|
|
||||||
return obj[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Pepe {
|
|
||||||
name: string;
|
|
||||||
when: Date;
|
|
||||||
size: number;
|
|
||||||
}
|
|
||||||
const p: Pepe = {
|
|
||||||
name: "n",
|
|
||||||
when: new Date(),
|
|
||||||
size: 1,
|
|
||||||
};
|
|
||||||
const a = impl(p, "size");
|
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
Amounts,
|
Amounts,
|
||||||
MerchantContractTerms as ContractTerms,
|
MerchantContractTerms as ContractTerms,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
|
TransactionIdStr,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import * as tests from "@gnu-taler/web-util/testing";
|
import * as tests from "@gnu-taler/web-util/testing";
|
||||||
import beer from "../../../static-dev/beer.png";
|
import beer from "../../../static-dev/beer.png";
|
||||||
@ -48,7 +49,7 @@ export const NoEnoughBalanceAvailable = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -88,7 +89,7 @@ export const NoEnoughBalanceMaterial = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -128,7 +129,7 @@ export const NoEnoughBalanceAgeAcceptable = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -169,7 +170,7 @@ export const NoEnoughBalanceMerchantAcceptable = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -211,7 +212,7 @@ export const NoEnoughBalanceMerchantDepositable = tests.createExample(
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -252,7 +253,7 @@ export const NoEnoughBalanceFeeGap = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "",
|
uri: "",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.InsufficientBalance,
|
status: PreparePayResultType.InsufficientBalance,
|
||||||
balanceDetails: {
|
balanceDetails: {
|
||||||
amountRequested: "USD:10",
|
amountRequested: "USD:10",
|
||||||
@ -296,7 +297,7 @@ export const PaymentPossible = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.PaymentPossible,
|
status: PreparePayResultType.PaymentPossible,
|
||||||
talerUri: "taler://pay/..",
|
talerUri: "taler://pay/..",
|
||||||
amountEffective: "USD:10",
|
amountEffective: "USD:10",
|
||||||
@ -336,7 +337,7 @@ export const PaymentPossibleWithFee = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.PaymentPossible,
|
status: PreparePayResultType.PaymentPossible,
|
||||||
talerUri: "taler://pay/..",
|
talerUri: "taler://pay/..",
|
||||||
amountEffective: "USD:10.20",
|
amountEffective: "USD:10.20",
|
||||||
@ -373,7 +374,7 @@ export const TicketWithAProductList = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.PaymentPossible,
|
status: PreparePayResultType.PaymentPossible,
|
||||||
talerUri: "taler://pay/..",
|
talerUri: "taler://pay/..",
|
||||||
amountEffective: "USD:10.20",
|
amountEffective: "USD:10.20",
|
||||||
@ -429,7 +430,7 @@ export const TicketWithShipping = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.PaymentPossible,
|
status: PreparePayResultType.PaymentPossible,
|
||||||
talerUri: "taler://pay/..",
|
talerUri: "taler://pay/..",
|
||||||
amountEffective: "USD:10.20",
|
amountEffective: "USD:10.20",
|
||||||
@ -477,7 +478,7 @@ export const AlreadyConfirmedByOther = tests.createExample(BaseView, {
|
|||||||
|
|
||||||
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0",
|
||||||
payStatus: {
|
payStatus: {
|
||||||
transactionId: " ",
|
transactionId: " " as TransactionIdStr,
|
||||||
status: PreparePayResultType.AlreadyConfirmed,
|
status: PreparePayResultType.AlreadyConfirmed,
|
||||||
talerUri: "taler://pay/..",
|
talerUri: "taler://pay/..",
|
||||||
amountEffective: "USD:10",
|
amountEffective: "USD:10",
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { PendingTaskType } from "@gnu-taler/taler-wallet-core";
|
import { PendingTaskType, TaskId } from "@gnu-taler/taler-wallet-core";
|
||||||
import * as tests from "@gnu-taler/web-util/testing";
|
import * as tests from "@gnu-taler/web-util/testing";
|
||||||
import { View as TestedComponent } from "./DeveloperPage.js";
|
import { View as TestedComponent } from "./DeveloperPage.js";
|
||||||
|
import { PendingIdStr } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: "developer",
|
title: "developer",
|
||||||
@ -35,7 +36,7 @@ export const AllOff = tests.createExample(TestedComponent, {
|
|||||||
onDownloadDatabase: async () => "this is the content of the database",
|
onDownloadDatabase: async () => "this is the content of the database",
|
||||||
operations: [
|
operations: [
|
||||||
{
|
{
|
||||||
id: "",
|
id: " " as TaskId,
|
||||||
type: PendingTaskType.ExchangeUpdate,
|
type: PendingTaskType.ExchangeUpdate,
|
||||||
exchangeBaseUrl: "http://exchange.url.",
|
exchangeBaseUrl: "http://exchange.url.",
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
|
@ -19,7 +19,11 @@
|
|||||||
* @author Sebastian Javier Marchano (sebasjm)
|
* @author Sebastian Javier Marchano (sebasjm)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AbsoluteTime, AttentionType } from "@gnu-taler/taler-util";
|
import {
|
||||||
|
AbsoluteTime,
|
||||||
|
AttentionType,
|
||||||
|
TransactionIdStr,
|
||||||
|
} from "@gnu-taler/taler-util";
|
||||||
import * as tests from "@gnu-taler/web-util/testing";
|
import * as tests from "@gnu-taler/web-util/testing";
|
||||||
import { ReadyView } from "./views.js";
|
import { ReadyView } from "./views.js";
|
||||||
|
|
||||||
@ -34,7 +38,7 @@ export const Ready = tests.createExample(ReadyView, {
|
|||||||
read: false,
|
read: false,
|
||||||
info: {
|
info: {
|
||||||
type: AttentionType.KycWithdrawal,
|
type: AttentionType.KycWithdrawal,
|
||||||
transactionId: "123",
|
transactionId: "123" as TransactionIdStr,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -42,7 +46,7 @@ export const Ready = tests.createExample(ReadyView, {
|
|||||||
read: false,
|
read: false,
|
||||||
info: {
|
info: {
|
||||||
type: AttentionType.MerchantRefund,
|
type: AttentionType.MerchantRefund,
|
||||||
transactionId: "123",
|
transactionId: "123" as TransactionIdStr,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@ import {
|
|||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
TransactionCommon,
|
TransactionCommon,
|
||||||
TransactionDeposit,
|
TransactionDeposit,
|
||||||
|
TransactionIdStr,
|
||||||
TransactionMajorState,
|
TransactionMajorState,
|
||||||
TransactionPayment,
|
TransactionPayment,
|
||||||
TransactionPeerPullCredit,
|
TransactionPeerPullCredit,
|
||||||
@ -63,7 +64,7 @@ const commonTransaction: TransactionCommon = {
|
|||||||
major: TransactionMajorState.Done,
|
major: TransactionMajorState.Done,
|
||||||
},
|
},
|
||||||
timestamp: TalerProtocolTimestamp.now(),
|
timestamp: TalerProtocolTimestamp.now(),
|
||||||
transactionId: "txn:deposit:12",
|
transactionId: "txn:deposit:12" as TransactionIdStr,
|
||||||
type: TransactionType.Deposit,
|
type: TransactionType.Deposit,
|
||||||
} as Omit<
|
} as Omit<
|
||||||
Omit<Omit<TransactionCommon, "extendedStatus">, "frozen">,
|
Omit<Omit<TransactionCommon, "extendedStatus">, "frozen">,
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
Transaction,
|
Transaction,
|
||||||
TransactionDeposit,
|
TransactionDeposit,
|
||||||
|
TransactionIdStr,
|
||||||
TransactionMajorState,
|
TransactionMajorState,
|
||||||
TransactionType,
|
TransactionType,
|
||||||
TranslatedString,
|
TranslatedString,
|
||||||
@ -74,10 +75,8 @@ interface Props {
|
|||||||
goToWalletHistory: (currency?: string) => Promise<void>;
|
goToWalletHistory: (currency?: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TransactionPage({
|
export function TransactionPage({ tid, goToWalletHistory }: Props): VNode {
|
||||||
tid: transactionId,
|
const transactionId = tid as TransactionIdStr; //FIXME: validate
|
||||||
goToWalletHistory,
|
|
||||||
}: Props): VNode {
|
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
const api = useBackendContext();
|
const api = useBackendContext();
|
||||||
const state = useAsyncAsHook(
|
const state = useAsyncAsHook(
|
||||||
@ -152,7 +151,7 @@ export interface WalletTransactionProps {
|
|||||||
onCancel: () => Promise<void>;
|
onCancel: () => Promise<void>;
|
||||||
onDelete: () => Promise<void>;
|
onDelete: () => Promise<void>;
|
||||||
onRetry: () => Promise<void>;
|
onRetry: () => Promise<void>;
|
||||||
onRefund: (id: string) => Promise<void>;
|
onRefund: (id: TransactionIdStr) => Promise<void>;
|
||||||
onBack: () => Promise<void>;
|
onBack: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +620,7 @@ export function TransactionView({
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={safely("refund transaction", () =>
|
onClick={safely("refund transaction", () =>
|
||||||
onRefund(transaction.proposalId),
|
onRefund(transaction.transactionId),
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<i18n.Translate>Accept</i18n.Translate>
|
<i18n.Translate>Accept</i18n.Translate>
|
||||||
|
Loading…
Reference in New Issue
Block a user