show accepted exchanges
This commit is contained in:
parent
344d3bda09
commit
8714240c90
2
lib/decl/mithril.d.ts
vendored
2
lib/decl/mithril.d.ts
vendored
@ -608,7 +608,7 @@ declare module _mithril {
|
|||||||
*
|
*
|
||||||
* @see m.component
|
* @see m.component
|
||||||
*/
|
*/
|
||||||
controller: MithrilControllerFunction<T> |
|
controller?: MithrilControllerFunction<T> |
|
||||||
MithrilControllerConstructor<T>;
|
MithrilControllerConstructor<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,6 +150,69 @@ export interface Coin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Checkable.Class
|
||||||
|
export class ExchangeHandle {
|
||||||
|
@Checkable.String
|
||||||
|
master_pub: string;
|
||||||
|
|
||||||
|
@Checkable.String
|
||||||
|
url: string;
|
||||||
|
|
||||||
|
static checked: (obj: any) => ExchangeHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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(ExchangeHandle))
|
||||||
|
exchanges: ExchangeHandle[];
|
||||||
|
|
||||||
|
@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;
|
||||||
|
|
||||||
|
@Checkable.Optional(Checkable.String)
|
||||||
|
repurchase_correlation_id: string;
|
||||||
|
|
||||||
|
static checked: (obj: any) => Contract;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export type PayCoinInfo = Array<{ updatedCoin: Coin, sig: CoinPaySig }>;
|
export type PayCoinInfo = Array<{ updatedCoin: Coin, sig: CoinPaySig }>;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ import {CryptoApi} from "./cryptoApi";
|
|||||||
import {Coin} from "./types";
|
import {Coin} from "./types";
|
||||||
import {PayCoinInfo} from "./types";
|
import {PayCoinInfo} from "./types";
|
||||||
import {CheckRepurchaseResult} from "./types";
|
import {CheckRepurchaseResult} from "./types";
|
||||||
|
import {Contract} from "./types";
|
||||||
|
import {ExchangeHandle} from "./types";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -182,68 +184,6 @@ export class ConfirmReserveRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Checkable.Class
|
|
||||||
export class ExchangeHandle {
|
|
||||||
@Checkable.String
|
|
||||||
master_pub: string;
|
|
||||||
|
|
||||||
@Checkable.String
|
|
||||||
url: string;
|
|
||||||
|
|
||||||
static checked: (obj: any) => ExchangeHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@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(ExchangeHandle))
|
|
||||||
exchanges: ExchangeHandle[];
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@Checkable.Optional(Checkable.String)
|
|
||||||
repurchase_correlation_id: string;
|
|
||||||
|
|
||||||
static checked: (obj: any) => Contract;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Checkable.Class
|
@Checkable.Class
|
||||||
export class Offer {
|
export class Offer {
|
||||||
|
@ -22,7 +22,7 @@ import {Checkable} from "./checkable";
|
|||||||
import {AmountJson} from "./types";
|
import {AmountJson} from "./types";
|
||||||
import Port = chrome.runtime.Port;
|
import Port = chrome.runtime.Port;
|
||||||
import {Notifier} from "./types";
|
import {Notifier} from "./types";
|
||||||
import {Contract} from "./wallet";
|
import {Contract} from "./types";
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
@ -21,12 +21,14 @@
|
|||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/// <reference path="../lib/decl/handlebars/handlebars.d.ts" />
|
/// <reference path="../lib/decl/handlebars/handlebars.d.ts" />
|
||||||
|
import MithrilComponent = _mithril.MithrilComponent;
|
||||||
|
import {substituteFulfillmentUrl} from "../lib/wallet/helpers";
|
||||||
|
import m from "mithril";
|
||||||
|
import {Contract} from "../lib/wallet/types";
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {substituteFulfillmentUrl} from "../lib/wallet/helpers";
|
|
||||||
|
|
||||||
declare var m: any;
|
|
||||||
|
|
||||||
function prettyAmount(amount) {
|
function prettyAmount(amount) {
|
||||||
let v = amount.value + amount.fraction / 1e6;
|
let v = amount.value + amount.fraction / 1e6;
|
||||||
@ -34,6 +36,35 @@ function prettyAmount(amount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Details = {
|
||||||
|
controller() {
|
||||||
|
return {collapsed: m.prop(true)};
|
||||||
|
},
|
||||||
|
view(ctrl, contract: Contract) {
|
||||||
|
if (ctrl.collapsed()) {
|
||||||
|
return m("div", [
|
||||||
|
m("button.linky", {
|
||||||
|
onclick: () => {
|
||||||
|
ctrl.collapsed(false);
|
||||||
|
}
|
||||||
|
}, "show more details")
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return m("div", [
|
||||||
|
m("button.linky", {
|
||||||
|
onclick: () => {
|
||||||
|
ctrl.collapsed(true);
|
||||||
|
}
|
||||||
|
}, "show less details"),
|
||||||
|
m("div", [
|
||||||
|
"Accepted exchanges:",
|
||||||
|
m("ul", contract.exchanges.map(e => m("li", `${e.url}: ${e.master_pub}`)))
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
let url = URI(document.location.href);
|
let url = URI(document.location.href);
|
||||||
let query: any = URI.parseQuery(url.query());
|
let query: any = URI.parseQuery(url.query());
|
||||||
@ -58,6 +89,7 @@ export function main() {
|
|||||||
`${p.description}: ${prettyAmount(p.price)}`))),
|
`${p.description}: ${prettyAmount(p.price)}`))),
|
||||||
m("button.confirm-pay", {onclick: doPayment}, i18n`Confirm Payment`),
|
m("button.confirm-pay", {onclick: doPayment}, i18n`Confirm Payment`),
|
||||||
m("p", error ? error : []),
|
m("p", error ? error : []),
|
||||||
|
m(Details, contract)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user