From 8effff33efc01b8d54f62562e8862a0bfc254829 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 7 Nov 2024 19:30:02 +0800 Subject: [PATCH 01/14] fix message passing in Firefox --- packages/yoroi-extension/app/api/thunk.js | 11 ++++++++++- .../extension/background/subscriptionManager.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 8bdd30e91f..d6b35cd7fa 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -408,8 +408,17 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener(async (message, _sender, _sendResponse) => { +chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendResponse) => { //fixme: verify sender.id/origin + let message; + try { + message = JSON.parse(serializedMessage); + } catch { + return; + } + if (typeof message !== 'object') { + return; + } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); if (message.type === 'wallet-state-update') { diff --git a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js index a04d09943b..6f87855b40 100644 --- a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js +++ b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js @@ -68,6 +68,6 @@ declare var chrome; */ export function emitUpdateToSubscriptions(data: Object): void { for (const { tabId } of getSubscriptions()) { - chrome.tabs.sendMessage(tabId, data); + chrome.tabs.sendMessage(tabId, JSON.stringify(data)); } } From 8f1329cc046b3c4a50552f421ba2e72daf5accd6 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 21 Oct 2024 00:22:45 +0300 Subject: [PATCH 02/14] messaging serialization fix --- packages/yoroi-extension/app/api/thunk.js | 9 ++++++--- .../chrome/extension/background/handlers/yoroi/index.js | 1 + .../chrome/extension/background/handlers/yoroi/wallet.js | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index d6b35cd7fa..5a5efe1718 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -110,6 +110,8 @@ declare var chrome; export function callBackground(message: T): Promise { return new Promise((resolve, reject) => { window.chrome.runtime.sendMessage(message, response => { + // $FlowIgnore + console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); if (window.chrome.runtime.lastError) { // eslint-disable-next-line prefer-promise-reject-errors reject(`Error ${window.chrome.runtime.lastError} when calling the background with: ${JSON.stringify(sanitizeForLog(message)) ?? 'undefined'}`); @@ -306,11 +308,12 @@ function deserializeTx(tx: any): ?WalletTransaction { } export const refreshTransactions: GetEntryFuncType = async (request) => { - const txs = await callBackground({ type: 'refresh-transactions', request }); - if (txs.error) { - console.error('Failed to refresh transactions!', txs.error); + const resp = await callBackground({ type: RefreshTransactions.typeTag, request }); + if (resp.error) { + console.error('Failed to refresh transactions!', resp.error); return []; } + const txs = JSON.parse(resp); return txs.map(tx => { try { return deserializeTx(tx); diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js index f935d3711a..b312ad4db3 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js @@ -107,6 +107,7 @@ export function getHandler(typeTag: string): ?Handler { return async (request, send, sendResponse) => { try { const result = await handler(request.request); + console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(result)); sendResponse(result); } catch (error) { sendResponse({ error: error.message }); diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js index 3bdce74838..9090ecc164 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js @@ -354,6 +354,7 @@ export const RefreshTransactions: HandlerType< // initial transaction list loading txs = await adaApi.refreshTransactions(refreshTxRequest); } - return txs; + // $FlowIgnore + return JSON.stringify(txs); }, }); From a8db8087cbbc7ed3e3d3a1c6cd67442d0c0a5ab9 Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:11:46 +0800 Subject: [PATCH 03/14] fix serialization --- packages/yoroi-extension/app/api/thunk.js | 10 +++++++--- .../background/handlers/yoroi/protocolParameters.js | 2 +- .../extension/background/handlers/yoroi/wallet.js | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 5a5efe1718..6fae34f1e8 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -292,7 +292,8 @@ export async function removeAllTransactions( } } -export const popAddress: GetEntryFuncType = async ({ publicDeriverId }) => { +type PopAddressType = ({ publicDeriverId: number, ...}) => ReturnType>; +export const popAddress: PopAddressType = async ({ publicDeriverId }) => { await callBackground({ type: PopAddress.typeTag, request: { publicDeriverId } }); } @@ -401,8 +402,11 @@ export const getConnectedSites: GetEntryFuncType = asy return await callBackground({ type: GetConnectedSites.typeTag }); } -export const getProtocolParameters: GetEntryFuncType = async (request) => { - return await callBackground({ type: GetProtocolParameters.typeTag, request }); +type GetProtocolParametersType = ({ networkId: number, ... }) => ReturnType>; +export const getProtocolParameters: GetProtocolParametersType = async ( + { networkId } +) => { + return await callBackground({ type: GetProtocolParameters.typeTag, request: { networkId } }); } // Background -> UI notifications: diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js index 93e4cdb8c0..109f64594b 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/protocolParameters.js @@ -206,7 +206,7 @@ class ProcolParameterApi { } export const GetProtocolParameters: HandlerType< - { networkId: number, ... }, + {| networkId: number |}, ProtocolParameters > = Object.freeze({ typeTag: 'get-protocol-parameters', diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js index 9090ecc164..bd9b23d1e8 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/wallet.js @@ -250,7 +250,7 @@ export const GetPrivateStakingKey: HandlerType< }); export const RemoveAllTransactions: HandlerType< - { publicDeriverId: number, ... }, + {| publicDeriverId: number |}, void > = Object.freeze({ typeTag: 'remove-all-transactions', @@ -275,7 +275,7 @@ export const RemoveAllTransactions: HandlerType< }); export const PopAddress: HandlerType< - { publicDeriverId: number, ... }, + {| publicDeriverId: number |}, void > = Object.freeze({ typeTag: 'pop-address', From 2559f7563bd01f161db9369fb37bd90cce66df1d Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:26:21 +0800 Subject: [PATCH 04/14] serialize request data from frontend to the background --- packages/yoroi-extension/app/api/thunk.js | 5 +++-- .../yoroi-extension/chrome/extension/background/index.js | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 6fae34f1e8..baad0098f9 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -107,9 +107,10 @@ declare var chrome; // UI -> background queries: -export function callBackground(message: T): Promise { +export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { - window.chrome.runtime.sendMessage(message, response => { + const serializedMessage = { type: message.type, request: JSON.stringify(message.request || null) }; + window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); if (window.chrome.runtime.lastError) { diff --git a/packages/yoroi-extension/chrome/extension/background/index.js b/packages/yoroi-extension/chrome/extension/background/index.js index 9df389ca06..ab35d1d8d7 100644 --- a/packages/yoroi-extension/chrome/extension/background/index.js +++ b/packages/yoroi-extension/chrome/extension/background/index.js @@ -36,7 +36,11 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { } const handler = getHandler(message.type); if (handler) { - handler(message, sender, sendResponse); + const deserializedMessage = { + type: message.type, + request: JSON.parse(message.request), + }; + handler(deserializedMessage, sender, sendResponse); // Returning `true` is required by Firefox, see: // https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage return true; From 961c7360f5258d089d713f3b5119939be4147405 Mon Sep 17 00:00:00 2001 From: yushi Date: Wed, 23 Oct 2024 21:31:56 +0800 Subject: [PATCH 05/14] add error log --- packages/yoroi-extension/app/api/thunk.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index baad0098f9..0579b29bc4 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -422,9 +422,11 @@ chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendRes try { message = JSON.parse(serializedMessage); } catch { + Logger.error('underializable message'); return; } if (typeof message !== 'object') { + Logger.error('unrecognizable message'); return; } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); From 9070b9a36d510a41df830a03a65fa4ccf2f58b48 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 25 Oct 2024 18:20:54 +0800 Subject: [PATCH 06/14] fix FF connector pop out window could not get response for API call to the background when the main extension window is open --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 0579b29bc4..09414672d5 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -416,7 +416,7 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener(async (serializedMessage, _sender, _sendResponse) => { +chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) => { //fixme: verify sender.id/origin let message; try { From 60c103171baaaffb1c8b529f846512247a6c2504 Mon Sep 17 00:00:00 2001 From: yushi Date: Fri, 25 Oct 2024 21:06:21 +0800 Subject: [PATCH 07/14] parvum melius --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 09414672d5..f535bcc100 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -109,7 +109,7 @@ declare var chrome; export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { - const serializedMessage = { type: message.type, request: JSON.stringify(message.request || null) }; + const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); From 510834518b2a7291cae819b42721761635337e88 Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 29 Oct 2024 16:46:17 +0800 Subject: [PATCH 08/14] lint --- packages/yoroi-extension/app/api/thunk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index f535bcc100..b88b7ce072 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -107,7 +107,7 @@ declare var chrome; // UI -> background queries: -export function callBackground(message: {| type: string, request?: Object |}): Promise { +export function callBackground(message: {| type: string, request?: Object |}): Promise { return new Promise((resolve, reject) => { const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { From a8d65217e91a422d78e8bafd6e6c24eeba5e025c Mon Sep 17 00:00:00 2001 From: yushi Date: Tue, 5 Nov 2024 16:16:42 +0800 Subject: [PATCH 09/14] log error when UI gets unserializable message --- packages/yoroi-extension/app/api/thunk.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index b88b7ce072..c29a7a9932 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -421,12 +421,12 @@ chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) let message; try { message = JSON.parse(serializedMessage); - } catch { - Logger.error('underializable message'); + } catch (error) { + Logger.error('unserializable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); return; } if (typeof message !== 'object') { - Logger.error('unrecognizable message'); + Logger.error('unrecognizable message type: ' + (typeof message) + ' (expected object); Original message: ' + serializedMessage); return; } Logger.debug('get message from background:', JSON.stringify(sanitizeForLog(message))); From 55cc2e62f07cd908755a6d0f021ce4255e7bdcd5 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Fri, 8 Nov 2024 23:33:38 +0300 Subject: [PATCH 10/14] sanitized --- packages/yoroi-extension/app/api/thunk.js | 2 +- packages/yoroi-extension/app/coreUtils.js | 8 +++++--- .../chrome/extension/background/handlers/yoroi/index.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index c29a7a9932..9ac5be3c09 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -112,7 +112,7 @@ export function callBackground(message: {| type: string, request?: Object |}) const serializedMessage = { type: message.type, request: JSON.stringify(message.request ?? null) }; window.chrome.runtime.sendMessage(serializedMessage, response => { // $FlowIgnore - console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(response)); + console.debug(`CLIENT [${message.type}] received result: `, JSON.stringify(sanitizeForLog(response))); if (window.chrome.runtime.lastError) { // eslint-disable-next-line prefer-promise-reject-errors reject(`Error ${window.chrome.runtime.lastError} when calling the background with: ${JSON.stringify(sanitizeForLog(message)) ?? 'undefined'}`); diff --git a/packages/yoroi-extension/app/coreUtils.js b/packages/yoroi-extension/app/coreUtils.js index 1d60daf755..be0a53c946 100644 --- a/packages/yoroi-extension/app/coreUtils.js +++ b/packages/yoroi-extension/app/coreUtils.js @@ -225,11 +225,13 @@ export function timeCached(fun: () => R, ttl: number): () => R { * @return same value or a copy in case the value is an object */ export function sanitizeForLog(v: any): any { + const fields: Array = ['password']; if (v != null && typeof v === 'object') { let r = Object.keys(v).reduce((o, k) => ({ ...o, [k]: sanitizeForLog(v[k]) }) , {}) - // $FlowIgnore[incompatible-use] - if (r.password != null) { - r = { ...r, password: '[sanitized]' }; + for (const f of fields) { + if (r[f] != null) { + r = { ...r, [f]: '[sanitized]' }; + } } return r; } diff --git a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js index b312ad4db3..4b88c7b783 100644 --- a/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js +++ b/packages/yoroi-extension/chrome/extension/background/handlers/yoroi/index.js @@ -43,6 +43,7 @@ import { } from './connector'; import { GetProtocolParameters } from './protocolParameters'; import { subscribe } from '../../subscriptionManager'; +import { sanitizeForLog } from '../../../../../app/coreUtils'; const handlerMap = Object.freeze({ [GetHistoricalCoinPrices.typeTag]: GetHistoricalCoinPrices.handle, @@ -107,7 +108,7 @@ export function getHandler(typeTag: string): ?Handler { return async (request, send, sendResponse) => { try { const result = await handler(request.request); - console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(result)); + console.debug(`BACKGROUND [${typeTag}] sending result: `, JSON.stringify(sanitizeForLog(result))); sendResponse(result); } catch (error) { sendResponse({ error: error.message }); From 04dfbbc47d0efb93aa5f2ec115bbec35d4d50190 Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Sun, 10 Nov 2024 00:19:14 +0300 Subject: [PATCH 11/14] filter message passing --- packages/yoroi-extension/app/api/thunk.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 9ac5be3c09..b8516b9719 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -416,13 +416,22 @@ const callbacks = Object.freeze({ serverStatusUpdate: [], coinPriceUpdate: [], }); -chrome.runtime.onMessage.addListener((serializedMessage, _sender, _sendResponse) => { - //fixme: verify sender.id/origin +const APP_ORIGIN = window.location.origin || null; +chrome.runtime.onMessage.addListener((serializedMessage, { origin }, _sendResponse) => { + if (APP_ORIGIN != null && origin !== APP_ORIGIN) { + Logger.debug('ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(serializedMessage))); + return; + } + const messageType = typeof serializedMessage; + if (messageType !== 'string') { + Logger.error('unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); + return; + } let message; try { message = JSON.parse(serializedMessage); } catch (error) { - Logger.error('unserializable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); + Logger.error('unparsable message: ' + serializedMessage + ' | Error: ' + stringifyError(error)); return; } if (typeof message !== 'object') { From 13252a8948b3dbdf6a73877593e33f1f02f1fdfb Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 11 Nov 2024 10:17:55 +0300 Subject: [PATCH 12/14] message type checking --- packages/yoroi-extension/app/api/thunk.js | 12 +++++++++--- .../extension/background/subscriptionManager.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index b8516b9719..1eba037b8a 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -417,14 +417,20 @@ const callbacks = Object.freeze({ coinPriceUpdate: [], }); const APP_ORIGIN = window.location.origin || null; -chrome.runtime.onMessage.addListener((serializedMessage, { origin }, _sendResponse) => { +const EXPECTED_MESSAGE_TYPE = 'yoroi-emit-update'; +chrome.runtime.onMessage.addListener((rawMessage, { origin }, _sendResponse) => { if (APP_ORIGIN != null && origin !== APP_ORIGIN) { - Logger.debug('ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(serializedMessage))); + Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(rawMessage))); return; } + if (rawMessage.type !== EXPECTED_MESSAGE_TYPE) { + Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + return; + } + const serializedMessage = rawMessage.data; const messageType = typeof serializedMessage; if (messageType !== 'string') { - Logger.error('unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); + Logger.error('[client] unexpected message type (' + messageType + ') a JSON string is expected, but received: ' + JSON.stringify(sanitizeForLog(serializedMessage))); return; } let message; diff --git a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js index 6f87855b40..bd69ca4799 100644 --- a/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js +++ b/packages/yoroi-extension/chrome/extension/background/subscriptionManager.js @@ -68,6 +68,6 @@ declare var chrome; */ export function emitUpdateToSubscriptions(data: Object): void { for (const { tabId } of getSubscriptions()) { - chrome.tabs.sendMessage(tabId, JSON.stringify(data)); + chrome.tabs.sendMessage(tabId, { type: 'yoroi-emit-update', data: JSON.stringify(data) }); } } From 8d4f16d3f373ff6be009046a5e11a31763bb7d5b Mon Sep 17 00:00:00 2001 From: vantuz-subhuman Date: Mon, 11 Nov 2024 13:30:17 +0300 Subject: [PATCH 13/14] trace logging fix --- packages/yoroi-extension/app/api/thunk.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/yoroi-extension/app/api/thunk.js b/packages/yoroi-extension/app/api/thunk.js index 1eba037b8a..aab033a4cf 100644 --- a/packages/yoroi-extension/app/api/thunk.js +++ b/packages/yoroi-extension/app/api/thunk.js @@ -420,11 +420,11 @@ const APP_ORIGIN = window.location.origin || null; const EXPECTED_MESSAGE_TYPE = 'yoroi-emit-update'; chrome.runtime.onMessage.addListener((rawMessage, { origin }, _sendResponse) => { if (APP_ORIGIN != null && origin !== APP_ORIGIN) { - Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + Logger.debug('[client] ignoring non-origin message (' + origin + '/' + APP_ORIGIN + ')'); return; } if (rawMessage.type !== EXPECTED_MESSAGE_TYPE) { - Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + '):' + JSON.stringify(sanitizeForLog(rawMessage))); + Logger.debug('[client] ignoring unknown type message (' + rawMessage.type + '/' + EXPECTED_MESSAGE_TYPE + ')'); return; } const serializedMessage = rawMessage.data; From f6be6538601bed1f7985d66ddf7353c6c48b1525 Mon Sep 17 00:00:00 2001 From: yushi Date: Thu, 14 Nov 2024 16:15:19 +0800 Subject: [PATCH 14/14] fix ttl deserialization --- .../yoroi-extension/app/domain/CardanoShelleyTransaction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js index 4beaca3ff4..f4f3fa1322 100644 --- a/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js +++ b/packages/yoroi-extension/app/domain/CardanoShelleyTransaction.js @@ -219,7 +219,11 @@ export function deserializeTransactionCtorData( state: serializedData.state, errorMsg: serializedData.errorMsg, certificates: serializedData.certificates, - ttl: serializedData.ttl && new BigNumber(serializedData.ttl), + ttl: serializedData.ttl && new BigNumber( + typeof serializedData.ttl === 'object' + ? { ...serializedData.ttl, _isBigNumber: true } + : serializedData.ttl + ), metadata: serializedData.metadata, withdrawals: serializedData.withdrawals.map(({ address, value }) => ({ address,