Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

481-bug-link-to-flowscan-broken #482

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/background/service/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { TransactionStatus } from '@onflow/typedefs';
import { ConcatenationScope } from 'webpack';

import { isValidEthereumAddress } from '@/shared/utils/address';
import createPersistStore from 'background/utils/persisitStore';
import createSessionStore from 'background/utils/sessionStore';

Expand Down Expand Up @@ -157,9 +155,10 @@ class Transaction {
updatePending = (txId: string, network: string, transactionStatus: TransactionStatus): string => {
const txList = this.session.pendingItem[network];
const txItemIndex = txList.findIndex((item) => item.hash.includes(txId));
let combinedTxHash = txId;
if (txItemIndex === -1) {
// txItem not found, return
return txId;
return combinedTxHash;
}
const txItem = txList[txItemIndex];

Expand All @@ -169,7 +168,6 @@ class Transaction {

const evmTxIds: string[] = transactionStatus.events?.reduce(
(transactionIds: string[], event) => {
console.log('event', event);
if (event.type.includes('EVM') && !!event.data?.hash) {
const hashBytes = event.data.hash.map((byte) => parseInt(byte));
const hash = '0x' + Buffer.from(hashBytes).toString('hex');
Expand All @@ -182,7 +180,6 @@ class Transaction {
},
[] as string[]
);
console.log('evmTxIds', evmTxIds);
txItem.evmTxIds = [...evmTxIds];

if (evmTxIds.length > 0) {
Expand All @@ -191,25 +188,28 @@ class Transaction {
// TODO: Check there aren't 100s of evmTxIds
console.warn('updatePending - evmTxIds.length > 10', evmTxIds);
}
txItem.hash = `${txItem.cadenceTxId || txItem.hash}_${evmTxIds.join('_')}`;
combinedTxHash = `${txItem.cadenceTxId || txItem.hash}_${evmTxIds.join('_')}`;
}
console.log('txItem', txItem);
txList[txItemIndex] = txItem;

this.session.pendingItem[network] = [...txList];
// Send a message to the UI to update the transfer list
chrome.runtime.sendMessage({ msg: 'transferListUpdated' });

// Return the hash of the transaction
return txItem.hash;
return combinedTxHash;
};

removePending = (txId: string, address: string, network: string) => {
const txList = this.session.pendingItem[network];
const newList = txList.filter((item) => {
// Supports hashes with multiple ids
// e.g. cadenceTxId_evmTxId
return !item.hash.includes(txId);
return (
!item.hash.includes(txId) &&
!item.cadenceTxId?.includes(txId) &&
!item.evmTxIds?.includes(txId)
);
});
this.session.pendingItem[network] = [...newList];
};
Expand Down
6 changes: 3 additions & 3 deletions src/ui/views/Wallet/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const TransferList = () => {
fetchTransactions();
const handler = (req) => {
if (req.msg === 'transferListUpdated') {
console.log('Transfer list updated');
fetchTransactions();
}
return true;
Expand Down Expand Up @@ -180,10 +179,11 @@ const TransferList = () => {
<>
{' '}
{(transactions || []).map((tx) => {
const txCombinedKey = `${tx.cadenceTxId || tx.hash}${tx.evmTxIds ? `_${tx.evmTxIds.join('_')}` : ''}_${tx.interaction}`;
return (
<ListItem
key={`${tx.hash}_${tx.interaction}`}
data-testid={`${tx.hash}_${tx.interaction}`}
key={txCombinedKey}
data-testid={txCombinedKey}
secondaryAction={
<EndListItemText
status={tx.status}
Expand Down