From a12d4b8fe3d8066d0bbfdf5d54abb03d4a3b2328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=89=E5=92=8F?= Date: Wed, 20 Jul 2022 12:37:27 +0800 Subject: [PATCH 1/2] fix: fixed error for 'GET_DECODED_TRANSACTION_INPUT' when the 'transaction.input' was '0x' --- .../common/redux/transactions/actions.js | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/integrations/ethereum/common/redux/transactions/actions.js b/src/integrations/ethereum/common/redux/transactions/actions.js index f1bcce4da..a6c8ca3c9 100644 --- a/src/integrations/ethereum/common/redux/transactions/actions.js +++ b/src/integrations/ethereum/common/redux/transactions/actions.js @@ -136,8 +136,8 @@ export const showTransaction = function(hash) { web3Instance, ); let events = []; - let decodedData = null; - + let decodedData; + let contract; let projectIndex; const state = getState(); @@ -157,6 +157,7 @@ export const showTransaction = function(hash) { } } + // I was going to use the blocks inView here by just dispatching `requestPage` // from the blocks redux, but that gets cleared and doesnt work well, so I'm // doing it the dirty and brute force way @@ -193,6 +194,8 @@ export const showTransaction = function(hash) { } } + + if (contract) { for (let j = 0; j < events.length; j++) { events[j].decodedLog = await new Promise(resolve => { @@ -209,21 +212,23 @@ export const showTransaction = function(hash) { }); } - decodedData = await new Promise(resolve => { - // TODO: there's a better way to do this to not have to send `contract` and `contracts` every time - ipcRenderer.once( - GET_DECODED_TRANSACTION_INPUT, - (event, decodedData) => { - resolve(decodedData); - }, - ); - ipcRenderer.send( - GET_DECODED_TRANSACTION_INPUT, - contract, - state.workspaces.current.projects[projectIndex].contracts, - transaction, - ); - }); + if (transaction.input !== '0x') { + decodedData = await new Promise(resolve => { + //TODO: there's a better way to do this to not have to send `contract` and `contracts` every time + ipcRenderer.once( + GET_DECODED_TRANSACTION_INPUT, + (event, decodedData) => { + resolve(decodedData); + }, + ); + ipcRenderer.send( + GET_DECODED_TRANSACTION_INPUT, + contract, + state.workspaces.current.projects[projectIndex].contracts, + transaction, + ); + }); + } } dispatch({ From 982cc8060a2e4dab88840caff836dae1d995c34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=93=89=E5=92=8F?= Date: Wed, 20 Jul 2022 17:17:49 +0800 Subject: [PATCH 2/2] style: format code --- src/integrations/ethereum/common/redux/transactions/actions.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/integrations/ethereum/common/redux/transactions/actions.js b/src/integrations/ethereum/common/redux/transactions/actions.js index a6c8ca3c9..0423fc177 100644 --- a/src/integrations/ethereum/common/redux/transactions/actions.js +++ b/src/integrations/ethereum/common/redux/transactions/actions.js @@ -157,7 +157,6 @@ export const showTransaction = function(hash) { } } - // I was going to use the blocks inView here by just dispatching `requestPage` // from the blocks redux, but that gets cleared and doesnt work well, so I'm // doing it the dirty and brute force way @@ -193,8 +192,6 @@ export const showTransaction = function(hash) { }); } } - - if (contract) { for (let j = 0; j < events.length; j++) {