Skip to content

refactor: multichain activity tab #31439

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

Merged
merged 17 commits into from
Apr 1, 2025
Merged
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/images/bitcoin-testnet-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion shared/constants/multichain/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type MultichainProviderConfig = ProviderConfigWithImageUrl & {
// NOTE: For now we use a callback to check if the address is compatible with
// the given network or not
isAddressCompatible: (address: string) => boolean;
decimals: number;
};

export type MultichainNetworkIds = `${MultichainNetworks}`;
Expand Down Expand Up @@ -55,6 +56,8 @@ export const MULTICHAIN_NETWORK_TO_NICKNAME: Record<CaipChainId, string> = {
};

export const BITCOIN_TOKEN_IMAGE_URL = './images/bitcoin-logo.svg';
export const BITCOIN_TESTNET_TOKEN_IMAGE_URL =
'./images/bitcoin-testnet-logo.svg';
export const SOLANA_TOKEN_IMAGE_URL = './images/solana-logo.svg';

export const BITCOIN_BLOCK_EXPLORER_URL = 'https://mempool.space';
Expand Down Expand Up @@ -94,6 +97,7 @@ export const MULTICHAIN_NETWORK_BLOCK_EXPLORER_FORMAT_URLS_MAP: Record<

export const MULTICHAIN_TOKEN_IMAGE_MAP: Record<CaipChainId, string> = {
[MultichainNetworks.BITCOIN]: BITCOIN_TOKEN_IMAGE_URL,
[MultichainNetworks.BITCOIN_TESTNET]: BITCOIN_TESTNET_TOKEN_IMAGE_URL,
[MultichainNetworks.SOLANA]: SOLANA_TOKEN_IMAGE_URL,
} as const;

Expand All @@ -111,6 +115,7 @@ export const MULTICHAIN_PROVIDER_CONFIGS: Record<
nickname: 'Bitcoin',
id: 'btc-mainnet',
type: 'rpc',
decimals: 8,
rpcPrefs: {
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.BITCOIN],
blockExplorerUrl:
Expand All @@ -131,8 +136,9 @@ export const MULTICHAIN_PROVIDER_CONFIGS: Record<
nickname: 'Bitcoin (testnet)',
id: 'btc-testnet',
type: 'rpc',
decimals: 8,
rpcPrefs: {
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.BITCOIN],
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.BITCOIN_TESTNET],
blockExplorerUrl:
MULTICHAIN_NETWORK_BLOCK_EXPLORER_FORMAT_URLS_MAP[
MultichainNetworks.BITCOIN_TESTNET
Expand All @@ -154,6 +160,7 @@ export const MULTICHAIN_PROVIDER_CONFIGS: Record<
nickname: 'Solana',
id: 'solana-mainnet',
type: 'rpc',
decimals: 5,
rpcPrefs: {
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.SOLANA],
blockExplorerUrl:
Expand All @@ -174,6 +181,7 @@ export const MULTICHAIN_PROVIDER_CONFIGS: Record<
nickname: 'Solana (devnet)',
id: 'solana-devnet',
type: 'rpc',
decimals: 5,
rpcPrefs: {
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.SOLANA],
blockExplorerUrl:
Expand All @@ -194,6 +202,7 @@ export const MULTICHAIN_PROVIDER_CONFIGS: Record<
nickname: 'Solana (testnet)',
id: 'solana-testnet',
type: 'rpc',
decimals: 5,
rpcPrefs: {
imageUrl: MULTICHAIN_TOKEN_IMAGE_MAP[MultichainNetworks.SOLANA],
blockExplorerUrl:
Expand Down
4 changes: 4 additions & 0 deletions shared/constants/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export enum TransactionGroupCategory {
* where the final token is sent to another chain.
*/
bridge = 'bridge',
/**
* Transaction group representing a redeposit (a send to ourselves), mainly used for consolidation.
*/
redeposit = 'redeposit',
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,57 @@ export default {
};

const mockTransaction = {
type: 'Send BTC',
status: 'Confirmed',
type: 'send',
status: 'confirmed',
timestamp: new Date('Sep 30 2023 12:56').getTime(),
id: 'b93ea2cb4eed0f9e13284ed8860bcfc45de2488bb6a8b0b2a843c4b2fbce40f3',
from: [{
address: "bc1p7atgm33ak04ntsq9366mvym42ecrk4y34ssysc99340a39eq9arq0pu9uj",
asset: {
amount: '1.2',
unit: 'BTC',
}
}],
to: [{
address: "bc1p3t7744qewy262ym5afgeuqlwswtpfe22y7c4lwv0a7972p2k73msee7rr3",
asset: {
amount: '1.2',
unit: 'BTC',
}
}],
fees: [{
type: 'base',
asset: {
amount: '1.0001',
unit: 'BTC',
}
}]
chain: 'bip122:000000000019d6689c085ae165831e93',
account: 'test-account-id',
from: [
{
address: 'bc1p7atgm33ak04ntsq9366mvym42ecrk4y34ssysc99340a39eq9arq0pu9uj',
asset: {
amount: '1.2',
unit: 'BTC',
fungible: true,
},
},
],
to: [
{
address: 'bc1p3t7744qewy262ym5afgeuqlwswtpfe22y7c4lwv0a7972p2k73msee7rr3',
asset: {
amount: '1.2',
unit: 'BTC',
fungible: true,
},
},
],
fees: [
{
type: 'priority',
asset: {
amount: '1.0001',
unit: 'BTC',
fungible: true,
},
},
],
};

export const Default = {
args: {
transaction: mockTransaction,
onClose: () => console.log('Modal closed'),
multichainNetwork: {
userAddress:
'bc1p7atgm33ak04ntsq9366mvym42ecrk4y34ssysc99340a39eq9arq0pu9uj',
networkConfig: {
nickname: 'Bitcoin',
isEvmNetwork: false,
chainId: 'bip122:000000000019d6689c085ae165831e93',
network: {
chainId: 'bip122:000000000019d6689c085ae165831e93',
ticker: 'BTC',
},
decimals: 8,
ticker: 'BTC',
id: 'btc-mainnet',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { renderWithProvider } from '../../../../test/lib/render-helpers';
import { MOCK_ACCOUNT_SOLANA_MAINNET } from '../../../../test/data/mock-accounts';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MULTICHAIN_PROVIDER_CONFIGS,
MultichainNetworks,
MultichainProviderConfig,
SOLANA_BLOCK_EXPLORER_URL,
} from '../../../../shared/constants/multichain/networks';
import mockState from '../../../../test/data/mock-state.json';
Expand Down Expand Up @@ -117,6 +119,7 @@ const mockProps = {
transaction: mockTransaction,
onClose: jest.fn(),
userAddress: MOCK_ACCOUNT_SOLANA_MAINNET.address,
networkConfig: MULTICHAIN_PROVIDER_CONFIGS[MultichainNetworks.BITCOIN],
};

describe('MultichainTransactionDetailsModal', () => {
Expand All @@ -136,6 +139,7 @@ describe('MultichainTransactionDetailsModal', () => {
transaction: Transaction;
onClose: jest.Mock;
userAddress: string;
networkConfig: MultichainProviderConfig;
} = mockProps,
) => {
const store = configureStore(mockState.metamask);
Expand Down Expand Up @@ -299,13 +303,14 @@ describe('MultichainTransactionDetailsModal', () => {
transaction: mockSwapTransaction,
onClose: jest.fn(),
userAddress,
networkConfig: MULTICHAIN_PROVIDER_CONFIGS[MultichainNetworks.SOLANA],
};

renderComponent(swapProps);

expect(screen.getByText('Swap')).toBeInTheDocument();
expect(screen.getByTestId('transaction-amount')).toHaveTextContent(
'2.5 SOL',
'100 USDC',
);

const addressStart = userAddress.substring(0, 6);
Expand Down
Loading
Loading