Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions packages/bridge-status-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Set the Solana tx signature as the `txHistory` key to support lookups by hash ([#6424](https://github.com/MetaMask/core/pull/6424))
- Read Completed swap properties from `txHistory` for consistency with bridge transactions ([#6424](https://github.com/MetaMask/core/pull/6424))

## [40.2.0]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ Object {
"destinationTokenDecimals": 18,
"destinationTokenSymbol": "ETH",
"hash": "signature",
"id": "test-uuid-1234",
"id": "signature",
"isBridgeTx": true,
"isSolana": true,
"networkClientId": "test-snap",
Expand All @@ -3132,7 +3132,7 @@ Object {

exports[`BridgeStatusController submitTx: Solana bridge should successfully submit a transaction 3`] = `
Object {
"bridgeTxMetaId": "test-uuid-1234",
"bridgeTxMetaId": "signature",
}
`;

Expand Down Expand Up @@ -3233,7 +3233,7 @@ Object {
"status": "PENDING",
},
"targetContractAddress": undefined,
"txMetaId": "test-uuid-1234",
"txMetaId": "signature",
}
`;

Expand Down Expand Up @@ -3439,7 +3439,7 @@ Object {
"destinationTokenDecimals": 18,
"destinationTokenSymbol": "USDC",
"hash": "signature",
"id": "test-uuid-1234",
"id": "signature",
"isBridgeTx": false,
"isSolana": true,
"networkClientId": "test-snap",
Expand Down Expand Up @@ -3554,7 +3554,7 @@ Object {
"status": "PENDING",
},
"targetContractAddress": undefined,
"txMetaId": "test-uuid-1234",
"txMetaId": "signature",
}
`;

Expand Down Expand Up @@ -3681,7 +3681,6 @@ Array [
"chain_id_source": "eip155:42161",
"custom_slippage": true,
"destination_transaction": "PENDING",
"error_message": undefined,
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -3727,7 +3726,7 @@ Array [
"chain_id_source": "eip155:42161",
"custom_slippage": true,
"destination_transaction": "FAILED",
"error_message": undefined,
"error_message": "",
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -3763,7 +3762,7 @@ Array [
"chain_id_destination": "eip155:42161",
"chain_id_source": "eip155:42161",
"custom_slippage": false,
"error_message": undefined,
"error_message": "",
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -3799,7 +3798,7 @@ Array [
"chain_id_destination": "eip155:42161",
"chain_id_source": "eip155:42161",
"custom_slippage": false,
"error_message": undefined,
"error_message": "",
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -3846,7 +3845,7 @@ Array [
"chain_id_source": "eip155:42161",
"custom_slippage": true,
"destination_transaction": "FAILED",
"error_message": undefined,
"error_message": "",
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down Expand Up @@ -3883,7 +3882,7 @@ Array [
"chain_id_destination": "eip155:42161",
"chain_id_source": "eip155:42161",
"custom_slippage": false,
"error_message": undefined,
"error_message": "",
"gas_included": false,
"is_hardware_wallet": false,
"price_impact": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export class BridgeStatusController extends StaticIntervalPollingController<Brid
this.#trackUnifiedSwapBridgeEvent(
UnifiedSwapBridgeEventName.Completed,
id,
getEVMTxPropertiesFromTransactionMeta(transactionMeta),
);
}
if (type === TransactionType.bridge && !isSolanaChainId(chainId)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-status-controller/src/utils/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ describe('metrics utils', () => {
it('should return correct properties for a successful swap transaction', () => {
const result = getEVMTxPropertiesFromTransactionMeta(mockTransactionMeta);
expect(result).toStrictEqual({
error_message: undefined,
error_message: '',
chain_id_source: 'eip155:1',
chain_id_destination: 'eip155:1',
token_symbol_source: 'ETH',
Expand Down Expand Up @@ -1027,7 +1027,7 @@ describe('metrics utils', () => {
const result = getEVMTxPropertiesFromTransactionMeta(
failedTransactionMeta,
);
expect(result.error_message).toBe('Failed to finalize swap tx');
expect(result.error_message).toBe('Transaction failed');
expect(result.source_transaction).toBe('FAILED');
});

Expand Down
4 changes: 1 addition & 3 deletions packages/bridge-status-controller/src/utils/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ export const getEVMTxPropertiesFromTransactionMeta = (
].includes(transactionMeta.status)
? StatusTypes.FAILED
: StatusTypes.COMPLETE,
error_message: transactionMeta.error?.message
? 'Failed to finalize swap tx'
: undefined,
error_message: transactionMeta.error?.message ?? '',
chain_id_source: formatChainIdToCaip(transactionMeta.chainId),
chain_id_destination: formatChainIdToCaip(transactionMeta.chainId),
token_symbol_source: transactionMeta.sourceTokenSymbol ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const handleSolanaTxResponse = (
return {
...getTxMetaFields(quoteResponse),
time: Date.now(),
id: uuid(),
id: hash ?? uuid(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Transaction ID Collision Risk

The change to id: hash ?? uuid() can result in empty string transaction IDs. The nullish coalescing operator (??) only falls back to uuid() if hash is null or undefined, not if it's an empty string. This could cause multiple transactions to share an empty ID, leading to lookup and tracking issues.

Fix in Cursor Fix in Web

chainId: hexChainId,
networkClientId: snapId ?? hexChainId,
txParams: { from: selectedAccountAddress, data: quoteResponse.trade },
Expand Down
Loading