wallet-core: use PeerContractTerms
This commit is contained in:
parent
2f6225f6e7
commit
dab739a63e
@ -413,8 +413,9 @@ export interface InternationalizedString {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract terms from a merchant.
|
* Contract terms from a merchant.
|
||||||
|
* FIXME: Add type field!
|
||||||
*/
|
*/
|
||||||
export interface ContractTerms {
|
export interface MerchantContractTerms {
|
||||||
/**
|
/**
|
||||||
* Hash of the merchant's wire details.
|
* Hash of the merchant's wire details.
|
||||||
*/
|
*/
|
||||||
@ -1310,8 +1311,8 @@ export const codecForProduct = (): Codec<Product> =>
|
|||||||
.property("price", codecOptional(codecForString()))
|
.property("price", codecOptional(codecForString()))
|
||||||
.build("Tax");
|
.build("Tax");
|
||||||
|
|
||||||
export const codecForContractTerms = (): Codec<ContractTerms> =>
|
export const codecForContractTerms = (): Codec<MerchantContractTerms> =>
|
||||||
buildCodecForObject<ContractTerms>()
|
buildCodecForObject<MerchantContractTerms>()
|
||||||
.property("order_id", codecForString())
|
.property("order_id", codecForString())
|
||||||
.property("fulfillment_url", codecOptional(codecForString()))
|
.property("fulfillment_url", codecOptional(codecForString()))
|
||||||
.property("fulfillment_message", codecOptional(codecForString()))
|
.property("fulfillment_message", codecOptional(codecForString()))
|
||||||
|
@ -55,7 +55,7 @@ import {
|
|||||||
AuditorDenomSig,
|
AuditorDenomSig,
|
||||||
codecForContractTerms,
|
codecForContractTerms,
|
||||||
CoinEnvelope,
|
CoinEnvelope,
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
DenominationPubKey,
|
DenominationPubKey,
|
||||||
DenomKeyType,
|
DenomKeyType,
|
||||||
ExchangeAuditor,
|
ExchangeAuditor,
|
||||||
@ -229,7 +229,7 @@ export enum ConfirmPayResultType {
|
|||||||
*/
|
*/
|
||||||
export interface ConfirmPayResultDone {
|
export interface ConfirmPayResultDone {
|
||||||
type: ConfirmPayResultType.Done;
|
type: ConfirmPayResultType.Done;
|
||||||
contractTerms: ContractTerms;
|
contractTerms: MerchantContractTerms;
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +529,7 @@ export type PreparePayResult =
|
|||||||
export interface PreparePayResultPaymentPossible {
|
export interface PreparePayResultPaymentPossible {
|
||||||
status: PreparePayResultType.PaymentPossible;
|
status: PreparePayResultType.PaymentPossible;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
contractTerms: ContractTerms;
|
contractTerms: MerchantContractTerms;
|
||||||
contractTermsHash: string;
|
contractTermsHash: string;
|
||||||
amountRaw: string;
|
amountRaw: string;
|
||||||
amountEffective: string;
|
amountEffective: string;
|
||||||
@ -539,14 +539,14 @@ export interface PreparePayResultPaymentPossible {
|
|||||||
export interface PreparePayResultInsufficientBalance {
|
export interface PreparePayResultInsufficientBalance {
|
||||||
status: PreparePayResultType.InsufficientBalance;
|
status: PreparePayResultType.InsufficientBalance;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
contractTerms: ContractTerms;
|
contractTerms: MerchantContractTerms;
|
||||||
amountRaw: string;
|
amountRaw: string;
|
||||||
noncePriv: string;
|
noncePriv: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PreparePayResultAlreadyConfirmed {
|
export interface PreparePayResultAlreadyConfirmed {
|
||||||
status: PreparePayResultType.AlreadyConfirmed;
|
status: PreparePayResultType.AlreadyConfirmed;
|
||||||
contractTerms: ContractTerms;
|
contractTerms: MerchantContractTerms;
|
||||||
paid: boolean;
|
paid: boolean;
|
||||||
amountRaw: string;
|
amountRaw: string;
|
||||||
amountEffective: string;
|
amountEffective: string;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
import {
|
import {
|
||||||
AmountString,
|
AmountString,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
Duration,
|
Duration,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
@ -381,7 +381,7 @@ export async function makeTestPayment(
|
|||||||
args: {
|
args: {
|
||||||
merchant: MerchantServiceInterface;
|
merchant: MerchantServiceInterface;
|
||||||
wallet: WalletCli;
|
wallet: WalletCli;
|
||||||
order: Partial<ContractTerms>;
|
order: Partial<MerchantContractTerms>;
|
||||||
instance?: string;
|
instance?: string;
|
||||||
},
|
},
|
||||||
auth: WithAuthorization = {},
|
auth: WithAuthorization = {},
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
Duration,
|
Duration,
|
||||||
Codec,
|
Codec,
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
@ -50,7 +50,7 @@ import {
|
|||||||
export interface PostOrderRequest {
|
export interface PostOrderRequest {
|
||||||
// The order must at least contain the minimal
|
// The order must at least contain the minimal
|
||||||
// order detail, but can override all
|
// order detail, but can override all
|
||||||
order: Partial<ContractTerms>;
|
order: Partial<MerchantContractTerms>;
|
||||||
|
|
||||||
// if set, the backend will then set the refund deadline to the current
|
// if set, the backend will then set the refund deadline to the current
|
||||||
// time plus the specified delay.
|
// time plus the specified delay.
|
||||||
@ -143,7 +143,7 @@ export interface CheckPaymentClaimedResponse {
|
|||||||
// Wallet claimed the order, but didn't pay yet.
|
// Wallet claimed the order, but didn't pay yet.
|
||||||
order_status: "claimed";
|
order_status: "claimed";
|
||||||
|
|
||||||
contract_terms: ContractTerms;
|
contract_terms: MerchantContractTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CheckPaymentPaidResponse {
|
export interface CheckPaymentPaidResponse {
|
||||||
@ -175,7 +175,7 @@ export interface CheckPaymentPaidResponse {
|
|||||||
refund_amount: AmountString;
|
refund_amount: AmountString;
|
||||||
|
|
||||||
// Contract terms
|
// Contract terms
|
||||||
contract_terms: ContractTerms;
|
contract_terms: MerchantContractTerms;
|
||||||
|
|
||||||
// Ihe wire transfer status from the exchange for this order if available, otherwise empty array
|
// Ihe wire transfer status from the exchange for this order if available, otherwise empty array
|
||||||
wire_details: TransactionWireTransfer[];
|
wire_details: TransactionWireTransfer[];
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { AbsoluteTime, ContractTerms, Duration } from "@gnu-taler/taler-util";
|
import { AbsoluteTime, MerchantContractTerms, Duration } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
WalletApiOperation,
|
WalletApiOperation,
|
||||||
HarnessExchangeBankAccount,
|
HarnessExchangeBankAccount,
|
||||||
@ -271,7 +271,7 @@ export async function runLibeufinBasicTest(t: GlobalTestState) {
|
|||||||
console.log("balances", JSON.stringify(bal, undefined, 2));
|
console.log("balances", JSON.stringify(bal, undefined, 2));
|
||||||
t.assertAmountEquals(bal.balances[0].available, "EUR:14.7");
|
t.assertAmountEquals(bal.balances[0].available, "EUR:14.7");
|
||||||
|
|
||||||
const order: Partial<ContractTerms> = {
|
const order: Partial<MerchantContractTerms> = {
|
||||||
summary: "Buy me!",
|
summary: "Buy me!",
|
||||||
amount: "EUR:5",
|
amount: "EUR:5",
|
||||||
fulfillment_url: "taler://fulfillment-success/thx",
|
fulfillment_url: "taler://fulfillment-success/thx",
|
||||||
|
@ -25,7 +25,7 @@ import {
|
|||||||
CoinEnvelope,
|
CoinEnvelope,
|
||||||
CoinRefreshRequest,
|
CoinRefreshRequest,
|
||||||
CoinStatus,
|
CoinStatus,
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
DenominationInfo,
|
DenominationInfo,
|
||||||
DenominationPubKey,
|
DenominationPubKey,
|
||||||
DenomSelectionState,
|
DenomSelectionState,
|
||||||
@ -1572,7 +1572,7 @@ export interface DepositGroupRecord {
|
|||||||
/**
|
/**
|
||||||
* Verbatim contract terms.
|
* Verbatim contract terms.
|
||||||
*/
|
*/
|
||||||
contractTermsRaw: ContractTerms;
|
contractTermsRaw: MerchantContractTerms;
|
||||||
|
|
||||||
contractTermsHash: string;
|
contractTermsHash: string;
|
||||||
|
|
||||||
@ -1707,10 +1707,9 @@ export interface PeerPullPaymentInitiationRecord {
|
|||||||
/**
|
/**
|
||||||
* Contract terms for the other party.
|
* Contract terms for the other party.
|
||||||
*
|
*
|
||||||
* FIXME: Nail down type!
|
* FIXME: Put into contract terms store.
|
||||||
* FIXME: Put in contractTerms store
|
|
||||||
*/
|
*/
|
||||||
contractTerms: any;
|
contractTerms: PeerContractTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ import {
|
|||||||
CancellationToken,
|
CancellationToken,
|
||||||
canonicalJson,
|
canonicalJson,
|
||||||
codecForDepositSuccess,
|
codecForDepositSuccess,
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
CreateDepositGroupRequest,
|
CreateDepositGroupRequest,
|
||||||
CreateDepositGroupResponse,
|
CreateDepositGroupResponse,
|
||||||
DepositGroupFees,
|
DepositGroupFees,
|
||||||
@ -310,7 +310,7 @@ export async function prepareDepositGroup(
|
|||||||
|
|
||||||
const now = AbsoluteTime.now();
|
const now = AbsoluteTime.now();
|
||||||
const nowRounded = AbsoluteTime.toTimestamp(now);
|
const nowRounded = AbsoluteTime.toTimestamp(now);
|
||||||
const contractTerms: ContractTerms = {
|
const contractTerms: MerchantContractTerms = {
|
||||||
auditors: [],
|
auditors: [],
|
||||||
exchanges: exchangeInfos,
|
exchanges: exchangeInfos,
|
||||||
amount: req.amount,
|
amount: req.amount,
|
||||||
@ -407,7 +407,7 @@ export async function createDepositGroup(
|
|||||||
const merchantPair = await ws.cryptoApi.createEddsaKeypair({});
|
const merchantPair = await ws.cryptoApi.createEddsaKeypair({});
|
||||||
const wireSalt = encodeCrock(getRandomBytes(16));
|
const wireSalt = encodeCrock(getRandomBytes(16));
|
||||||
const wireHash = hashWire(req.depositPaytoUri, wireSalt);
|
const wireHash = hashWire(req.depositPaytoUri, wireSalt);
|
||||||
const contractTerms: ContractTerms = {
|
const contractTerms: MerchantContractTerms = {
|
||||||
auditors: [],
|
auditors: [],
|
||||||
exchanges: exchangeInfos,
|
exchanges: exchangeInfos,
|
||||||
amount: req.amount,
|
amount: req.amount,
|
||||||
|
@ -44,7 +44,7 @@ import {
|
|||||||
CoinStatus,
|
CoinStatus,
|
||||||
ConfirmPayResult,
|
ConfirmPayResult,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
ContractTerms,
|
MerchantContractTerms,
|
||||||
ContractTermsUtil,
|
ContractTermsUtil,
|
||||||
DenominationInfo,
|
DenominationInfo,
|
||||||
Duration,
|
Duration,
|
||||||
@ -298,7 +298,7 @@ export async function expectProposalDownload(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function extractContractData(
|
export function extractContractData(
|
||||||
parsedContractTerms: ContractTerms,
|
parsedContractTerms: MerchantContractTerms,
|
||||||
contractTermsHash: string,
|
contractTermsHash: string,
|
||||||
merchantSig: string,
|
merchantSig: string,
|
||||||
): WalletContractData {
|
): WalletContractData {
|
||||||
@ -453,7 +453,7 @@ export async function processDownloadProposal(
|
|||||||
|
|
||||||
logger.info(`Contract terms hash: ${contractTermsHash}`);
|
logger.info(`Contract terms hash: ${contractTermsHash}`);
|
||||||
|
|
||||||
let parsedContractTerms: ContractTerms;
|
let parsedContractTerms: MerchantContractTerms;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
parsedContractTerms = codecForContractTerms().decode(
|
parsedContractTerms = codecForContractTerms().decode(
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Amounts,
|
Amounts,
|
||||||
ConfirmPayResultType,
|
MerchantContractTerms as ContractTerms,
|
||||||
ContractTerms,
|
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import merchantIcon from "../../../static-dev/merchant-icon.jpeg";
|
import merchantIcon from "../../../static-dev/merchant-icon.jpeg";
|
||||||
|
@ -18,17 +18,14 @@ import {
|
|||||||
AbsoluteTime,
|
AbsoluteTime,
|
||||||
AmountJson,
|
AmountJson,
|
||||||
Amounts,
|
Amounts,
|
||||||
ConfirmPayResultType,
|
MerchantContractTerms as ContractTerms,
|
||||||
ContractTerms,
|
|
||||||
PreparePayResult,
|
PreparePayResult,
|
||||||
PreparePayResultPaymentPossible,
|
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
Product,
|
Product,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { Fragment, h, VNode } from "preact";
|
import { Fragment, h, VNode } from "preact";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { Amount } from "../../components/Amount.js";
|
import { Amount } from "../../components/Amount.js";
|
||||||
import { ErrorTalerOperation } from "../../components/ErrorTalerOperation.js";
|
|
||||||
import { LoadingError } from "../../components/LoadingError.js";
|
import { LoadingError } from "../../components/LoadingError.js";
|
||||||
import { LogoHeader } from "../../components/LogoHeader.js";
|
import { LogoHeader } from "../../components/LogoHeader.js";
|
||||||
import { Part } from "../../components/Part.js";
|
import { Part } from "../../components/Part.js";
|
||||||
|
Loading…
Reference in New Issue
Block a user