From 5e85cd8b8fa25ed3fbfc260b48bcad098978407a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 9 Feb 2016 21:56:06 +0100 Subject: new reserve creation protocol --- extension/lib/wallet/types.ts | 138 +++++++++++++++++++++++++++++++++++------- 1 file changed, 115 insertions(+), 23 deletions(-) (limited to 'extension/lib/wallet/types.ts') diff --git a/extension/lib/wallet/types.ts b/extension/lib/wallet/types.ts index 478287a21..4f512800e 100644 --- a/extension/lib/wallet/types.ts +++ b/extension/lib/wallet/types.ts @@ -14,6 +14,8 @@ TALER; see the file COPYING. If not, If not, see */ +import {EddsaPublicKey} from "./emscriptif"; +import {Checkable} from "./checkable"; "use strict"; // TODO: factor into multiple files @@ -61,48 +63,138 @@ export interface Coin { } -export interface AmountJson { +@Checkable.Class +export class AmountJson { + @Checkable.Number value: number; - fraction: number + + @Checkable.Number + fraction: number; + + @Checkable.String currency: string; + + static checked: (obj: any) => AmountJson; } -export interface ConfirmReserveRequest { +@Checkable.Class +export class CreateReserveRequest { /** - * Name of the form field for the amount. + * The initial amount for the reserve. */ - field_amount; + @Checkable.Value(AmountJson) + amount: AmountJson; /** - * Name of the form field for the reserve public key. + * Mint URL where the bank should create the reserve. */ - field_reserve_pub; + @Checkable.String + mint: string; - /** - * Name of the form field for the reserve public key. - */ - field_mint; + static checked: (obj: any) => CreateReserveRequest; +} - /** - * The actual amount in string form. - * TODO: where is this format specified? - */ - amount_str; +@Checkable.Class +export class CreateReserveResponse { /** - * Target URL for the reserve creation request. + * Mint URL where the bank should create the reserve. + * The URL is canonicalized in the response. */ - post_url; + @Checkable.String + mint: string; + + @Checkable.String + reservePub: string; + + static checked: (obj: any) => CreateReserveResponse; +} + +@Checkable.Class +export class ConfirmReserveRequest { /** - * Mint URL where the bank should create the reserve. + * Public key of then reserve that should be marked + * as confirmed. */ - mint; + @Checkable.String + reservePub: string; + + static checked: (obj: any) => ConfirmReserveRequest; } -export interface ConfirmReserveResponse { - backlink?: string; - success: boolean; +@Checkable.Class +export class MintInfo { + @Checkable.String + master_pub: string; + + @Checkable.String + url: string; + + static checked: (obj: any) => MintInfo; +} + + +@Checkable.Class +export class Contract { + @Checkable.String + H_wire: string; + + @Checkable.Value(AmountJson) + amount: AmountJson; + + @Checkable.List(Checkable.AnyObject) + auditors: any[]; + + @Checkable.String + expiry: string; + + @Checkable.Any + locations: any; + + @Checkable.Value(AmountJson) + max_fee: AmountJson; + + @Checkable.Any + merchant: any; + + @Checkable.String + merchant_pub: string; + + @Checkable.List(Checkable.Value(MintInfo)) + mints: MintInfo[]; + + @Checkable.List(Checkable.AnyObject) + products: any[]; + + @Checkable.String + refund_deadline: string; + + @Checkable.String + timestamp: string; + + @Checkable.Number + transaction_id: number; + + @Checkable.String + fulfillment_url: string; + + static checked: (obj: any) => Contract; +} + + +@Checkable.Class +export class Offer { + @Checkable.Value(Contract) + contract: Contract; + + @Checkable.String + merchant_sig: string; + + @Checkable.String + H_contract: string; + + static checked: (obj: any) => Offer; } \ No newline at end of file -- cgit v1.2.3