Skip to content

Commit 746450d

Browse files
committed
merge main
2 parents d9d34d3 + a38dc9f commit 746450d

File tree

18 files changed

+603
-281
lines changed

18 files changed

+603
-281
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mobile-app/app/(tabs)/index.tsx

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {
1010
Icon,
1111
IconProps,
1212
Spinner,
13+
Modal,
1314
} from "@ui-kitten/components";
1415
import { StyleSheet } from "react-native";
16+
import { setStringAsync } from "expo-clipboard";
1517
import Animated, {
1618
useAnimatedScrollHandler,
1719
useSharedValue,
@@ -22,6 +24,7 @@ import { Asset } from "../../data/facades/chain/types";
2224
import { useAccount } from "../../providers/AccountProvider";
2325
import { router } from "expo-router";
2426
import { SafeAreaView } from "react-native-safe-area-context";
27+
import { CurrencyUtils } from "@ironfish/sdk";
2528

2629
const MenuIcon = (props: IconProps) => <Icon {...props} name="menu-outline" />;
2730
const SettingsIcon = (props: IconProps) => (
@@ -48,11 +51,18 @@ export default function Balances() {
4851
const { account, accountName, isLoading } = useAccount();
4952
const scrollYOffset = useSharedValue(0);
5053
const [selectedIndex, setSelectedIndex] = useState(0);
54+
const [addressModalVisible, setAddressModalVisible] = useState(false);
5155

5256
const scrollHandler = useAnimatedScrollHandler((event) => {
5357
scrollYOffset.value = event.contentOffset.y;
5458
});
5559

60+
const copyAddressToClipboard = async () => {
61+
if (account) {
62+
await setStringAsync(account.publicAddress);
63+
}
64+
};
65+
5666
const getTransactionsResult = facade.getTransactions.useQuery(
5767
{ accountName },
5868
{
@@ -96,7 +106,7 @@ export default function Balances() {
96106
},
97107
);
98108

99-
if (isLoading) {
109+
if (isLoading || !account) {
100110
return (
101111
<SafeAreaView>
102112
<Layout style={[styles.container, styles.loadingContainer]}>
@@ -115,6 +125,30 @@ export default function Balances() {
115125

116126
return (
117127
<SafeAreaView>
128+
<Modal
129+
visible={addressModalVisible}
130+
backdropStyle={styles.backdrop}
131+
onBackdropPress={() => setAddressModalVisible(false)}
132+
>
133+
<Card disabled style={styles.modalCard}>
134+
<Text category="h6" style={styles.modalTitle}>
135+
Your Iron Fish Address
136+
</Text>
137+
<Text selectable style={styles.address}>
138+
{account.publicAddress}
139+
</Text>
140+
<Button onPress={copyAddressToClipboard} style={{ marginBottom: 8 }}>
141+
Copy Address
142+
</Button>
143+
<Button
144+
appearance="ghost"
145+
onPress={() => setAddressModalVisible(false)}
146+
>
147+
Close
148+
</Button>
149+
</Card>
150+
</Modal>
151+
118152
<Animated.ScrollView
119153
scrollEventThrottle={16}
120154
onScroll={scrollHandler}
@@ -144,7 +178,7 @@ export default function Balances() {
144178
</Layout>
145179
<Layout style={styles.headerBalance}>
146180
<Text category="h1" style={styles.balanceAmount}>
147-
{account?.balances.iron.confirmed ?? "0.00"}
181+
{CurrencyUtils.render(account?.balances.iron.confirmed ?? "0")}
148182
</Text>
149183
<Text category="s1" appearance="hint">
150184
{getIronAsset.data?.verification.status === "verified"
@@ -157,7 +191,7 @@ export default function Balances() {
157191
appearance="ghost"
158192
accessoryLeft={ReceiveIcon}
159193
style={styles.actionButton}
160-
onPress={() => router.push("/address/")}
194+
onPress={() => setAddressModalVisible(true)}
161195
>
162196
Receive
163197
</Button>
@@ -173,6 +207,7 @@ export default function Balances() {
173207
appearance="ghost"
174208
accessoryLeft={BridgeIcon}
175209
style={styles.actionButton}
210+
onPress={() => router.push("/menu/debug/browser")}
176211
>
177212
Bridge
178213
</Button>
@@ -224,7 +259,9 @@ export default function Balances() {
224259
? getIronAsset.data.verification.symbol
225260
: (getIronAsset.data?.name ?? "IRON")
226261
}
227-
amount={account.balances.iron.confirmed}
262+
amount={CurrencyUtils.render(
263+
account.balances.iron.confirmed,
264+
)}
228265
verified={
229266
getIronAsset.data?.verification.status === "verified"
230267
}
@@ -241,7 +278,14 @@ export default function Balances() {
241278
? asset.verification.symbol
242279
: (asset?.name ?? balance.assetId)
243280
}
244-
amount={balance.confirmed}
281+
amount={CurrencyUtils.render(
282+
balance.confirmed,
283+
false,
284+
balance.assetId,
285+
asset?.verification.status === "verified"
286+
? asset.verification
287+
: undefined,
288+
)}
245289
verified={asset?.verification.status === "verified"}
246290
/>
247291
);
@@ -401,4 +445,21 @@ const styles = StyleSheet.create({
401445
transactionCard: {
402446
marginVertical: 4,
403447
},
448+
backdrop: {
449+
backgroundColor: "rgba(0, 0, 0, 0.5)",
450+
},
451+
modalCard: {
452+
margin: 16,
453+
paddingHorizontal: 16,
454+
paddingTop: 16,
455+
},
456+
modalTitle: {
457+
textAlign: "center",
458+
marginBottom: 16,
459+
},
460+
address: {
461+
textAlign: "center",
462+
marginBottom: 16,
463+
fontSize: 30,
464+
},
404465
});

packages/mobile-app/app/account-select/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Button, StyleSheet, Text, View } from "react-native";
33
import { useRouter } from "expo-router";
44
import { LinkButton } from "../../components/LinkButton";
55
import { useFacade } from "../../data/facades";
6+
import { CurrencyUtils } from "@ironfish/sdk";
67

78
export default function AccountSelect() {
89
const router = useRouter();
@@ -31,7 +32,9 @@ export default function AccountSelect() {
3132
title={account.name}
3233
/>
3334
{account.active && <Text>Active</Text>}
34-
<Text>{`${account.balances.iron.confirmed} $IRON`}</Text>
35+
<Text>
36+
{`${CurrencyUtils.render(account.balances.iron.confirmed)} $IRON`}
37+
</Text>
3538
</View>
3639
))}
3740
<LinkButton title="Add Account" href="/add-account/" />

packages/mobile-app/app/account-settings/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { StyleSheet } from "react-native";
1111
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
1212
import { useState } from "react";
1313
import { useFacade } from "../../data/facades";
14+
import { CurrencyUtils } from "@ironfish/sdk";
1415

1516
const ForwardIcon = (props: any): IconElement => (
1617
<Icon {...props} name="arrow-ios-forward" />
@@ -25,10 +26,6 @@ const ACCOUNT_SETTINGS_ROUTES = {
2526
title: "Account Name",
2627
href: "account-settings/account-name",
2728
},
28-
address: {
29-
title: "Address",
30-
href: "address",
31-
},
3229
exportAccount: {
3330
title: "Export Account",
3431
href: "account-settings/export-account",
@@ -96,8 +93,9 @@ export default function AccountSettings() {
9693

9794
const menuItems = getMenuItems({
9895
currentAccountName: getAccountResult.data?.name ?? "Unknown",
99-
currentAccountBalance:
96+
currentAccountBalance: CurrencyUtils.render(
10097
getAccountResult.data?.balances.iron.confirmed ?? "0",
98+
),
10199
});
102100

103101
const handleSelect = (index: number) => {

packages/mobile-app/app/address/index.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)