Skip to content

Commit

Permalink
token integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Yunkevich committed May 16, 2024
1 parent 55eed18 commit b7385d7
Show file tree
Hide file tree
Showing 18 changed files with 1,148 additions and 50 deletions.
117 changes: 114 additions & 3 deletions BlueComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ export const BlueListItem = React.memo((props) => {

return (
<ListItem containerStyle={props.containerStyle ?? { backgroundColor: 'transparent' }} Component={props.Component ?? TouchableOpacity} bottomDivider={props.bottomDivider !== undefined ? props.bottomDivider : true} topDivider={props.topDivider !== undefined ? props.topDivider : false} testID={props.testID} onPress={props.onPress} onLongPress={props.onLongPress} disabled={props.disabled} accessible={props.switch === undefined}>
{props.leftAvatar && <Avatar>{props.leftAvatar}</Avatar>}
{props.leftAvatar && <Avatar {...props.leftAvatarProps}>{props.leftAvatar}</Avatar>}
{props.leftIcon && <Avatar icon={props.leftIcon} />}
<ListItem.Content>
<ListItem.Content style={props.contentStyle}>
<ListItem.Title
style={{
color: props.disabled ? colors.buttonDisabledTextColor : colors.foregroundColor,
Expand Down Expand Up @@ -434,10 +434,25 @@ export const BlueListItem = React.memo((props) => {
)}
</ListItem.Content>
{props.rightTitle && (
<ListItem.Content right>
<ListItem.Content right style={props.rightContentStyle}>
<ListItem.Title style={props.rightTitleStyle} numberOfLines={0} right>
{props.rightTitle}
</ListItem.Title>
{props.rightSubtitle && (
<ListItem.Subtitle
numberOfLines={props.subtitleNumberOfLines ?? 1}
accessible={props.switch === undefined}
style={{
flexWrap: 'wrap',
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
color: colors.alternativeTextColor,
fontWeight: '400',
fontSize: 14,
}}
>
{props.rightSubtitle}
</ListItem.Subtitle>
)}
</ListItem.Content>
)}
{props.isLoading ? (
Expand Down Expand Up @@ -952,6 +967,102 @@ export const BlueTransactionOnchainIcon = (props) => {
);
};

export const MlCoinLogo = () => {
const { colors } = useTheme();
const stylesMlLogoHooks = StyleSheet.create({
img: {
tintColor: colors.inverseForegroundColor,
},
imgContainer: {
backgroundColor: colors.buttonBackgroundColor,
},
});
return (
<View>
<View style={[stylesMlLogo.imgContainer, stylesMlLogoHooks.imgContainer]}>
<Image source={create_wallet} style={[stylesMlLogo.img, stylesMlLogoHooks.img]} />
</View>
</View>
);
};

const stylesMlLogo = StyleSheet.create({
imgContainer: {
height: 42,
width: 42,
borderRadius: 50,
alignItems: 'center',
justifyContent: 'center',
},
img: {
height: 20,
width: 20,
},
});

export const TokenLogo = ({ text }) => {
const { colors } = useTheme();
const stylesTokenLogoHooks = StyleSheet.create({
container: {
backgroundColor: colors.buttonBackgroundColor,
},
text: {
color: colors.inverseForegroundColor,
},
img: {
backgroundColor: colors.buttonBackgroundColor,
tintColor: colors.inverseForegroundColor,
},
imgContainer: {
backgroundColor: colors.buttonBackgroundColor,
borderColor: colors.inverseForegroundColor,
tintColor: colors.inverseForegroundColor,
},
});
return (
<View>
<View style={[stylesTokenLogo.container, stylesTokenLogoHooks.container]}>
<Text style={[stylesTokenLogo.text, stylesTokenLogoHooks.text]}>{text}</Text>
<View style={[stylesTokenLogo.imgContainer, stylesTokenLogoHooks.imgContainer]}>
<Image source={create_wallet} style={[stylesTokenLogo.img, stylesTokenLogoHooks.img]} />
</View>
</View>
</View>
);
};

const stylesTokenLogo = StyleSheet.create({
container: {
position: 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: 42,
width: 42,
borderRadius: 50,
},
text: {
textTransform: 'uppercase',
fontSize: 16,
fontWeight: 'bold',
},
imgContainer: {
alignItems: 'center',
justifyContent: 'center',
position: 'absolute',
right: -5,
bottom: -5,
height: 20,
width: 20,
borderRadius: 50,
borderWidth: 2,
},
img: {
height: 8,
width: 8,
},
});

export const BlueTransactionOffchainIcon = (props) => {
const { colors } = useTheme();
const stylesBlueIconHooks = StyleSheet.create({
Expand Down
35 changes: 34 additions & 1 deletion Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { createNativeStackNavigator } from 'react-native-screens/native-stack';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { Platform, useWindowDimensions, Dimensions, I18nManager, Image, StyleSheet, View, Text, Touchable, TouchableOpacity } from 'react-native';
import { useTheme } from '@react-navigation/native';
import { useRoute, useTheme } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';

import Settings from './screen/settings/settings';
import About from './screen/settings/about';
Expand All @@ -26,6 +27,9 @@ import TestMode from './screen/settings/testmode';

import WalletsList from './screen/wallets/list';
import WalletTransactions from './screen/wallets/transactions';
import WalletTransactionsHeader from './screen/wallets/transactions-header';
import MLWalletTransactions from './screen/wallets/ml-transactions';
import MLWalletTokens from './screen/wallets/ml-tokens';
import AddWallet from './screen/wallets/add';
import WalletsAddMultisig from './screen/wallets/addMultisig';
import WalletsAddMultisigStep2 from './screen/wallets/addMultisigStep2';
Expand Down Expand Up @@ -535,6 +539,31 @@ const BottomTab = () => {
);
};

const TopTab = createMaterialTopTabNavigator();

function MlWalletRoot() {
const { walletID } = useRoute().params;
const { colors } = useTheme();
const tabBarOptions = {
labelStyle: { fontSize: 18, fontWeight: 'bold', textTransform: 'none' },
indicatorStyle: { backgroundColor: colors.mainColor },
activeTintColor: colors.foregroundColor,
tabStyle: { padding: 2 },
style: { marginTop: 8, marginHorizontal: 16, elevation: 0 },
pressColor: colors.background,
};

return (
<View style={styles.flex}>
<WalletTransactionsHeader />
<TopTab.Navigator tabBarOptions={tabBarOptions}>
<TopTab.Screen name="Transactions" component={MLWalletTransactions} initialParams={{ walletID }} />
<TopTab.Screen name="Tokens" component={MLWalletTokens} initialParams={{ walletID }} />
</TopTab.Navigator>
</View>
);
}

const Navigation = () => {
const theme = useTheme();

Expand All @@ -554,6 +583,7 @@ const Navigation = () => {
<RootStack.Screen name="HodlHodlWebview" component={HodlHodlWebview} options={HodlHodlWebview.navigationOptions(theme)} />

<RootStack.Screen name="WalletTransactions" component={WalletTransactions} options={WalletTransactions.navigationOptions(theme)} />
<RootStack.Screen name="MLWalletTransactions" component={MlWalletRoot} options={WalletTransactions.navigationOptions(theme)} />
<WalletsStack.Screen name="WalletDetails" component={WalletDetails} options={WalletDetails.navigationOptions(theme)} />
<WalletsStack.Screen name="WalletAddresses" component={WalletAddresses} options={WalletAddresses.navigationOptions(theme)} />

Expand Down Expand Up @@ -589,6 +619,9 @@ const Navigation = () => {
};

const styles = StyleSheet.create({
flex: {
flex: 1,
},
marginTopTab: {
marginTop: 20,
},
Expand Down
Binary file modified assets/mintlayer/wasm_wrappers_bg.wasm
Binary file not shown.
9 changes: 8 additions & 1 deletion blue_modules/Mintlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const MINTLAYER_ENDPOINTS = {
GET_ADDRESS_DELEGATIONS: '/address/:address/delegations',
GET_DELEGATION: '/delegation/:delegation',
GET_CHAIN_TIP: '/chain/tip',
GET_TOKEN_DATA: '/token/:token',
};

const ML_NETWORK_TYPES = {
Expand All @@ -22,6 +23,7 @@ const TransactionType = {
CreateDelegationId: 'CreateDelegationId',
DelegateStaking: 'DelegateStaking',
CreateStakePool: 'CreateStakePool',
TokenTransfer: 'TokenTransfer',
};

const ML_ATOMS_PER_COIN = 100000000000;
Expand Down Expand Up @@ -110,4 +112,9 @@ const broadcastTransaction = (transaction, network) => {
return tryServers({ endpoint: MINTLAYER_ENDPOINTS.POST_TRANSACTION, body: transaction, network });
};

export { TransactionType, getAddressData, getTransactionData, getAddressUtxo, getWalletUtxos, broadcastTransaction, getFeesEstimates, getChainTip, MINTLAYER_ENDPOINTS, ML_NETWORK_TYPES, ML_ATOMS_PER_COIN };
const getTokenData = async (token, network) => {
const endpoint = MINTLAYER_ENDPOINTS.GET_TOKEN_DATA.replace(':token', token);
return tryServers({ endpoint, network });
};

export { TransactionType, getAddressData, getTransactionData, getAddressUtxo, getWalletUtxos, broadcastTransaction, getFeesEstimates, getChainTip, getTokenData, MINTLAYER_ENDPOINTS, ML_NETWORK_TYPES, ML_ATOMS_PER_COIN };
Loading

0 comments on commit b7385d7

Please sign in to comment.