diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-31 11:56:26 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-31 11:57:09 +0200 |
commit | 87f981d91c952e7351a06b42aa88d2401addc8f2 (patch) | |
tree | bb224a73cdb8947f6d59884b754cb8ad019cc445 /src/webex/wxApi.ts | |
parent | 04a7800bc8c27475585fbad36c74b13a8cd814c8 (diff) | |
download | wallet-core-87f981d91c952e7351a06b42aa88d2401addc8f2.tar.gz wallet-core-87f981d91c952e7351a06b42aa88d2401addc8f2.tar.bz2 wallet-core-87f981d91c952e7351a06b42aa88d2401addc8f2.zip |
improve backend / content script messaging
Diffstat (limited to 'src/webex/wxApi.ts')
-rw-r--r-- | src/webex/wxApi.ts | 49 |
1 files changed, 47 insertions, 2 deletions
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<string> { } /** - * 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<void> { +export function saveOffer(offer: object): Promise<number> { return callBackend("save-offer", { offer }); } @@ -208,3 +209,47 @@ export function saveOffer(offer: object): Promise<void> { export function confirmReserve(reservePub: string): Promise<void> { return callBackend("confirm-reserve", { reservePub }); } + +/** + * Query for a payment by fulfillment URL. + */ +export function queryPayment(url: string): Promise<any> { + return callBackend("query-payment", { url }); +} + +/** + * Add a new history item. + */ +export function putHistory(historyEntry: any): Promise<void> { + return callBackend("put-history-entry", { historyEntry }); +} + +/** + * Mark a payment as succeeded. + */ +export function paymentSucceeded(contractTermsHash: string, merchantSig: string): Promise<void> { + return callBackend("payment-succeeded", { contractTermsHash, merchantSig }); +} + +/** + * Mark a payment as succeeded. + */ +export function paymentFailed(contractTermsHash: string): Promise<void> { + 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<any> { + 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<string> { + return callBackend("generate-nonce"); +} |