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
59 changes: 58 additions & 1 deletion app/components/UI/Bridge/_mocks_/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
SolAccountType,
BtcScope,
BtcAccountType,
TrxScope,
TrxAccountType,
} from '@metamask/keyring-api';
import { AccountWalletType, AccountGroupType } from '@metamask/account-api';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -53,6 +55,11 @@ export const solanaToken2Address =
export const btcNativeTokenAddress =
'bip122:000000000019d6689c085ae165831e93/slip44:0' as CaipAssetId;

// Tron account and tokens
export const trxAccountId = 'trxAccountId';
export const trxAccountAddress = 'TN3W4Bb1JVHPiWJVm7d9q9qHGXSdoMrMrE';
export const trxNativeTokenAddress = 'tron:728126428/slip44:195' as CaipAssetId;

export const initialState = {
engine: {
backgroundState: {
Expand Down Expand Up @@ -100,6 +107,11 @@ export const initialState = {
isActiveDest: true,
isGaslessSwapEnabled: false,
},
[TrxScope.Mainnet]: {
isActiveSrc: true,
isActiveDest: true,
isGaslessSwapEnabled: false,
},
},
bip44DefaultPairs: {
bip122: {
Expand Down Expand Up @@ -259,6 +271,12 @@ export const initialState = {
'bip122:000000000019d6689c085ae165831e93/slip44:0' as const,
isEvm: false as const,
},
[TrxScope.Mainnet]: {
chainId: TrxScope.Mainnet,
name: 'Tron',
nativeCurrency: 'tron:728126428/slip44:195' as const,
isEvm: false as const,
},
},
},
MultichainBalancesController: {
Expand All @@ -279,12 +297,19 @@ export const initialState = {
unit: 'BTC',
},
},
[trxAccountId]: {
[trxNativeTokenAddress]: {
amount: '500',
unit: 'TRX',
},
},
},
},
MultichainAssetsController: {
accountsAssets: {
[solanaAccountId]: [solanaNativeTokenAddress, solanaToken2Address],
[btcAccountId]: [btcNativeTokenAddress],
[trxAccountId]: [trxNativeTokenAddress],
},
assetsMetadata: {
[btcNativeTokenAddress]: {
Expand Down Expand Up @@ -348,6 +373,19 @@ export const initialState = {
},
],
},
[trxNativeTokenAddress]: {
name: 'Tron',
symbol: 'TRX',
iconUrl: 'https://tron.network/static/images/logo.png',
fungible: true as const,
units: [
{
name: 'Tron',
symbol: 'TRX',
decimals: 6,
},
],
},
},
},
MultichainAssetsRatesController: {
Expand All @@ -364,6 +402,10 @@ export const initialState = {
rate: '100000', // 1 BTC = 100000 USD
conversionTime: 0,
},
[trxNativeTokenAddress]: {
rate: '0.10', // 1 TRX = 0.10 USD
conversionTime: 0,
},
},
},
AccountsController: {
Expand Down Expand Up @@ -400,6 +442,16 @@ export const initialState = {
lastSelected: 0,
},
},
[trxAccountId]: {
id: trxAccountId,
address: trxAccountAddress,
name: 'Account 4',
type: TrxAccountType.Eoa,
scopes: [TrxScope.Mainnet],
metadata: {
lastSelected: 0,
},
},
},
},
},
Expand Down Expand Up @@ -428,7 +480,12 @@ export const initialState = {
groupIndex: 0,
},
},
accounts: [evmAccountId, solanaAccountId, btcAccountId],
accounts: [
evmAccountId,
solanaAccountId,
btcAccountId,
trxAccountId,
],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,112 @@ exports[`BridgeDestNetworkSelector renders with initial state and displays netwo
</View>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={[Function]}
>
<View
accessibilityRole="none"
accessible={true}
style={
{
"padding": 16,
}
}
>
<View
style={
{
"alignItems": "center",
"flexDirection": "row",
}
}
>
<View
alignItems="center"
flexDirection="row"
style={
[
{
"alignItems": "center",
"flexDirection": "row",
},
{
"flex": 1,
},
]
}
>
<View
alignItems="center"
flexDirection="row"
gap={8}
style={
[
{
"alignItems": "center",
"flexDirection": "row",
"gap": 8,
},
{
"flex": 1,
},
]
}
>
<View
style={
{
"alignItems": "center",
"backgroundColor": "#ffffff",
"borderRadius": 8,
"height": 32,
"justifyContent": "center",
"overflow": "hidden",
"width": 32,
}
}
>
<Image
onError={[Function]}
resizeMode="contain"
source={1}
style={
{
"height": 32,
"width": 32,
}
}
testID="network-avatar-image"
/>
</View>
<View
style={
[
{},
undefined,
]
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#121314",
"fontFamily": "Geist Medium",
"fontSize": 18,
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
Tron
</Text>
</View>
</View>
</View>
</View>
</View>
</TouchableOpacity>
<TouchableOpacity
onPress={[Function]}
>
Expand Down
21 changes: 11 additions & 10 deletions app/components/UI/Bridge/components/BridgeDestNetworksBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { selectChainId } from '../../../../selectors/networkController';
// Using ScrollView from react-native-gesture-handler to fix scroll issues with the bottom sheet
import { ScrollView } from 'react-native-gesture-handler';
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import { BtcScope, SolScope } from '@metamask/keyring-api';
import { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';
import { BridgeViewMode } from '../types';
///: END:ONLY_INCLUDE_IF
const createStyles = (params: { theme: Theme }) => {
Expand Down Expand Up @@ -69,16 +69,17 @@ export const ChainPopularity: Record<Hex | CaipChainId, number> = {
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
[BtcScope.Mainnet]: 3,
[SolScope.Mainnet]: 4,
[TrxScope.Mainnet]: 5,
///: END:ONLY_INCLUDE_IF
[CHAIN_IDS.BASE]: 5,
[CHAIN_IDS.ARBITRUM]: 6,
[CHAIN_IDS.LINEA_MAINNET]: 7,
[CHAIN_IDS.POLYGON]: 8,
[CHAIN_IDS.AVALANCHE]: 9,
[CHAIN_IDS.OPTIMISM]: 10,
[CHAIN_IDS.ZKSYNC_ERA]: 11,
[NETWORKS_CHAIN_ID.SEI]: 12,
[NETWORKS_CHAIN_ID.MONAD]: 13,
[CHAIN_IDS.BASE]: 6,
[CHAIN_IDS.ARBITRUM]: 7,
[CHAIN_IDS.LINEA_MAINNET]: 8,
[CHAIN_IDS.POLYGON]: 9,
[CHAIN_IDS.AVALANCHE]: 10,
[CHAIN_IDS.OPTIMISM]: 11,
[CHAIN_IDS.ZKSYNC_ERA]: 12,
[NETWORKS_CHAIN_ID.SEI]: 13,
[NETWORKS_CHAIN_ID.MONAD]: 14,
};

export const BridgeDestNetworksBar = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,60 @@ exports[`BridgeDestTokenSelector renders with initial state and displays tokens
</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
{
"alignItems": "center",
"alignSelf": "flex-start",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc866",
"borderRadius": 10,
"borderWidth": 1,
"flexDirection": "row",
"height": 40,
"justifyContent": "center",
"overflow": "hidden",
"paddingHorizontal": 16,
}
}
>
<View
alignItems="center"
flexDirection="row"
gap={8}
style={
[
{
"alignItems": "center",
"flexDirection": "row",
"gap": 8,
},
undefined,
]
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#121314",
"fontFamily": "Geist Regular",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
Tron
</Text>
</View>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BridgeSourceNetworkSelectorSelectorsIDs } from '../../../../../../e2e/s
import { cloneDeep } from 'lodash';
import { MultichainNetwork } from '@metamask/multichain-transactions-controller';
import { CHAIN_IDS } from '@metamask/transaction-controller';
import { BtcScope, SolScope } from '@metamask/keyring-api';
import { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';

const mockNavigate = jest.fn();
const mockGoBack = jest.fn();
Expand Down Expand Up @@ -180,6 +180,7 @@ describe('BridgeSourceNetworkSelector', () => {
optimismChainId,
SolScope.Mainnet,
BtcScope.Mainnet,
TrxScope.Mainnet,
]);

// Should navigate back
Expand Down
Loading
Loading