Skip to content

Commit 213b466

Browse files
committed
Hide scanning message when account head is within CONFIRMATIONS of latest
1 parent 6e94d4a commit 213b466

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { useAccount } from "../../providers/AccountProvider";
2525
import { router } from "expo-router";
2626
import { SafeAreaView } from "react-native-safe-area-context";
2727
import { CurrencyUtils } from "@ironfish/sdk";
28+
import { CONFIRMATIONS } from "@/data/constants";
2829

2930
const MenuIcon = (props: IconProps) => <Icon {...props} name="menu-outline" />;
3031
const SettingsIcon = (props: IconProps) => (
@@ -116,7 +117,11 @@ export default function Balances() {
116117
);
117118
}
118119

119-
const isSyncing = getWalletStatusResult.data?.status === "SCANNING";
120+
const isSyncing =
121+
account?.head?.sequence !== undefined &&
122+
getWalletStatusResult.data?.latestKnownBlock !== undefined &&
123+
account.head.sequence <
124+
Math.max(getWalletStatusResult.data.latestKnownBlock - CONFIRMATIONS, 1);
120125
const syncProgress = isSyncing
121126
? ((account?.head?.sequence ?? 0) /
122127
(getWalletStatusResult.data?.latestKnownBlock ?? 1)) *

packages/mobile-app/data/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ export enum Network {
55

66
export const IRON_ASSET_ID_HEX =
77
"51f33a2f14f92735e562dc658a5639279ddca3d5079a6d1242b2a588a9cbf44c";
8+
9+
// TODO: Make confirmations configurable
10+
export const CONFIRMATIONS = 2;

packages/mobile-app/data/oreowalletServerApi/oreowalletServerApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Network } from "../constants";
1+
import { CONFIRMATIONS, Network } from "../constants";
22
import * as Crypto from "expo-crypto";
33
import * as Uint8ArrayUtils from "../../utils/uint8Array";
44

@@ -294,7 +294,7 @@ class OreowalletServer {
294294
async getBalances(
295295
network: Network,
296296
account: AccountInfo,
297-
confirmations: number = 2,
297+
confirmations: number = CONFIRMATIONS,
298298
): Promise<GetBalancesResponse> {
299299
const url = OREOWALLET_SERVER_URLS[network] + `getBalances`;
300300

packages/mobile-app/data/wallet/oreowalletWallet.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
decodeAccount,
99
encodeAccount,
1010
} from "@ironfish/sdk";
11-
import { IRON_ASSET_ID_HEX, Network } from "../constants";
11+
import { CONFIRMATIONS, IRON_ASSET_ID_HEX, Network } from "../constants";
1212
import * as Uint8ArrayUtils from "../../utils/uint8Array";
1313
import { AssetLoader } from "./assetLoader";
1414
import { Output } from "../facades/wallet/types";
@@ -31,9 +31,6 @@ function assertStarted(state: WalletState): asserts state is StartedState {
3131
}
3232
}
3333

34-
// TODO: Make confirmations configurable
35-
const CONFIRMATIONS = 2;
36-
3734
// Used when calculating a transaction's expiration sequence by adding it
3835
// to the latest block sequence returned from the API.
3936
const EXPIRATION_DELTA = 20;

packages/mobile-app/data/wallet/wallet.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
encodeAccount,
1212
} from "@ironfish/sdk";
1313
import { ChainProcessor } from "../chainProcessor";
14-
import { Network } from "../constants";
14+
import { CONFIRMATIONS, Network } from "../constants";
1515
import * as Uint8ArrayUtils from "../../utils/uint8Array";
1616
import { LightBlock, LightTransaction } from "../walletServerApi/lightstreamer";
1717
import { WriteQueue } from "./writeQueue";
@@ -37,9 +37,6 @@ function assertStarted(state: WalletState): asserts state is StartedState {
3737
}
3838
}
3939

40-
// TODO: Make confirmations configurable
41-
const CONFIRMATIONS = 2;
42-
4340
// Used when calculating a transaction's expiration sequence by adding it
4441
// to the latest block sequence returned from the API.
4542
const EXPIRATION_DELTA = 20;

0 commit comments

Comments
 (0)