diff --git a/scripts/post-build.js b/scripts/post-build.js index ab0a039..f9cb3ba 100644 --- a/scripts/post-build.js +++ b/scripts/post-build.js @@ -73,7 +73,7 @@ async function writeManifestFile(targetPath, fileContent) { (async () => { try { - const id = "1019"; + const id = "1020"; const chromeFileName = `${pck.name}-chrome-edge-${pck.version}-${id}`; const firefoxFileName = `${pck.name}-firefox-${pck.version}-${id}`; diff --git a/src/popup/pages/Wallet/component/TxListView/index.js b/src/popup/pages/Wallet/component/TxListView/index.js index bdd6a4e..03d0ea5 100644 --- a/src/popup/pages/Wallet/component/TxListView/index.js +++ b/src/popup/pages/Wallet/component/TxListView/index.js @@ -471,8 +471,13 @@ const TxItem = ({ amount = getBalanceForUI(result.totalBalanceChange, MAIN_COIN_CONFIG.decimals, 2); amount = result.symbol + amount; - let isZkReceive = result.symbol !== "-" - showAddress = isZkReceive ? addressSlice(result.from, 8):addressSlice(result.to, 8) + if(result.symbol == "-"){ + showAddress = addressSlice(result.to, 8) + }else if(result.symbol == "+"){ + showAddress = addressSlice(result.from, 8) + }else{ + showAddress = addressSlice(result.to, 8) + } } } if (!showAddress) { diff --git a/src/utils/zkUtils.js b/src/utils/zkUtils.js index 8ebee4f..48caf0a 100644 --- a/src/utils/zkUtils.js +++ b/src/utils/zkUtils.js @@ -315,10 +315,10 @@ export function getZkAppUpdateInfo(accountUpdates, publicKey, tokenId) { let otherList = []; accountUpdates.forEach((update) => { const { body } = update; + const magnitude = new BigNumber(body.balanceChange.magnitude) + .abs() + .toString(); if (body.tokenId === tokenId) { - const magnitude = new BigNumber(body.balanceChange.magnitude) - .abs() - .toString(); if (body.publicKey === publicKey) { if (body.balanceChange.sgn === "Negative") { totalBalanceChange = new BigNumber(totalBalanceChange) @@ -330,34 +330,49 @@ export function getZkAppUpdateInfo(accountUpdates, publicKey, tokenId) { .toString(); } } else { - updateList.push({ - address: body.publicKey, - amount: magnitude, - }); + if (!new BigNumber(magnitude).isZero()) { + updateList.push({ + address: body.publicKey, + amount: magnitude, + }); + } } } if (body.publicKey !== publicKey) { - otherList.push(body.publicKey); + otherList.push({ + address: body.publicKey, + amount: magnitude, + }); } }); if (updateList.length !== 0) { updateList.sort((a, b) => b.amount - a.amount); } + if (otherList.length !== 0) { + otherList.sort((a, b) => b.amount - a.amount); + } let symbol = ""; let from = ""; let to = ""; + if (totalBalanceChange > 0) { symbol = "+"; - - from = updateList.length > 0 ? updateList[0].address : otherList[0]; + from = + updateList.length > 0 ? updateList[0].address : otherList[0]?.address; to = publicKey; } else if (totalBalanceChange < 0) { symbol = "-"; totalBalanceChange = new BigNumber(totalBalanceChange).abs().toString(); from = publicKey; - to = updateList.length > 0 ? updateList[0].address : otherList[0]; + to = + updateList.length > 0 ? updateList[0].address : otherList[0]?.address; + } else { + to = + updateList.length > 0 ? updateList[0].address : otherList[0]?.address; + from = publicKey; } + return { totalBalanceChange, symbol, @@ -374,4 +389,4 @@ export function getZkAppUpdateInfo(accountUpdates, publicKey, tokenId) { to: "-", }; } -} \ No newline at end of file +}