From 87f981d91c952e7351a06b42aa88d2401addc8f2 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 31 May 2017 11:56:26 +0200 Subject: improve backend / content script messaging --- src/webex/wxApi.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/webex/wxApi.ts') diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts index 248cb04b5..ff601b6f7 100644 --- a/src/webex/wxApi.ts +++ b/src/webex/wxApi.ts @@ -196,9 +196,10 @@ export function hashContract(contract: object): Promise { } /** - * Save an offer in the wallet. + * Save an offer in the wallet. Returns the offer id that + * the offer is stored under. */ -export function saveOffer(offer: object): Promise { +export function saveOffer(offer: object): Promise { return callBackend("save-offer", { offer }); } @@ -208,3 +209,47 @@ export function saveOffer(offer: object): Promise { export function confirmReserve(reservePub: string): Promise { return callBackend("confirm-reserve", { reservePub }); } + +/** + * Query for a payment by fulfillment URL. + */ +export function queryPayment(url: string): Promise { + return callBackend("query-payment", { url }); +} + +/** + * Add a new history item. + */ +export function putHistory(historyEntry: any): Promise { + return callBackend("put-history-entry", { historyEntry }); +} + +/** + * Mark a payment as succeeded. + */ +export function paymentSucceeded(contractTermsHash: string, merchantSig: string): Promise { + return callBackend("payment-succeeded", { contractTermsHash, merchantSig }); +} + +/** + * Mark a payment as succeeded. + */ +export function paymentFailed(contractTermsHash: string): Promise { + return callBackend("payment-failed", { contractTermsHash }); +} + +/** + * Get the payment cookie for the current tab, or undefined if no payment + * cookie was set. + */ +export function getTabCookie(contractTermsHash: string, merchantSig: string): Promise { + return callBackend("get-tab-cookie"); +} + +/** + * Generate a contract nonce (EdDSA key pair), store it in the wallet's + * database and return the public key. + */ +export function generateNonce(): Promise { + return callBackend("generate-nonce"); +} -- cgit v1.2.3