diff --git a/src/components/TransactionHistory.tsx b/src/components/TransactionHistory.tsx index b40ca6b7..b4ba8810 100644 --- a/src/components/TransactionHistory.tsx +++ b/src/components/TransactionHistory.tsx @@ -83,14 +83,50 @@ export const TransactionHistory: React.FC = ({ isOpen, const fromAddress = signer.toString(); const isFromOurAccount = fromAddress === selectedAccount.address; + // Only track transactions from this account + if (!isFromOurAccount) { + return; + } + // Parse balances.transfer or balances.transferKeepAlive - if (method.section === 'balances' && + if (method.section === 'balances' && (method.method === 'transfer' || method.method === 'transferKeepAlive')) { const [dest, value] = method.args; - const toAddress = dest.toString(); - const isToOurAccount = toAddress === selectedAccount.address; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + to: dest.toString(), + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } - if (isFromOurAccount || isToOurAccount) { + // Parse assets.transfer (PEZ, USDT, etc.) + else if (method.section === 'assets' && method.method === 'transfer') { + const [assetId, dest, value] = method.args; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: `${method.method} (Asset ${assetId.toString()})`, + section: method.section, + from: fromAddress, + to: dest.toString(), + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } + + // Parse staking operations + else if (method.section === 'staking') { + if (method.method === 'bond' || method.method === 'bondExtra') { + const value = method.args[method.method === 'bond' ? 1 : 0]; txList.push({ blockNumber, extrinsicIndex: index, @@ -98,35 +134,93 @@ export const TransactionHistory: React.FC = ({ isOpen, method: method.method, section: method.section, from: fromAddress, - to: toAddress, amount: value.toString(), success: true, timestamp: timestamp, }); + } else if (method.method === 'unbond') { + const [value] = method.args; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } else if (method.method === 'nominate' || method.method === 'withdrawUnbonded' || method.method === 'chill') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + success: true, + timestamp: timestamp, + }); } } - // Parse assets.transfer (PEZ, USDT, etc.) - if (method.section === 'assets' && method.method === 'transfer') { - const [assetId, dest, value] = method.args; - const toAddress = dest.toString(); - const isToOurAccount = toAddress === selectedAccount.address; - - if (isFromOurAccount || isToOurAccount) { + // Parse DEX operations + else if (method.section === 'dex') { + if (method.method === 'swap') { + const [path, amountIn] = method.args; txList.push({ blockNumber, extrinsicIndex: index, hash: extrinsic.hash.toHex(), - method: `${method.method} (Asset ${assetId.toString()})`, + method: method.method, + section: method.section, + from: fromAddress, + amount: amountIn.toString(), + success: true, + timestamp: timestamp, + }); + } else if (method.method === 'addLiquidity' || method.method === 'removeLiquidity') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, section: method.section, from: fromAddress, - to: toAddress, - amount: value.toString(), success: true, timestamp: timestamp, }); } } + + // Parse stakingScore operations + else if (method.section === 'stakingScore' && method.method === 'startTracking') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + success: true, + timestamp: timestamp, + }); + } + + // Parse pezRewards operations + else if (method.section === 'pezRewards' && method.method === 'claimReward') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + success: true, + timestamp: timestamp, + }); + } }); } catch (blockError) { console.warn(`Error processing block #${blockNumber}:`, blockError); diff --git a/src/pages/WalletDashboard.tsx b/src/pages/WalletDashboard.tsx index b95fdbd7..ff870aeb 100644 --- a/src/pages/WalletDashboard.tsx +++ b/src/pages/WalletDashboard.tsx @@ -65,14 +65,48 @@ const WalletDashboard: React.FC = () => { const fromAddress = signer.toString(); const isFromOurAccount = fromAddress === selectedAccount.address; + // Only track this account's transactions + if (!isFromOurAccount) return; + // Parse balances.transfer if (method.section === 'balances' && (method.method === 'transfer' || method.method === 'transferKeepAlive')) { const [dest, value] = method.args; - const toAddress = dest.toString(); - const isToOurAccount = toAddress === selectedAccount.address; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + to: dest.toString(), + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } - if (isFromOurAccount || isToOurAccount) { + // Parse assets.transfer + else if (method.section === 'assets' && method.method === 'transfer') { + const [assetId, dest, value] = method.args; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: `${method.method} (Asset ${assetId.toString()})`, + section: method.section, + from: fromAddress, + to: dest.toString(), + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } + + // Parse staking operations + else if (method.section === 'staking') { + if (method.method === 'bond' || method.method === 'bondExtra') { + const value = method.args[method.method === 'bond' ? 1 : 0]; txList.push({ blockNumber, extrinsicIndex: index, @@ -80,35 +114,80 @@ const WalletDashboard: React.FC = () => { method: method.method, section: method.section, from: fromAddress, - to: toAddress, amount: value.toString(), success: true, timestamp: timestamp, }); + } else if (method.method === 'unbond') { + const [value] = method.args; + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + amount: value.toString(), + success: true, + timestamp: timestamp, + }); + } else if (method.method === 'nominate' || method.method === 'withdrawUnbonded' || method.method === 'chill') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + success: true, + timestamp: timestamp, + }); } } - // Parse assets.transfer - if (method.section === 'assets' && method.method === 'transfer') { - const [assetId, dest, value] = method.args; - const toAddress = dest.toString(); - const isToOurAccount = toAddress === selectedAccount.address; - - if (isFromOurAccount || isToOurAccount) { + // Parse DEX operations + else if (method.section === 'dex') { + if (method.method === 'swap') { + const [path, amountIn] = method.args; txList.push({ blockNumber, extrinsicIndex: index, hash: extrinsic.hash.toHex(), - method: `${method.method} (Asset ${assetId.toString()})`, + method: method.method, + section: method.section, + from: fromAddress, + amount: amountIn.toString(), + success: true, + timestamp: timestamp, + }); + } else if (method.method === 'addLiquidity' || method.method === 'removeLiquidity') { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, section: method.section, from: fromAddress, - to: toAddress, - amount: value.toString(), success: true, timestamp: timestamp, }); } } + + // Parse stakingScore & pezRewards + else if ((method.section === 'stakingScore' && method.method === 'startTracking') || + (method.section === 'pezRewards' && method.method === 'claimReward')) { + txList.push({ + blockNumber, + extrinsicIndex: index, + hash: extrinsic.hash.toHex(), + method: method.method, + section: method.section, + from: fromAddress, + success: true, + timestamp: timestamp, + }); + } }); } catch (blockError) { // Continue to next block