diff --git a/src/services.ts b/src/services.ts index d02fb70..81298d3 100644 --- a/src/services.ts +++ b/src/services.ts @@ -1,4 +1,4 @@ -import { createUserReturn, User, Process, createTransactionReturn, parse_network_msg, outputs_list, FaucetMessage, AnkFlag, NewTxMessage, encryptWithNewKeyResult, AnkSharedSecret, CachedMessage, UnknownMessage } from '../dist/pkg/sdk_client'; +import { createUserReturn, User, Process, createTransactionReturn, outputs_list, FaucetMessage, AnkFlag, NewTxMessage, CipherMessage, CachedMessage } from '../dist/pkg/sdk_client'; import IndexedDB from './database' import { WebSocketClient } from './websockets'; @@ -105,7 +105,7 @@ class Services { const recipientSpAddress = spAddressElement.value; const message = messageElement.value; - const msg_payload: UnknownMessage = {sender: this.sp_address!, message: message}; + const msg_payload: CipherMessage = {sender: this.sp_address!, message: message, error: null}; let notificationInfo = await services.notify_address_for_message(recipientSpAddress, msg_payload); if (notificationInfo) { @@ -113,7 +113,7 @@ class Services { console.debug(networkMsg); const connection = await services.pickWebsocketConnectionRandom(); - const flag: AnkFlag = "Unknown"; + const flag: AnkFlag = 'Cipher'; try { // send message (transaction in envelope) await services.updateMessages(networkMsg); @@ -763,6 +763,7 @@ class Services { let faucetMsg: FaucetMessage = { sp_address: cachedMsg.recipient, commitment: cachedMsg.commitment, + error: null, } connection.sendMessage(flag, JSON.stringify(faucetMsg)); } @@ -836,7 +837,8 @@ class Services { const flag: AnkFlag = "NewTx"; const newTxMsg: NewTxMessage = { 'transaction': notificationInfo.transaction, - 'tweak_data': null + 'tweak_data': null, + 'error': null, } connection.sendMessage(flag, JSON.stringify(newTxMsg)); await services.updateMessages(notificationInfo.new_network_msg); @@ -871,14 +873,15 @@ class Services { const flag: AnkFlag = "NewTx"; const newTxMsg: NewTxMessage = { 'transaction': notificationInfo.transaction, - 'tweak_data': null + 'tweak_data': null, + 'error': null, } connection.sendMessage(flag, JSON.stringify(newTxMsg)); await services.updateMessages(notificationInfo.new_network_msg); return; } - public async notify_address_for_message(sp_address: string, message: UnknownMessage): Promise { + public async notify_address_for_message(sp_address: string, message: CipherMessage): Promise { const services = await Services.getInstance(); const connection = await services.pickWebsocketConnectionRandom(); if (!connection) { @@ -891,7 +894,8 @@ class Services { const flag: AnkFlag = "NewTx"; const newTxMsg: NewTxMessage = { 'transaction': notificationInfo.transaction, - 'tweak_data': null + 'tweak_data': null, + 'error': null, } connection.sendMessage(flag, JSON.stringify(newTxMsg)); console.info('Successfully sent notification transaction'); diff --git a/src/websockets.ts b/src/websockets.ts index 04d47ef..6cc35c5 100644 --- a/src/websockets.ts +++ b/src/websockets.ts @@ -31,11 +31,7 @@ class WebSocketClient { // By parsing the message, we can link it with existing cached message and return the updated version of the message let res: CachedMessage = await services.parseNetworkMessage(msgData, feeRate); console.debug(res); - if (res.status === 'Error') { - if (res.error) { - console.error(res.error); - } - } else if (res.status === 'FaucetComplete') { + if (res.status === 'FaucetComplete') { // we received a faucet tx, there's nothing else to do window.alert(`New faucet output\n${res.commited_in}`); await services.updateMessages(res);