From 714ba54d50918436331106998b8af31ecfe1010b Mon Sep 17 00:00:00 2001 From: Chewing Glass Date: Mon, 31 Jul 2023 18:59:15 -0500 Subject: [PATCH] Payments working --- src/components/HNTKeyboard.tsx | 35 +- src/features/account/AccountActionBar.tsx | 24 +- .../account/AccountManageTokenListScreen.tsx | 7 +- src/features/account/AccountTokenBalance.tsx | 136 ++++---- src/features/account/AccountTokenList.tsx | 13 +- src/features/account/AccountTokenScreen.tsx | 56 ++-- src/features/account/AccountsScreen.tsx | 67 ++-- src/features/account/AirdropScreen.tsx | 47 +-- src/features/account/TokenListItem.tsx | 68 ++-- src/features/burn/BurnScreen.tsx | 16 +- src/features/collectables/HotspotList.tsx | 2 +- src/features/home/homeTypes.ts | 3 +- src/features/payment/PaymentItem.tsx | 32 +- src/features/payment/PaymentScreen.tsx | 34 +- src/features/payment/PaymentSummary.tsx | 7 +- src/features/payment/usePaymentsReducer.ts | 15 +- src/features/request/RequestScreen.tsx | 5 +- src/hooks/useSimulatedTransaction.ts | 4 +- src/locales/en.ts | 2 +- src/solana/WalletSignBottomSheet.tsx | 68 ++-- .../WalletSignBottomSheetTransaction.tsx | 2 +- src/storage/TokensProvider.tsx | 4 +- src/store/slices/balancesSlice.ts | 44 +-- src/store/store.ts | 1 + src/types/balance.ts | 2 - src/utils/Balance.tsx | 28 +- src/utils/StoreSolBalance.ts | 1 - src/utils/StoreTokenBalance.ts | 9 +- src/utils/solanaUtils.ts | 52 ++- yarn.lock | 315 +++++++++++++----- 30 files changed, 648 insertions(+), 451 deletions(-) diff --git a/src/components/HNTKeyboard.tsx b/src/components/HNTKeyboard.tsx index 94100a6a1..5db8f70b4 100644 --- a/src/components/HNTKeyboard.tsx +++ b/src/components/HNTKeyboard.tsx @@ -6,7 +6,6 @@ import { } from '@gorhom/bottom-sheet' import { Portal } from '@gorhom/portal' import { useMint, useOwnedAmount } from '@helium/helium-react-hooks' -import { humanReadable } from '@helium/spl-utils' import useBackHandler from '@hooks/useBackHandler' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { usePublicKey } from '@hooks/usePublicKey' @@ -34,6 +33,7 @@ import { Edge } from 'react-native-safe-area-context' import { Payment } from '../features/payment/PaymentItem' import { CSAccount } from '../storage/cloudStorage' import { decimalSeparator, groupSeparator } from '../utils/i18n' +import { humanReadable } from '../utils/solanaUtils' import AccountIcon from './AccountIcon' import BackgroundFill from './BackgroundFill' import Box from './Box' @@ -87,7 +87,7 @@ const HNTKeyboardSelector = forwardRef( const decimals = useMint(mint)?.info?.decimals const { t } = useTranslation() const bottomSheetModalRef = useRef(null) - const { symbol } = useMetaplexMetadata(mint) + const { symbol, loading: loadingMeta } = useMetaplexMetadata(mint) const { backgroundStyle } = useOpacity('surfaceSecondary', 1) const [value, setValue] = useState('0') const [originalValue, setOriginalValue] = useState('') @@ -119,12 +119,13 @@ const HNTKeyboardSelector = forwardRef( }, [payee]) const valueAsBalance = useMemo(() => { - const stripped = value - .replaceAll(groupSeparator, '') - .replaceAll(decimalSeparator, '.') + if (!value || typeof decimals === 'undefined') return undefined + const [whole, dec] = value.split(decimalSeparator) + const decPart = (dec || '').padEnd(decimals, '0').slice(0, decimals) + const fullStr = `${whole.replaceAll(groupSeparator, '')}${decPart}` - return new BN(stripped) - }, [value]) + return new BN(fullStr) + }, [value, decimals]) const hasMaxDecimals = useMemo(() => { if (!valueAsBalance || typeof decimals === 'undefined') return false @@ -202,8 +203,7 @@ const HNTKeyboardSelector = forwardRef( maxBalance = networkFee ? maxBalance?.sub(networkFee) : maxBalance } - const val = - maxBalance && decimals ? humanReadable(maxBalance, decimals) : '0' + const val = humanReadable(maxBalance, decimals) || '0' setValue(maxEnabled ? '0' : val) setMaxEnabled((m) => !m) @@ -248,11 +248,13 @@ const HNTKeyboardSelector = forwardRef( > - - {t('hntKeyboard.enterAmount', { - ticker: symbol, - })} - + {!loadingMeta && ( + + {t('hntKeyboard.enterAmount', { + ticker: symbol, + })} + + )} { diff --git a/src/features/account/AccountActionBar.tsx b/src/features/account/AccountActionBar.tsx index 14f1cdae0..032d404f0 100644 --- a/src/features/account/AccountActionBar.tsx +++ b/src/features/account/AccountActionBar.tsx @@ -1,14 +1,14 @@ -import React, { useCallback, useMemo } from 'react' -import { useNavigation } from '@react-navigation/native' -import { useTranslation } from 'react-i18next' -import { LayoutChangeEvent } from 'react-native' -import { Ticker } from '@helium/currency' import Box from '@components/Box' import FabButton from '@components/FabButton' import Text from '@components/Text' +import { useNavigation } from '@react-navigation/native' +import { PublicKey } from '@solana/web3.js' +import React, { useCallback, useMemo } from 'react' +import { useTranslation } from 'react-i18next' +import { LayoutChangeEvent } from 'react-native' +import { useAccountStorage } from '../../storage/AccountStorageProvider' import { useAppStorage } from '../../storage/AppStorageProvider' import { HomeNavigationProp } from '../home/homeTypes' -import { useAccountStorage } from '../../storage/AccountStorageProvider' export type Action = | 'send' @@ -21,7 +21,7 @@ export type Action = | 'airdrop' type Props = { - ticker?: Ticker + mint?: PublicKey onLayout?: (event: LayoutChangeEvent) => void compact?: boolean maxCompact?: boolean @@ -43,7 +43,7 @@ const AccountActionBar = ({ hasDelegate, hasSwaps, hasAirdrop, - ticker, + mint, }: Props) => { const navigation = useNavigation() const { t } = useTranslation() @@ -58,7 +58,7 @@ const AccountActionBar = ({ navigation.navigate('ConfirmPin', { action: 'payment' }) } else { navigation.navigate('PaymentScreen', { - defaultTokenType: ticker, + mint: mint?.toBase58(), }) } break @@ -72,7 +72,9 @@ const AccountActionBar = ({ break } case 'airdrop': { - navigation.navigate('AirdropScreen', { ticker: ticker || 'HNT' }) + if (mint) { + navigation.navigate('AirdropScreen', { mint: mint?.toBase58() }) + } break } case '5G': { @@ -93,7 +95,7 @@ const AccountActionBar = ({ } } }, - [navigation, pin, requirePinForPayment, ticker], + [pin?.status, requirePinForPayment, navigation, mint], ) const fabMargin = useMemo(() => { diff --git a/src/features/account/AccountManageTokenListScreen.tsx b/src/features/account/AccountManageTokenListScreen.tsx index 4f6d74f1d..dd8ea8ccb 100644 --- a/src/features/account/AccountManageTokenListScreen.tsx +++ b/src/features/account/AccountManageTokenListScreen.tsx @@ -7,7 +7,7 @@ import TokenIcon from '@components/TokenIcon' import TouchableContainer from '@components/TouchableContainer' import { Ticker } from '@helium/currency' import { useOwnedAmount } from '@helium/helium-react-hooks' -import { DC_MINT, humanReadable } from '@helium/spl-utils' +import { DC_MINT } from '@helium/spl-utils' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { usePublicKey } from '@hooks/usePublicKey' import CheckBox from '@react-native-community/checkbox' @@ -17,6 +17,7 @@ import { useAccountStorage } from '@storage/AccountStorageProvider' import { useVisibleTokens } from '@storage/TokensProvider' import { useColors, useHitSlop } from '@theme/themeHooks' import { useBalance } from '@utils/Balance' +import { humanReadable } from '@utils/solanaUtils' import BN from 'bn.js' import React, { memo, useCallback, useMemo } from 'react' import { FlatList } from 'react-native-gesture-handler' @@ -42,7 +43,9 @@ const CheckableTokenListItem = ({ const { amount, decimals } = useOwnedAmount(wallet, mint) const { json, symbol } = useMetaplexMetadata(mint) const balanceToDisplay = useMemo(() => { - return amount ? humanReadable(new BN(amount.toString()), decimals) : '' + return amount && typeof decimals !== 'undefined' + ? humanReadable(new BN(amount.toString()), decimals) + : '' }, [amount, decimals]) const colors = useColors() diff --git a/src/features/account/AccountTokenBalance.tsx b/src/features/account/AccountTokenBalance.tsx index 8533c53a9..6835a86ee 100644 --- a/src/features/account/AccountTokenBalance.tsx +++ b/src/features/account/AccountTokenBalance.tsx @@ -1,81 +1,98 @@ -import { Ticker } from '@helium/currency' -import { BoxProps } from '@shopify/restyle' -import React, { memo, useMemo } from 'react' +import Box from '@components/Box' import Text from '@components/Text' import TextTransform from '@components/TextTransform' -import Box from '@components/Box' +import { useOwnedAmount, useTokenAccount } from '@helium/helium-react-hooks' +import { DC_MINT } from '@helium/spl-utils' +import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' +import { usePublicKey } from '@hooks/usePublicKey' +import { BoxProps } from '@shopify/restyle' +import { PublicKey } from '@solana/web3.js' +import { useAccountStorage } from '@storage/AccountStorageProvider' import { Theme } from '@theme/theme' +import { IOT_SUB_DAO_KEY, MOBILE_SUB_DAO_KEY } from '@utils/constants' +import { getEscrowTokenAccount, humanReadable } from '@utils/solanaUtils' +import BN from 'bn.js' +import React, { memo, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { useBalance } from '../../utils/Balance' type Props = { - ticker: Ticker + mint: PublicKey textVariant?: 'h0' | 'h1' | 'h2' | 'h2Medium' showTicker?: boolean } & BoxProps +const EscrowDetails = () => { + const { t } = useTranslation() + const { currentAccount } = useAccountStorage() + + const iotEscrow = getEscrowTokenAccount( + currentAccount?.solanaAddress, + IOT_SUB_DAO_KEY, + ) + const mobileEscrow = getEscrowTokenAccount( + currentAccount?.solanaAddress, + MOBILE_SUB_DAO_KEY, + ) + const { info: iotEscrowAcct } = useTokenAccount(iotEscrow) + const { info: mobileEscrowAcct } = useTokenAccount(mobileEscrow) + + return ( + + + {t('accountsScreen.receivedBalance', { + amount: humanReadable( + new BN(iotEscrowAcct?.amount?.toString() || '0').add( + new BN(mobileEscrowAcct?.amount?.toString() || '0'), + ), + 6, + ), + })} + + + ) +} + const AccountTokenBalance = ({ - ticker, + mint, textVariant, showTicker = true, ...boxProps }: Props) => { + const { currentAccount } = useAccountStorage() + const wallet = usePublicKey(currentAccount?.solanaAddress) const { - dcBalance, - mobileBalance, - iotBalance, - solBalance, - hntBalance, - dcEscrowBalance, - } = useBalance() - const { t } = useTranslation() - - const balance = useMemo(() => { - switch (ticker) { - default: - case 'HNT': { - return hntBalance - } - case 'MOBILE': - return mobileBalance - case 'IOT': - return iotBalance - case 'SOL': - return solBalance - case 'DC': - return dcBalance - } - }, [dcBalance, mobileBalance, hntBalance, solBalance, iotBalance, ticker]) + amount: balance, + decimals, + loading: loadingOwned, + } = useOwnedAmount(wallet, mint) + const balanceStr = + typeof decimals !== 'undefined' && balance + ? humanReadable(new BN(balance?.toString() || '0'), decimals) + : undefined + const { symbol } = useMetaplexMetadata(mint) const tokenDetails = useMemo(() => { - if (ticker !== 'DC' || !showTicker) return + if (!mint.equals(DC_MINT) || !showTicker) return - return ( - - - {t('accountsScreen.receivedBalance', { - amount: dcEscrowBalance?.toString(2, { showTicker: false }), - })} - - - ) - }, [ticker, showTicker, t, dcEscrowBalance]) + return + }, [mint, showTicker]) return ( - {!showTicker && ( - - {typeof balance === 'number' - ? balance - : `${balance?.toString(2, { showTicker: false })}`} - - )} + {!showTicker && + (loadingOwned ? ( + + ) : ( + + {balanceStr} + + ))} {showTicker && ( )} diff --git a/src/features/account/AccountTokenList.tsx b/src/features/account/AccountTokenList.tsx index 9bf72a49f..c8169c06d 100644 --- a/src/features/account/AccountTokenList.tsx +++ b/src/features/account/AccountTokenList.tsx @@ -6,7 +6,7 @@ import { BottomSheetFlatListProps } from '@gorhom/bottom-sheet/lib/typescript/co import { DC_MINT, HNT_MINT, IOT_MINT, MOBILE_MINT } from '@helium/spl-utils' import { useNavigation } from '@react-navigation/native' import { PublicKey } from '@solana/web3.js' -import { useVisibleTokens } from '@storage/TokensProvider' +import { useVisibleTokens, DEFAULT_TOKENS } from '@storage/TokensProvider' import { useBalance } from '@utils/Balance' import { times } from 'lodash' import React, { useCallback, useMemo } from 'react' @@ -40,17 +40,22 @@ const AccountTokenList = ({ onLayout }: Props) => { const { tokenAccounts } = useBalance() const { bottom } = useSafeAreaInsets() const mints = useMemo(() => { - return tokenAccounts + const taMints = tokenAccounts ?.filter( (ta) => visibleTokens.has(ta.mint) && ta.balance > 0 && (ta.decimals > 0 || ta.mint === DC_MINT.toBase58()), ) - .map((ta) => new PublicKey(ta.mint)) + .map((ta) => ta.mint) + + const all = [...new Set([...DEFAULT_TOKENS, ...(taMints || [])])] .sort((a, b) => { - return getSortValue(b.toBase58()) - getSortValue(a.toBase58()) + return getSortValue(b) - getSortValue(a) }) + .map((mint) => new PublicKey(mint)) + + return all }, [tokenAccounts, visibleTokens]) const bottomSpace = useMemo(() => bottom * 2, [bottom]) diff --git a/src/features/account/AccountTokenScreen.tsx b/src/features/account/AccountTokenScreen.tsx index 909049c4b..d3fd7c4f5 100644 --- a/src/features/account/AccountTokenScreen.tsx +++ b/src/features/account/AccountTokenScreen.tsx @@ -13,7 +13,8 @@ import BottomSheet, { BottomSheetFlatList, WINDOW_HEIGHT, } from '@gorhom/bottom-sheet' -import { HNT_MINT, DC_MINT, IOT_MINT, MOBILE_MINT } from '@helium/spl-utils' +import { Ticker } from '@helium/currency' +import { DC_MINT, HNT_MINT, IOT_MINT, MOBILE_MINT } from '@helium/spl-utils' import useLayoutHeight from '@hooks/useLayoutHeight' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { usePublicKey } from '@hooks/usePublicKey' @@ -73,7 +74,8 @@ const AccountTokenScreen = () => { ] = useState(true) const mintStr = useMemo(() => route.params.mint, [route.params.mint]) - const mint = usePublicKey(mintStr) + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const mint = usePublicKey(mintStr)! const { json, symbol } = useMetaplexMetadata(mint) @@ -183,10 +185,10 @@ const AccountTokenScreen = () => { const hasAirdrop = useMemo(() => { if (cluster === 'devnet') { return ( - mint?.equals(NATIVE_MINT) || - mint?.equals(HNT_MINT) || - mint?.equals(IOT_MINT) || - mint?.equals(MOBILE_MINT) + mint.equals(NATIVE_MINT) || + mint.equals(HNT_MINT) || + mint.equals(IOT_MINT) || + mint.equals(MOBILE_MINT) ) } return false @@ -310,7 +312,7 @@ const AccountTokenScreen = () => { const filters = useCallback( () => ( <> - {!mint?.equals(DC_MINT) && ( + {!mint.equals(DC_MINT) && ( <> { /> )} - {mint?.equals(DC_MINT) && ( + {mint.equals(DC_MINT) && ( <> { hasBottomTitle: true, } - if (mint?.equals(DC_MINT)) { + if (mint.equals(DC_MINT)) { options = { hasSend: false, hasRequest: false, @@ -435,20 +437,22 @@ const AccountTokenScreen = () => { showTicker={false} textVariant="h2Medium" justifyContent="flex-start" - ticker={routeTicker} + mint={mint} flex={1} /> - + {!!symbol && ( + + )} @@ -458,19 +462,21 @@ const AccountTokenScreen = () => { - - + + {!!symbol && ( + + )} { const widgetGroup = 'group.com.helium.mobile.wallet.widget' @@ -274,7 +275,7 @@ const AccountsScreen = () => { - + ) }, [handleTopHeaderLayout, headerAnimatedStyle]) diff --git a/src/features/account/AirdropScreen.tsx b/src/features/account/AirdropScreen.tsx index 6a06bc9f8..9f36f881a 100644 --- a/src/features/account/AirdropScreen.tsx +++ b/src/features/account/AirdropScreen.tsx @@ -1,16 +1,22 @@ +import DripLogo from '@assets/images/dripLogo.svg' +import { ReAnimatedBox } from '@components/AnimatedBox' import BackScreen from '@components/BackScreen' import Box from '@components/Box' import ButtonPressable from '@components/ButtonPressable' -import React, { memo, useCallback, useEffect, useMemo, useState } from 'react' -import * as solUtils from '@utils/solanaUtils' -import { useAccountStorage } from '@storage/AccountStorageProvider' -import { RouteProp, useNavigation, useRoute } from '@react-navigation/native' -import { useTranslation } from 'react-i18next' +import CircleLoader from '@components/CircleLoader' import SafeAreaBox from '@components/SafeAreaBox' +import Text from '@components/Text' import TokenIcon from '@components/TokenIcon' -import { Edge } from 'react-native-safe-area-context' -import DripLogo from '@assets/images/dripLogo.svg' -import { ReAnimatedBox } from '@components/AnimatedBox' +import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' +import { usePublicKey } from '@hooks/usePublicKey' +import { RouteProp, useNavigation, useRoute } from '@react-navigation/native' +import { NATIVE_MINT } from '@solana/spl-token' +import { useAccountStorage } from '@storage/AccountStorageProvider' +import * as logger from '@utils/logger' +import * as solUtils from '@utils/solanaUtils' +import axios from 'axios' +import React, { memo, useCallback, useEffect, useMemo, useState } from 'react' +import { useTranslation } from 'react-i18next' import { interpolate, runOnJS, @@ -20,12 +26,9 @@ import { withRepeat, withTiming, } from 'react-native-reanimated' -import Text from '@components/Text' -import axios from 'axios' -import * as logger from '@utils/logger' -import CircleLoader from '@components/CircleLoader' -import { HomeNavigationProp, HomeStackParamList } from '../home/homeTypes' +import { Edge } from 'react-native-safe-area-context' import { useSolana } from '../../solana/SolanaProvider' +import { HomeNavigationProp, HomeStackParamList } from '../home/homeTypes' const DROP_HEIGHT = 79 @@ -42,20 +45,22 @@ const AirdropScreen = () => { const [loading, setLoading] = useState(false) const route = useRoute() - const { ticker } = route.params + const { mint: mintStr } = route.params + const mint = usePublicKey(mintStr) + const { symbol, json } = useMetaplexMetadata(mint) const onAirdrop = useCallback(async () => { if (!currentAccount?.solanaAddress || !anchorProvider) return setLoading(true) - if (ticker === 'SOL') { + if (mint?.equals(NATIVE_MINT)) { solUtils.airdrop(anchorProvider, currentAccount?.solanaAddress) setLoading(false) navigation.goBack() } else { try { await axios.get( - `https://faucet.web.test-helium.com/${ticker.toLowerCase()}/${ + `https://faucet.web.test-helium.com/${symbol?.toLowerCase()}/${ currentAccount?.solanaAddress }?amount=2)`, ) @@ -68,7 +73,7 @@ const AirdropScreen = () => { setErrorMessage((error as Error).message) } } - }, [anchorProvider, currentAccount, navigation, ticker]) + }, [anchorProvider, currentAccount?.solanaAddress, mint, navigation, symbol]) const edges = useMemo(() => ['bottom'] as Edge[], []) @@ -163,7 +168,7 @@ const AirdropScreen = () => { marginBottom="l" > - + @@ -184,7 +189,11 @@ const AirdropScreen = () => { titleColorDisabled="black500" titleColor="primary" fontWeight="500" - title={!loading ? t('airdropScreen.airdropTicker', { ticker }) : ''} + title={ + !loading + ? t('airdropScreen.airdropTicker', { ticker: symbol || '' }) + : '' + } disabled={loading} marginVertical="l" marginHorizontal="l" diff --git a/src/features/account/TokenListItem.tsx b/src/features/account/TokenListItem.tsx index 58c4b6f0b..de399e763 100644 --- a/src/features/account/TokenListItem.tsx +++ b/src/features/account/TokenListItem.tsx @@ -6,13 +6,13 @@ import TokenIcon from '@components/TokenIcon' import TouchableContainer from '@components/TouchableContainer' import { Ticker } from '@helium/currency' import { useOwnedAmount } from '@helium/helium-react-hooks' -import { humanReadable } from '@helium/spl-utils' import useHaptic from '@hooks/useHaptic' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { usePublicKey } from '@hooks/usePublicKey' import { useNavigation } from '@react-navigation/native' import { PublicKey } from '@solana/web3.js' import { useAccountStorage } from '@storage/AccountStorageProvider' +import { humanReadable } from '@utils/solanaUtils' import BN from 'bn.js' import React, { useCallback, useMemo } from 'react' import { HomeNavigationProp } from '../home/homeTypes' @@ -26,11 +26,15 @@ const TokenListItem = ({ mint }: Props) => { const navigation = useNavigation() const { currentAccount } = useAccountStorage() const wallet = usePublicKey(currentAccount?.solanaAddress) - const { amount, decimals } = useOwnedAmount(wallet, mint) + const { + amount, + decimals, + loading: loadingOwned, + } = useOwnedAmount(wallet, mint) // const amount = BigInt(0) // const decimals = 0 const { triggerImpact } = useHaptic() - const { json, symbol } = useMetaplexMetadata(mint) + const { json, symbol, loading } = useMetaplexMetadata(mint) const mintStr = mint.toBase58() const handleNavigation = useCallback(() => { @@ -43,7 +47,7 @@ const TokenListItem = ({ mint }: Props) => { const balanceToDisplay = useMemo(() => { return amount && typeof decimals !== 'undefined' ? humanReadable(new BN(amount.toString()), decimals) - : '' + : '0' }, [amount, decimals]) return ( @@ -58,24 +62,46 @@ const TokenListItem = ({ mint }: Props) => { borderBottomColor="primaryBackground" borderBottomWidth={1} > - + {loading ? ( + + ) : ( + + )} + - - - {`${balanceToDisplay} `} - - - {symbol} - - + {loadingOwned ? ( + + + + + ) : ( + + + {`${balanceToDisplay} `} + + + {symbol} + + + )} {symbol && ( { const { submitDelegateDataCredits } = useSubmitTxn() const addressBookRef = useRef(null) const { - floatToBalance, networkTokensToDc, hntBalance, solBalance, @@ -88,9 +88,7 @@ const BurnScreen = () => { } = useBalance() const { showOKAlert } = useAlert() const hntKeyboardRef = useRef(null) - const [dcAmount, setDcAmount] = useState( - new Balance(Number(route.params.amount), CurrencyType.dataCredit), - ) + const [dcAmount, setDcAmount] = useState(new BN(route.params.amount)) const [submitError, setSubmitError] = useState(undefined) const [delegateAddress, setDelegateAddress] = useState(route.params.address) const [hasError, setHasError] = useState(false) @@ -118,12 +116,12 @@ const BurnScreen = () => { }, [networkType]) const amountBalance = useMemo(() => { - const amount = parseFloat(route.params.amount) + const amount = new BN(route.params.amount) if (dcAmount) return dcAmount - return floatToBalance(amount, 'HNT') - }, [floatToBalance, dcAmount, route.params.amount]) + return amount + }, [dcAmount, route.params.amount]) const feeAsTokens = useMemo(() => { return Balance.fromFloat(TXN_FEE_IN_SOL, CurrencyType.solTokens) @@ -245,7 +243,7 @@ const BurnScreen = () => { }, [amountBalance, insufficientFunds, t]) const onConfirmBalance = useCallback((opts) => { - setDcAmount(new Balance(opts.balance.floatBalance, CurrencyType.dataCredit)) + setDcAmount(new BN(opts.balance)) }, []) const handleAddressBookSelected = useCallback( diff --git a/src/features/collectables/HotspotList.tsx b/src/features/collectables/HotspotList.tsx index 5551d6715..0829780bf 100644 --- a/src/features/collectables/HotspotList.tsx +++ b/src/features/collectables/HotspotList.tsx @@ -147,7 +147,7 @@ const HotspotList = () => { const RewardItem = useCallback( ({ ticker, amount, ...rest }) => { const decimals = - ticker === 'IOT' ? iotMint?.info.decimals : mobileMint?.info.decimals + ticker === 'IOT' ? iotMint?.decimals : mobileMint?.decimals let realAmount = '' if (amount) { const num = toNumber(amount, decimals || 6) diff --git a/src/features/home/homeTypes.ts b/src/features/home/homeTypes.ts index b8068e16d..d0dd766bc 100644 --- a/src/features/home/homeTypes.ts +++ b/src/features/home/homeTypes.ts @@ -9,6 +9,7 @@ export type PaymentRouteParam = { memo?: string netType?: string defaultTokenType?: Ticker + mint?: string } export type BurnRouteParam = { @@ -35,7 +36,7 @@ export type HomeStackParamList = { action: 'payment' } PaymentScreen: undefined | PaymentRouteParam - AirdropScreen: { ticker: Ticker } + AirdropScreen: { mint: string } BurnScreen: BurnRouteParam PaymentQrScanner: undefined RequestScreen: undefined diff --git a/src/features/payment/PaymentItem.tsx b/src/features/payment/PaymentItem.tsx index e110b812c..0d5dc8f54 100644 --- a/src/features/payment/PaymentItem.tsx +++ b/src/features/payment/PaymentItem.tsx @@ -9,12 +9,12 @@ import TouchableOpacityBox from '@components/TouchableOpacityBox' import Address from '@helium/address' import { Balance, DataCredits } from '@helium/currency' import { useMint } from '@helium/helium-react-hooks' -import { humanReadable } from '@helium/spl-utils' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { BoxProps } from '@shopify/restyle' import { PublicKey } from '@solana/web3.js' import { Theme } from '@theme/theme' import { useColors, useOpacity } from '@theme/themeHooks' +import { humanReadable } from '@utils/solanaUtils' import BN from 'bn.js' import { toUpper } from 'lodash' import React, { memo, useCallback, useEffect, useMemo } from 'react' @@ -85,7 +85,7 @@ const PaymentItem = ({ const { dcToNetworkTokens, oraclePrice } = useBalance() const { t } = useTranslation() const { secondaryText } = useColors() - const { symbol } = useMetaplexMetadata(mint) + const { symbol, loading: loadingMeta } = useMetaplexMetadata(mint) const addressIsWrongNetType = useMemo( () => @@ -240,17 +240,19 @@ const PaymentItem = ({ flex={1} justifyContent="center" > - - {t('payment.enterAmount', { - symbol, - })} - + {!loadingMeta && ( + + {t('payment.enterAmount', { + ticker: symbol, + })} + + )} ) : ( @@ -264,9 +266,7 @@ const PaymentItem = ({ variant="subtitle2" color="primaryText" > - {typeof amount !== 'undefined' && - typeof decimals !== 'undefined' && - humanReadable(amount, decimals)} + {humanReadable(amount, decimals)} {fee && ( diff --git a/src/features/payment/PaymentScreen.tsx b/src/features/payment/PaymentScreen.tsx index b82d132fa..6e22edcc6 100644 --- a/src/features/payment/PaymentScreen.tsx +++ b/src/features/payment/PaymentScreen.tsx @@ -20,7 +20,7 @@ import TouchableOpacityBox from '@components/TouchableOpacityBox' import Address, { NetTypes } from '@helium/address' import { Ticker } from '@helium/currency' import { useMint, useOwnedAmount } from '@helium/helium-react-hooks' -import { HNT_MINT, humanReadable } from '@helium/spl-utils' +import { HNT_MINT } from '@helium/spl-utils' import useDisappear from '@hooks/useDisappear' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import { usePublicKey } from '@hooks/usePublicKey' @@ -30,7 +30,10 @@ import { PublicKey } from '@solana/web3.js' import { useVisibleTokens } from '@storage/TokensProvider' import { useColors, useHitSlop } from '@theme/themeHooks' import { Mints } from '@utils/constants' -import { calcCreateAssociatedTokenAccountAccountFee } from '@utils/solanaUtils' +import { + calcCreateAssociatedTokenAccountAccountFee, + humanReadable, +} from '@utils/solanaUtils' import BN from 'bn.js' import { unionBy } from 'lodash' import React, { @@ -88,7 +91,8 @@ const parseLinkedPayments = (opts: PaymentRouteParam): LinkedPayment[] => { { payee: opts.payee, amount: opts.amount, - mint: Mints[opts.defaultTokenType?.toUpperCase() as Ticker], + mint: + opts.mint || Mints[opts.defaultTokenType?.toUpperCase() as Ticker], }, ] } @@ -167,11 +171,19 @@ const PaymentScreen = () => { netType: networkType, }) + useEffect(() => { + dispatch({ + type: 'updateTokenBalance', + balance, + }) + }, [dispatch, balance]) + const { submitPayment } = useSubmitTxn() const solanaPayment = useSelector( (reduxState: RootState) => reduxState.solana.payment, ) + const { symbol } = useMetaplexMetadata(mint) const { top } = useSafeAreaInsets() @@ -366,7 +378,9 @@ const PaymentScreen = () => { } if (insufficientFunds[0]) { errStrings.push( - t('payment.insufficientFunds', { token: insufficientFunds[1] }), + t('payment.insufficientFunds', { + token: insufficientFunds[1]?.equals(NATIVE_MINT) ? 'SOL' : symbol, + }), ) } @@ -379,12 +393,13 @@ const PaymentScreen = () => { } return errStrings }, [ - currentAccount, + currentAccount?.ledgerDevice, + paymentState.payments.length, insufficientFunds, selfPay, - paymentState.payments.length, - t, wrongNetTypePay, + t, + symbol, ]) const isFormValid = useMemo(() => { @@ -593,11 +608,8 @@ const PaymentScreen = () => { }, [sortedAccountsForNetType]) const decimals = useMint(mint)?.info?.decimals - const { symbol } = useMetaplexMetadata(mint) const tokenButtonBalance = useMemo(() => { - if (typeof balance !== 'undefined' && typeof decimals !== 'undefined') { - return humanReadable(balance, decimals) - } + return humanReadable(balance, decimals) }, [balance, decimals]) const data = useMemo((): TokenListItem[] => { diff --git a/src/features/payment/PaymentSummary.tsx b/src/features/payment/PaymentSummary.tsx index 553c7251c..429091bf7 100644 --- a/src/features/payment/PaymentSummary.tsx +++ b/src/features/payment/PaymentSummary.tsx @@ -2,8 +2,8 @@ import AccountIcon from '@components/AccountIcon' import Box from '@components/Box' import Text from '@components/Text' import { useMint } from '@helium/helium-react-hooks' -import { humanReadable } from '@helium/spl-utils' import { PublicKey } from '@solana/web3.js' +import { humanReadable } from '@utils/solanaUtils' import BN from 'bn.js' import React, { memo, useMemo } from 'react' import { useTranslation } from 'react-i18next' @@ -34,10 +34,7 @@ const PaymentSummary = ({ const decimals = useMint(mint)?.info?.decimals const total = useMemo(() => { - if (typeof totalBalance === 'undefined' || typeof decimals === 'undefined') - return '' - - return humanReadable(totalBalance, decimals) + return humanReadable(totalBalance, decimals) || '' }, [totalBalance, decimals]) const fee = useMemo( () => diff --git a/src/features/payment/usePaymentsReducer.ts b/src/features/payment/usePaymentsReducer.ts index 098bc5f00..9738c2727 100644 --- a/src/features/payment/usePaymentsReducer.ts +++ b/src/features/payment/usePaymentsReducer.ts @@ -24,6 +24,11 @@ type UpdateBalanceAction = { payer: string } +type UpdateTokenBalanceAction = { + type: 'updateTokenBalance' + balance?: BN +} + type RemovePayment = { type: 'removePayment' index: number @@ -81,9 +86,9 @@ const initialState = (opts: { error: undefined, payments: [{}] as Array, totalAmount: new BN(0), - balance: opts.balance || new BN(0), ...calculateFee([{}]), ...opts, + balance: opts.balance || new BN(0), }) const paymentsSum = (payments: Payment[]) => { @@ -143,6 +148,7 @@ function reducer( action: | UpdatePayeeAction | UpdateBalanceAction + | UpdateTokenBalanceAction | UpdateErrorAction | AddPayee | AddLinkedPayments @@ -210,6 +216,13 @@ function reducer( }) return { ...state, ...recalculate(nextPayments, state) } } + + case 'updateTokenBalance': { + return { + ...state, + balance: action.balance || new BN(0), + } + } case 'addPayee': { if (state.payments.length >= MAX_PAYMENTS) return state diff --git a/src/features/request/RequestScreen.tsx b/src/features/request/RequestScreen.tsx index c86147064..85ec79e17 100644 --- a/src/features/request/RequestScreen.tsx +++ b/src/features/request/RequestScreen.tsx @@ -17,7 +17,6 @@ import TokenSelector, { import TouchableOpacityBox from '@components/TouchableOpacityBox' import { NetTypes as NetType } from '@helium/address' import { useMint } from '@helium/helium-react-hooks' -import { humanReadable } from '@helium/spl-utils' import useHaptic from '@hooks/useHaptic' import { useMetaplexMetadata } from '@hooks/useMetaplexMetadata' import Clipboard from '@react-native-community/clipboard' @@ -34,6 +33,7 @@ import { } from '@theme/themeHooks' import animateTransition from '@utils/animateTransition' import { makePayRequestLink } from '@utils/linking' +import { humanReadable } from '@utils/solanaUtils' import BN from 'bn.js' import React, { memo, @@ -339,8 +339,7 @@ const RequestScreen = () => { ) : ( - {typeof decimals !== 'undefined' && - humanReadable(paymentAmount, decimals)} + {humanReadable(paymentAmount, decimals)} )} diff --git a/src/hooks/useSimulatedTransaction.ts b/src/hooks/useSimulatedTransaction.ts index 88d121a45..1e9e3a21c 100644 --- a/src/hooks/useSimulatedTransaction.ts +++ b/src/hooks/useSimulatedTransaction.ts @@ -25,7 +25,7 @@ type BalanceChange = { nativeChange?: number mint?: PublicKey symbol?: string - type?: 'send' | 'recieve' + type?: 'send' | 'receive' } type BalanceChanges = BalanceChange[] | null @@ -301,7 +301,7 @@ export function useSimulatedTransaction( const type = accountNativeBalance.lt(existingNativeBalance) ? 'send' - : 'recieve' + : 'receive' // Filter out zero change if (!accountNativeBalance.eq(existingNativeBalance)) { diff --git a/src/locales/en.ts b/src/locales/en.ts index 095354c13..4a7c3e765 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -382,7 +382,7 @@ export default { connectToWebsitesYouTrust: 'Only connect to websites you trust', estimatedChanges: 'Estimated Changes', sendToken: 'Send {{amount}} {{ticker}}', - recieveToken: 'Receive {{amount}} {{ticker}}', + receiveToken: 'Receive {{amount}} {{ticker}}', insufficientFunds: 'Insufficient funds', insufficientRentExempt: 'Solana wallets must have a minimum of ~{{amount}} SOL to cover rent. The result of this transaction would leave your wallet with less than the rent-exempt minimum.', diff --git a/src/solana/WalletSignBottomSheet.tsx b/src/solana/WalletSignBottomSheet.tsx index 3913002e5..fec09339b 100644 --- a/src/solana/WalletSignBottomSheet.tsx +++ b/src/solana/WalletSignBottomSheet.tsx @@ -1,7 +1,25 @@ +import Checkmark from '@assets/images/checkmark.svg' +import Box from '@components/Box' +import ButtonPressable from '@components/ButtonPressable' +import SafeAreaBox from '@components/SafeAreaBox' +import Text from '@components/Text' +import { + BottomSheetBackdrop, + BottomSheetModal, + BottomSheetModalProvider, + useBottomSheetDynamicSnapPoints, +} from '@gorhom/bottom-sheet' +import { useSolOwnedAmount } from '@helium/helium-react-hooks' +import { usePublicKey } from '@hooks/usePublicKey' +import { useRentExempt } from '@hooks/useRentExempt' +import { LAMPORTS_PER_SOL } from '@solana/web3.js' +import { useAccountStorage } from '@storage/AccountStorageProvider' +import { useColors, useOpacity } from '@theme/themeHooks' +import BN from 'bn.js' import React, { + Ref, forwardRef, memo, - Ref, useCallback, useEffect, useImperativeHandle, @@ -9,31 +27,16 @@ import React, { useRef, useState, } from 'react' -import Checkmark from '@assets/images/checkmark.svg' import { useTranslation } from 'react-i18next' -import { - BottomSheetBackdrop, - useBottomSheetDynamicSnapPoints, - BottomSheetModal, - BottomSheetModalProvider, -} from '@gorhom/bottom-sheet' -import { Edge } from 'react-native-safe-area-context' -import SafeAreaBox from '@components/SafeAreaBox' -import Box from '@components/Box' -import Text from '@components/Text' -import { useColors, useOpacity } from '@theme/themeHooks' -import ButtonPressable from '@components/ButtonPressable' -import { LAMPORTS_PER_SOL } from '@solana/web3.js' -import { useBalance } from '@utils/Balance' import { ScrollView } from 'react-native-gesture-handler' -import { useRentExempt } from '@hooks/useRentExempt' +import { Edge } from 'react-native-safe-area-context' +import WalletSignBottomSheetTransaction from './WalletSignBottomSheetTransaction' import { - WalletSignBottomSheetRef, WalletSignBottomSheetProps, + WalletSignBottomSheetRef, WalletSignOpts, WalletStandardMessageTypes, } from './walletSignBottomSheetTypes' -import WalletSignBottomSheetTransaction from './WalletSignBottomSheetTransaction' let promiseResolve: (value: boolean | PromiseLike) => void @@ -47,7 +50,9 @@ const WalletSignBottomSheet = forwardRef( const { backgroundStyle } = useOpacity('surfaceSecondary', 1) const { secondaryText } = useColors() const { t } = useTranslation() - const { solBalance } = useBalance() + const { currentAccount } = useAccountStorage() + const solanaAddress = usePublicKey(currentAccount?.solanaAddress) + const { amount: solBalance } = useSolOwnedAmount(solanaAddress) const bottomSheetModalRef = useRef(null) const [totalSolFee, setTotalSolFee] = useState(0) const [isVisible, setIsVisible] = useState(false) @@ -96,22 +101,21 @@ const WalletSignBottomSheet = forwardRef( return 5000 / LAMPORTS_PER_SOL }, [walletSignOpts, totalSolFee, currentTxs]) - const insufficientRentExempt = useMemo( - () => - (solBalance?.floatBalance || 0) - estimatedTotalSolByLamports < - (rentExempt || 0), - [solBalance?.floatBalance, estimatedTotalSolByLamports, rentExempt], - ) + const insufficientRentExempt = useMemo(() => { + if (solBalance) { + return new BN(solBalance.toString()) + .sub(new BN(estimatedTotalSolByLamports)) + .lt(new BN(rentExempt || 0)) + } + }, [solBalance, estimatedTotalSolByLamports, rentExempt]) const insufficientFunds = useMemo( () => nestedInsufficentFunds || - estimatedTotalSolByLamports > (solBalance?.floatBalance || 0), - [ - solBalance?.floatBalance, - estimatedTotalSolByLamports, - nestedInsufficentFunds, - ], + new BN(estimatedTotalSolByLamports).gt( + new BN(solBalance?.toString() || '0'), + ), + [solBalance, estimatedTotalSolByLamports, nestedInsufficentFunds], ) const safeEdges = useMemo(() => ['bottom'] as Edge[], []) diff --git a/src/solana/WalletSignBottomSheetTransaction.tsx b/src/solana/WalletSignBottomSheetTransaction.tsx index ca54e9a31..fde0b60e8 100644 --- a/src/solana/WalletSignBottomSheetTransaction.tsx +++ b/src/solana/WalletSignBottomSheetTransaction.tsx @@ -100,7 +100,7 @@ const WalletSignBottomSheetTransaction = ({ amount: change.nativeChange, }) } else { - balanceChange = t('browserScreen.recieveToken', { + balanceChange = t('browserScreen.receiveToken', { ticker: change.symbol, amount: change.nativeChange, }) diff --git a/src/storage/TokensProvider.tsx b/src/storage/TokensProvider.tsx index 0fa3bc11c..d1df42d69 100644 --- a/src/storage/TokensProvider.tsx +++ b/src/storage/TokensProvider.tsx @@ -16,7 +16,7 @@ import { updateVisibleTokens, } from './cloudStorage' -const DEFAULT_TOKENS = new Set([ +export const DEFAULT_TOKENS = new Set([ HNT_MINT.toBase58(), MOBILE_MINT.toBase58(), IOT_MINT.toBase58(), @@ -38,7 +38,7 @@ const useVisibleTokensHook = () => { if (response) { setVisibleTokens( Object.entries(response).reduce((acc, [key, s]) => { - acc[key] = new Set(s) + acc[key] = new Set([...s, ...DEFAULT_TOKENS]) return acc }, {} as Record>), ) diff --git a/src/store/slices/balancesSlice.ts b/src/store/slices/balancesSlice.ts index 35aaa539b..2cc7208b5 100644 --- a/src/store/slices/balancesSlice.ts +++ b/src/store/slices/balancesSlice.ts @@ -1,12 +1,10 @@ import { AnchorProvider } from '@coral-xyz/anchor' import { PayloadAction, createAsyncThunk, createSlice } from '@reduxjs/toolkit' -import { Cluster, PublicKey } from '@solana/web3.js' import { AccountLayout, TOKEN_PROGRAM_ID, getMint } from '@solana/spl-token' -import BN from 'bn.js' +import { Cluster, PublicKey } from '@solana/web3.js' import { CSAccount } from '../../storage/cloudStorage' -import { getBalanceHistory, getTokenPrices } from '../../utils/walletApiV2' import { AccountBalance, Prices, TokenAccount } from '../../types/balance' -import { getEscrowTokenAccount } from '../../utils/solanaUtils' +import { getBalanceHistory, getTokenPrices } from '../../utils/walletApiV2' type BalanceHistoryByCurrency = Record type BalanceHistoryByWallet = Record @@ -15,7 +13,6 @@ type BalanceHistoryByCluster = Record export type Tokens = { atas: TokenAccount[] sol: { tokenAccount: string; balance: number } - dcEscrow: { tokenAccount: string; balance: number } } type AtaBalances = Record> @@ -59,6 +56,7 @@ export const syncTokenAccounts = createAsyncThunk( const tokenAccounts = await connection.getTokenAccountsByOwner(pubKey, { programId: TOKEN_PROGRAM_ID, }) + const solAcct = await connection.getAccountInfo(pubKey) const atas = await Promise.all( tokenAccounts.value.map(async (tokenAccount) => { @@ -75,26 +73,7 @@ export const syncTokenAccounts = createAsyncThunk( }), ) - const escrowAccount = getEscrowTokenAccount(acct.solanaAddress) - let escrowBalance = 0 - const [dcEscrowAcc, solAcc] = await Promise.all([ - connection.getAccountInfo(escrowAccount), - connection.getAccountInfo(pubKey), - ]) - try { - const dcEscrowBalance = - dcEscrowAcc && AccountLayout.decode(dcEscrowAcc.data).amount - escrowBalance = dcEscrowBalance - ? new BN(dcEscrowBalance.toString()).toNumber() - : 0 - } catch {} - - const dcEscrow = { - tokenAccount: escrowAccount.toBase58(), - balance: escrowBalance, - } - - const solBalance = solAcc?.lamports || 0 + const solBalance = solAcct?.lamports || 0 const sol = { tokenAccount: acct.solanaAddress, balance: solBalance, @@ -102,7 +81,6 @@ export const syncTokenAccounts = createAsyncThunk( return { atas, - dcEscrow, sol, } }, @@ -144,24 +122,16 @@ const balancesSlice = createSlice({ cluster: Cluster solanaAddress: string balance: number - type: 'dcEscrow' | 'sol' tokenAccount: string }>, ) => { const { payload } = action - const { cluster, solanaAddress, balance, type, tokenAccount } = payload + const { cluster, solanaAddress, balance, tokenAccount } = payload const next = { tokenAccount, balance } const prevTokens = state.balances?.[cluster]?.[solanaAddress] if (!prevTokens) return - switch (type) { - case 'dcEscrow': - prevTokens.dcEscrow = next - break - case 'sol': - prevTokens.sol = next - break - } + prevTokens.sol = next }, updateAtaBalance: ( state, @@ -234,5 +204,5 @@ const balancesSlice = createSlice({ }) const { reducer, name } = balancesSlice -export { name, balancesSlice } +export { balancesSlice, name } export default reducer diff --git a/src/store/store.ts b/src/store/store.ts index 163dcfbea..97ad74d3a 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -33,6 +33,7 @@ const store = configureStore({ middleware: (getDefaultMiddleware) => getDefaultMiddleware({ serializableCheck: false, + immutableCheck: { warnAfter: 500 }, }).concat([solanaStatusApi.middleware]), enhancers, }) diff --git a/src/types/balance.ts b/src/types/balance.ts index 636c738ae..46fc75577 100644 --- a/src/types/balance.ts +++ b/src/types/balance.ts @@ -34,8 +34,6 @@ export type Prices = Record> export type BalanceInfo = { atas: Required[] dcBalance: Balance - dcEscrowBalance: Balance - dcEscrowToken: Omit formattedDcValue: string formattedEscrowDcValue: string formattedHntValue: string diff --git a/src/utils/Balance.tsx b/src/utils/Balance.tsx index 8870e1c99..06ecbe510 100644 --- a/src/utils/Balance.tsx +++ b/src/utils/Balance.tsx @@ -35,7 +35,6 @@ import { useAppDispatch } from '../store/store' import { AccountBalance, BalanceInfo, TokenAccount } from '../types/balance' import StoreAtaBalance from './StoreAtaBalance' import StoreSolBalance from './StoreSolBalance' -import StoreTokenBalance from './StoreTokenBalance' import { accountCurrencyType } from './accountUtils' import { decimalSeparator, groupSeparator } from './i18n' import { useBalanceHistory } from './useBalanceHistory' @@ -214,17 +213,6 @@ const useBalanceHook = () => { const solToken = accountBalancesForCluster?.sol - const dcEscrowToken = accountBalancesForCluster?.dcEscrow - - const dcEscrowBalance = new Balance( - dcEscrowToken?.balance || 0, - CurrencyType.dataCredit, - ) - const formattedEscrowDcValue = await CurrencyFormatter.format( - dcEscrowBalance.toUsd(oraclePrice).floatBalance, - 'usd', - ) - const solBalance = Balance.fromIntAndTicker(solToken?.balance || 0, 'SOL') const solPrice = tokenPrices?.solana?.[currency] || 0 const solAmount = solBalance?.floatBalance @@ -277,11 +265,7 @@ const useBalanceHook = () => { return { atas, - dcBalance, - dcEscrowBalance, - dcEscrowToken, formattedDcValue, - formattedEscrowDcValue, formattedHntValue, formattedIotValue, formattedMobileValue, @@ -395,9 +379,6 @@ const useBalanceHook = () => { const initialState = { balanceHistory: [] as AccountBalance[], bonesToBalance: () => new Balance(0, CurrencyType.networkToken), - dcBalance: new Balance(0, CurrencyType.dataCredit), - dcDelegatedBalance: new Balance(0, CurrencyType.dataCredit), - dcEscrowBalance: new Balance(0, CurrencyType.dataCredit), dcToNetworkTokens: () => undefined, floatToBalance: () => undefined, formattedDcValue: '', @@ -423,7 +404,6 @@ const initialState = { atas: [], updating: false, solToken: undefined, - dcEscrowToken: undefined, tokenAccounts: undefined, } const BalanceContext = @@ -433,7 +413,7 @@ const { Provider } = BalanceContext export const BalanceProvider = ({ children }: { children: ReactNode }) => { const balanceHook = useBalanceHook() - const { atas, dcEscrowToken, solToken } = balanceHook + const { atas, solToken } = balanceHook const { cluster } = useSolana() const prevSolAddress = usePrevious(solToken?.tokenAccount) const prevCluster = usePrevious(cluster) @@ -452,12 +432,6 @@ export const BalanceProvider = ({ children }: { children: ReactNode }) => { {atas?.map((ta) => ( ))} - {dcEscrowToken?.tokenAccount && ( - - )} {solToken?.tokenAccount && ( )} diff --git a/src/utils/StoreSolBalance.ts b/src/utils/StoreSolBalance.ts index a0fe5a8ff..92cf74464 100644 --- a/src/utils/StoreSolBalance.ts +++ b/src/utils/StoreSolBalance.ts @@ -23,7 +23,6 @@ const StoreSolBalance = ({ solanaAddress }: Props) => { cluster, solanaAddress, balance: Number(amount), - type: 'sol', tokenAccount: solanaAddress, }), ) diff --git a/src/utils/StoreTokenBalance.ts b/src/utils/StoreTokenBalance.ts index 9a345eaac..25d29f74d 100644 --- a/src/utils/StoreTokenBalance.ts +++ b/src/utils/StoreTokenBalance.ts @@ -1,18 +1,17 @@ import { useTokenAccount } from '@helium/helium-react-hooks' +import { AccountLayout } from '@solana/spl-token' import { PublicKey } from '@solana/web3.js' import { useEffect } from 'react' -import { AccountLayout } from '@solana/spl-token' +import { useSolana } from '../solana/SolanaProvider' import { useAccountStorage } from '../storage/AccountStorageProvider' import { balancesSlice } from '../store/slices/balancesSlice' import { useAppDispatch } from '../store/store' -import { useSolana } from '../solana/SolanaProvider' type TokenInput = { tokenAccount: string - type: 'dcEscrow' | 'sol' } -const StoreTokenBalance = ({ tokenAccount, type }: TokenInput) => { +const StoreTokenBalance = ({ tokenAccount }: TokenInput) => { const tokenAccountResponse = useTokenAccount(new PublicKey(tokenAccount)) const { currentAccount } = useAccountStorage() const dispatch = useAppDispatch() @@ -39,7 +38,6 @@ const StoreTokenBalance = ({ tokenAccount, type }: TokenInput) => { cluster, solanaAddress: currentAccount?.solanaAddress, balance: amount, - type, tokenAccount, }), ) @@ -49,7 +47,6 @@ const StoreTokenBalance = ({ tokenAccount, type }: TokenInput) => { dispatch, tokenAccount, tokenAccountResponse, - type, ]) return null diff --git a/src/utils/solanaUtils.ts b/src/utils/solanaUtils.ts index 314b0c3ae..9843531aa 100644 --- a/src/utils/solanaUtils.ts +++ b/src/utils/solanaUtils.ts @@ -118,6 +118,30 @@ import { import { getH3Location } from './h3' import * as Logger from './logger' import sleep from './sleep' +import { decimalSeparator, groupSeparator } from './i18n' + +export function humanReadable( + amount?: BN, + decimals?: number, +): string | undefined { + if (typeof decimals === 'undefined' || typeof amount === 'undefined') return + + const input = amount.toString() + const integerPart = + input.length > decimals ? input.slice(0, input.length - decimals) : '' + const formattedIntegerPart = integerPart.replace( + /\B(?=(\d{3})+(?!\d))/g, + groupSeparator, + ) + const decimalPart = input + .slice(-decimals) + .padStart(decimals, '0') // Add prefix zeros + .replace(/0+$/, '') // Remove trailing zeros + + return `${formattedIntegerPart.length > 0 ? formattedIntegerPart : '0'}${ + Number(decimalPart) !== 0 ? `${decimalSeparator}${decimalPart}` : '' + }` +} const govProgramId = new PublicKey( 'hgovkRU6Ghe1Qoyb54HdSLdqN7VtxaifBzRmh9jtd3S', @@ -655,16 +679,20 @@ export const delegateDataCredits = async ( } } -export const getEscrowTokenAccount = (address: string) => { - try { - const subDao = IOT_SUB_DAO_KEY - const delegatedDataCredits = delegatedDataCreditsKey(subDao, address)[0] - const escrowTokenAccount = escrowAccountKey(delegatedDataCredits)[0] - - return escrowTokenAccount - } catch (e) { - Logger.error(e) - throw e as Error +export const getEscrowTokenAccount = ( + address: string | undefined, + subDao: PublicKey, +) => { + if (address) { + try { + const delegatedDataCredits = delegatedDataCreditsKey(subDao, address)[0] + const escrowTokenAccount = escrowAccountKey(delegatedDataCredits)[0] + + return escrowTokenAccount + } catch (e) { + Logger.error(e) + throw e as Error + } } } @@ -1633,7 +1661,9 @@ export const updateEntityInfoTxn = async ({ ) const mobileInfo = await program.account.mobileHotspotInfoV0.fetchNullable( - mobileInfoKey(mobileConfigKey, entityKey)[0], + ( + await mobileInfoKey(mobileConfigKey, entityKey) + )[0], ) if (!mobileInfo) { diff --git a/yarn.lock b/yarn.lock index 8ae1a13ee..27041af85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2275,13 +2275,6 @@ dependencies: "@solana/web3.js" "^1.43.4" -"@helium/account-fetch-cache@^0.2.5": - version "0.2.5" - resolved "https://registry.yarnpkg.com/@helium/account-fetch-cache/-/account-fetch-cache-0.2.5.tgz#518e945abd51bad1811ff0b4b5c80d62ebafdb6f" - integrity sha512-Cv8ST15awWpaHJGkY3SGeb+BuZ0wzbS3AMtQ8ZAeUr+XuJ5mbaGZUE9QPI9dNPKV1txzgn4JkEs+BQywt8LwRg== - dependencies: - "@solana/web3.js" "^1.43.4" - "@helium/address@4.6.2": version "4.6.2" resolved "https://registry.yarnpkg.com/@helium/address/-/address-4.6.2.tgz#0356bd9693ff7184f93f3c4e12c04f4f9c1db7b6" @@ -2291,15 +2284,6 @@ js-sha256 "^0.9.0" multiformats "^9.6.4" -"@helium/address@^4.10.2": - version "4.10.2" - resolved "https://registry.yarnpkg.com/@helium/address/-/address-4.10.2.tgz#56960b118fceb6b6ddabe3e4ecec467d9ae50e26" - integrity sha512-qCswC7Z3GXuJyHv36RcOSnffeghjqJQx0fdu2Lxpf9fgOnIi1JZO2tjjk1mBaqOwCyp+0YzrTPUoEukL/WCtsA== - dependencies: - bs58 "^5.0.0" - js-sha256 "^0.9.0" - multiformats "^9.6.4" - "@helium/address@^4.6.2", "@helium/address@^4.8.0", "@helium/address@^4.8.1": version "4.8.1" resolved "https://registry.yarnpkg.com/@helium/address/-/address-4.8.1.tgz#d8d7cefc6aa7791d79eb8759befb821aaccec3ff" @@ -2317,6 +2301,18 @@ "@solana/spl-token" "^0.3.6" "@solana/web3.js" "^1.43.4" +"@helium/circuit-breaker-sdk@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/circuit-breaker-sdk/-/circuit-breaker-sdk-0.0.32.tgz#e7fbafdadae1078290b8d3f0b53b81bf7b4628e7" + integrity sha512-dFKFc2UehuTVHKANWXX8GUfkmmKqLQX5aOX5+Ngm5aWkgZSkGZEbjl1G/ke8B6xwH3sm+fe19ID+mtBseuk2mw== + dependencies: + "@coral-xyz/anchor" "^0.26.0" + "@helium/idls" "^0.0.32" + "@helium/spl-utils" "^0.0.32" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + "@helium/circuit-breaker-sdk@^0.1.2": version "0.1.2" resolved "https://registry.yarnpkg.com/@helium/circuit-breaker-sdk/-/circuit-breaker-sdk-0.1.2.tgz#b7f684ba1a5dbc36027a66b85c8914a7ca0e43c7" @@ -2329,6 +2325,18 @@ bn.js "^5.2.0" bs58 "^4.0.1" +"@helium/circuit-breaker-sdk@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/circuit-breaker-sdk/-/circuit-breaker-sdk-0.1.4.tgz#53a49a70d533540e4118c19f2d04cd63c556b390" + integrity sha512-9Fa1zxhYO9Nh+iZuPgA4dpyAp9Le2TRoVRu/caWWDC8DNC9Ba2Hd/xeWbRDExymryVZqq741U57OiAi3cPXwbQ== + dependencies: + "@coral-xyz/anchor" "^0.26.0" + "@helium/idls" "^0.1.1" + "@helium/spl-utils" "^0.1.4" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + "@helium/circuit-breaker-sdk@^0.2.14": version "0.2.14" resolved "https://registry.yarnpkg.com/@helium/circuit-breaker-sdk/-/circuit-breaker-sdk-0.2.14.tgz#a325cf881f8dec6b7f398a4a08f8a74e70610d63" @@ -2387,23 +2395,18 @@ bs58 "^4.0.1" crypto-js "^4.1.1" -"@helium/distributor-oracle@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/distributor-oracle/-/distributor-oracle-0.2.14.tgz#677dccd5167333adea2cc2d777c66d677b330568" - integrity sha512-2ecSvRYVvWPh48mkh6mLnCgghlZVDcFDHE/KLKermCR5HUFrATFuNmFGyDMMCzUZ4qufM915iK76X1/SgdyCsA== +"@helium/distributor-oracle@file:.yalc/@helium/distributor-oracle": + version "0.1.2" dependencies: "@coral-xyz/anchor" "^0.26.0" "@fastify/cors" "^8.1.1" - "@helium/account-fetch-cache" "^0.2.14" - "@helium/address" "^4.10.2" - "@helium/helium-entity-manager-sdk" "^0.2.14" - "@helium/helium-sub-daos-sdk" "^0.2.14" - "@helium/idls" "^0.2.5" - "@helium/lazy-distributor-sdk" "^0.2.14" - "@helium/rewards-oracle-sdk" "^0.2.14" - "@helium/spl-utils" "^0.2.14" - "@metaplex-foundation/mpl-bubblegum" "^0.7.0" - "@solana/spl-token" "^0.3.8" + "@helium/address" "^4.6.2" + "@helium/helium-entity-manager-sdk" "^0.1.2" + "@helium/helium-sub-daos-sdk" "^0.1.2" + "@helium/idls" "^0.1.1" + "@helium/lazy-distributor-sdk" "^0.1.2" + "@helium/rewards-oracle-sdk" "^0.1.1" + "@helium/spl-utils" "^0.1.2" "@types/sequelize" "^4.28.14" aws-sdk "^2.1313.0" axios "^0.27.2" @@ -2428,26 +2431,44 @@ bn.js "^5.2.0" bs58 "^4.0.1" -"@helium/helium-entity-manager-sdk@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/helium-entity-manager-sdk/-/helium-entity-manager-sdk-0.2.14.tgz#f2a864797daf03a32f6da52f6d9ab56c8dc259c1" - integrity sha512-mWZ10jo1MxwpeB+Mw9JZ5kmRU6gYwJSHUisCuwsi/0OSnZI8l9QlRGsM3HrLA9RnuCeUD+2h+/56wdtF9esTmg== +"@helium/helium-entity-manager-sdk@^0.1.2": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@helium/helium-entity-manager-sdk/-/helium-entity-manager-sdk-0.1.5.tgz#96457885d125c781831a1b595b3cb5e3d6a91f1d" + integrity sha512-1zvavQVXDXmH5IFKYJJwGPxV4iMPQYiGJKk6do1jGFFizfGelDD7raUq+csnMiNExYQeOT8vQSyjNpQuYKjU2g== dependencies: - "@coral-xyz/anchor" "^0.26.0" - "@helium/address" "^4.10.2" - "@helium/anchor-resolvers" "^0.2.5" - "@helium/helium-sub-daos-sdk" "^0.2.14" - "@helium/idls" "^0.2.5" - "@helium/spl-utils" "^0.2.14" + "@coral-xyz/anchor" "0.26.0" + "@helium/address" "^4.6.2" + "@helium/helium-sub-daos-sdk" "^0.1.4" + "@helium/idls" "^0.1.1" + "@helium/spl-utils" "^0.1.4" + "@metaplex-foundation/mpl-bubblegum" "^0.6.2" + "@metaplex-foundation/mpl-token-metadata" "^2.2.3" + "@solana/spl-account-compression" "^0.1.5" + "@solana/spl-token" "^0.3.6" bn.js "^5.2.0" bs58 "^4.0.1" crypto-js "^4.1.1" js-sha256 "^0.9.0" -"@helium/helium-react-hooks@0.2.14": +"@helium/helium-entity-manager-sdk@file:.yalc/@helium/helium-entity-manager-sdk": + version "0.0.32" + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/address" "^4.6.2" + "@helium/helium-sub-daos-sdk" "^0.0.32" + "@helium/idls" "^0.0.32" + "@helium/spl-utils" "^0.0.32" + "@metaplex-foundation/mpl-bubblegum" "^0.6.2" + "@metaplex-foundation/mpl-token-metadata" "^2.2.3" + "@solana/spl-account-compression" "^0.1.5" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + crypto-js "^4.1.1" + js-sha256 "^0.9.0" + +"@helium/helium-react-hooks@file:.yalc/@helium/helium-react-hooks": version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/helium-react-hooks/-/helium-react-hooks-0.2.14.tgz#82eead80f801ae9b0a46daca3fae38860d22dd35" - integrity sha512-vtkA6YVVoARm+WD50x7/jvUWg/s64KnIS+Gl2UVx6otsgtdPWKEM/iEAG4z/I6Ri1z/q+yLUOnjps5xuuKBToA== dependencies: "@coral-xyz/anchor" "^0.26.0" "@helium/account-fetch-cache" "^0.2.14" @@ -2471,6 +2492,32 @@ bn.js "^5.2.0" bs58 "^4.0.1" +"@helium/helium-sub-daos-sdk@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/helium-sub-daos-sdk/-/helium-sub-daos-sdk-0.0.32.tgz#0141a03a67e67fc63fc95e12d2983d5476f2e348" + integrity sha512-1jGpoVSuqJAP+omnRXet0EVJlooP/pulml4x1hbE3XtCFOhU0Ev31RFmoAuuVZmpuKdP8CtUzyEjQpOzO2yqsA== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/circuit-breaker-sdk" "^0.0.32" + "@helium/spl-utils" "^0.0.32" + "@helium/treasury-management-sdk" "^0.0.32" + "@helium/voter-stake-registry-sdk" "^0.0.32" + bn.js "^5.2.0" + bs58 "^4.0.1" + +"@helium/helium-sub-daos-sdk@^0.1.2", "@helium/helium-sub-daos-sdk@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/helium-sub-daos-sdk/-/helium-sub-daos-sdk-0.1.4.tgz#99852310f0f8fa4e7afa2d128f3d2eff884b65d4" + integrity sha512-O7OiEYrZeLBHJJAdzPuG3JygrZ4i+cb3l5QnyQ+pIVpunuOfsA+fNpzgzDH2MBE9MDUkOr3kR3uSF3Jy3DA9ww== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/circuit-breaker-sdk" "^0.1.4" + "@helium/spl-utils" "^0.1.4" + "@helium/treasury-management-sdk" "^0.1.4" + "@helium/voter-stake-registry-sdk" "^0.1.4" + bn.js "^5.2.0" + bs58 "^4.0.1" + "@helium/http@4.7.5": version "4.7.5" resolved "https://registry.yarnpkg.com/@helium/http/-/http-4.7.5.tgz#c78ffcba77d29b9ef5514adfd41c08412ee8a8d3" @@ -2484,6 +2531,17 @@ retry-axios "^2.1.2" snakecase-keys "^5.1.0" +"@helium/idls@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/idls/-/idls-0.0.32.tgz#5b5ce1b8fabfbe6494d1fa0b1eb202dd19f4e2c6" + integrity sha512-74s0qqHdwk/X5iWPcGxytOIsrjeLo4xB87koy99/2Tilht085pu0RdEnM9TwTg3Nx7zaRTcr82yt1cjOySoCFg== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@solana/web3.js" "^1.43.4" + bn.js "^5.2.0" + borsh "^0.7.0" + bs58 "^4.0.1" + "@helium/idls@^0.0.43": version "0.0.43" resolved "https://registry.yarnpkg.com/@helium/idls/-/idls-0.0.43.tgz#de77dccd27411f6f2eed6daabb8b1ea1f600fe19" @@ -2517,27 +2575,27 @@ borsh "^0.7.0" bs58 "^4.0.1" -"@helium/lazy-distributor-sdk@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@helium/lazy-distributor-sdk/-/lazy-distributor-sdk-0.1.2.tgz#fba4313826eee6ce199143104bbd502c29d25711" - integrity sha512-kAFexiDHjGbEpm2H+C/8omOlu+0pClX61js8eslZxJgtWoLjMa+iwWNp2CPILDplsP/pKJyMPEHFHW67+ezCMQ== +"@helium/lazy-distributor-sdk@^0.1.2": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/lazy-distributor-sdk/-/lazy-distributor-sdk-0.1.4.tgz#f221cb946bb7730c6422c901d56a0588c92f6b10" + integrity sha512-8Ouh1lqmi7Tt6m3Vr3NNrxK/6VJ9qs6w9Aj/PUjhc8oc8uaOCJ4qrwNLwq4fHogsn9XduE/JBKROGCyL9iOFEQ== dependencies: "@coral-xyz/anchor" "0.26.0" - "@helium/circuit-breaker-sdk" "^0.1.2" - "@helium/spl-utils" "^0.1.2" + "@helium/circuit-breaker-sdk" "^0.1.4" + "@helium/spl-utils" "^0.1.4" "@metaplex-foundation/mpl-token-metadata" "^2.2.3" "@solana/spl-token" "^0.3.6" bn.js "^5.2.0" bs58 "^4.0.1" -"@helium/lazy-distributor-sdk@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/lazy-distributor-sdk/-/lazy-distributor-sdk-0.2.14.tgz#5989317a2ef1aed0235b21dfdd73fa5307227604" - integrity sha512-+3hNVpwOV0PSBgysunEZYI7rHXB1fLq3n3BbVva7kb0gm0QAwJcoI2NPVn98jI3x1jCgQnw0SYAPUFAUiYV0nw== +"@helium/lazy-distributor-sdk@file:.yalc/@helium/lazy-distributor-sdk": + version "0.1.2" dependencies: - "@coral-xyz/anchor" "^0.26.0" - "@helium/anchor-resolvers" "^0.2.5" - "@helium/circuit-breaker-sdk" "^0.2.14" + "@coral-xyz/anchor" "0.26.0" + "@helium/circuit-breaker-sdk" "^0.1.2" + "@helium/spl-utils" "^0.1.2" + "@metaplex-foundation/mpl-token-metadata" "^2.2.3" + "@solana/spl-token" "^0.3.6" bn.js "^5.2.0" bs58 "^4.0.1" @@ -2569,17 +2627,44 @@ resolved "https://registry.yarnpkg.com/@helium/react-native-sdk/-/react-native-sdk-1.0.0.tgz#41024fa99859490bd8a0b717f52acc11ae72f114" integrity sha512-Qi1Nnp/q2hsz2D7aeuM6LxXhNX8NrHz1U+PoQslwK2XfqPFZEYb4uAzjXDKlc+JBWPiF96GMJywv/ofxlZ9XLg== -"@helium/rewards-oracle-sdk@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/rewards-oracle-sdk/-/rewards-oracle-sdk-0.2.14.tgz#8422914271821b43850572da677866870adabdeb" - integrity sha512-VE4FJy43tvvIdEoJBHch2+BlQzeBaDdcxzOZPXftVM9gxL0sHxlAKRXsozgg6eRB3mowMKd6EHa4FxJztgMBMA== +"@helium/rewards-oracle-sdk@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@helium/rewards-oracle-sdk/-/rewards-oracle-sdk-0.1.1.tgz#b056b73e0a0b556b22c3190ece80aa5d52fe62c1" + integrity sha512-Qo5WZ+isTaznv3KNK92V44h7s+AWcD4de/J4pR7Gekii1F9p+0uY/AQAjHyXTUMxBcZu9UxZK19xtUnt5R4K5A== dependencies: "@coral-xyz/anchor" "^0.26.0" - "@helium/anchor-resolvers" "^0.2.5" "@helium/idls" "^0.0.43" + "@helium/spl-utils" "^0.0.43" + "@solana/spl-token" "^0.3.6" bn.js "^5.2.0" bs58 "^4.0.1" +"@helium/spl-utils@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.0.32.tgz#f665611767b398eb2d6024d9b9e5ddbee40e9191" + integrity sha512-VWp3Ve02X2fOd49Nojfw4yDDFH/Iqi/iZ9AbeTJMpfWSQsixFULVeBGADQQFa4xiIYynI3x+zX5Uo1wzgZuxlw== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/address" "^4.8.1" + "@solana/spl-token" "^0.3.6" + "@solana/web3.js" "^1.43.4" + bn.js "^5.2.0" + borsh "^0.7.0" + bs58 "^5.0.0" + +"@helium/spl-utils@^0.0.43": + version "0.0.43" + resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.0.43.tgz#7b5d7266e5ea56f5fbb3e7635831378f90f90a8a" + integrity sha512-RfETETah5MtKVoZqMmIzeMTgpFdL6bfs1e+7+2U8zcmGPyi8zMNyRDyRWtQZiknkbBtpORfgJEaP3TXwQBaxSQ== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/address" "^4.8.1" + "@solana/spl-token" "^0.3.6" + "@solana/web3.js" "^1.43.4" + bn.js "^5.2.0" + borsh "^0.7.0" + bs58 "^5.0.0" + "@helium/spl-utils@^0.1.2": version "0.1.2" resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.1.2.tgz#e12b924bf4bd3217f265250a2720cb7ed2316d1d" @@ -2594,16 +2679,13 @@ borsh "^0.7.0" bs58 "^5.0.0" -"@helium/spl-utils@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.2.14.tgz#7d9bcc8236095d81c9cea661c9ca32741cb70bf6" - integrity sha512-joRHzlFppePOymHQ8GpAXYLfsfOZZ1t8k0OD0+c6ceuWUpx5N6Fu2YUu0Yv9Rj2nvFnl++G0DSmy1+Q8yvkOGA== +"@helium/spl-utils@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.1.4.tgz#214b6076e76d2cd0095758ed3db33f0824048df3" + integrity sha512-QhEhJuOd9P8GbUKx5f9zI1m2zjN9si/IrAlDQk4gkFBDFsi4szzY03rj4CwyhmwIYJk/qi1b4JiMoRIinFutJg== dependencies: - "@coral-xyz/anchor" "^0.26.0" - "@helium/account-fetch-cache" "^0.2.14" - "@helium/address" "^4.10.2" - "@helium/anchor-resolvers" "^0.2.5" - "@metaplex-foundation/mpl-token-metadata" "^2.5.2" + "@coral-xyz/anchor" "0.26.0" + "@helium/address" "^4.8.1" "@solana/spl-account-compression" "^0.1.7" "@solana/spl-token" "^0.3.6" "@solana/web3.js" "^1.43.4" @@ -2611,16 +2693,11 @@ borsh "^0.7.0" bs58 "^5.0.0" -"@helium/spl-utils@^0.2.6": - version "0.2.6" - resolved "https://registry.yarnpkg.com/@helium/spl-utils/-/spl-utils-0.2.6.tgz#20b136f13d9e1d58e7032b4c55b5cc0c1ad9f6dc" - integrity sha512-Ut1bdWRMyru4YOYFB4NS31fbSGYTtW3gMxEg3/c+SKMwAfoZcRIOE8FgOV1nugSrFJ570zsx8R7lHIQYfAOmog== +"@helium/spl-utils@file:.yalc/@helium/spl-utils": + version "0.1.2" dependencies: - "@coral-xyz/anchor" "^0.26.0" - "@helium/account-fetch-cache" "^0.2.5" + "@coral-xyz/anchor" "0.26.0" "@helium/address" "^4.8.1" - "@helium/anchor-resolvers" "^0.2.5" - "@metaplex-foundation/mpl-token-metadata" "^2.5.2" "@solana/spl-account-compression" "^0.1.7" "@solana/spl-token" "^0.3.6" "@solana/web3.js" "^1.43.4" @@ -2652,6 +2729,32 @@ bn.js "^5.2.0" bs58 "^4.0.1" +"@helium/treasury-management-sdk@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/treasury-management-sdk/-/treasury-management-sdk-0.0.32.tgz#e726d2dff0354c7d1e5c76327f18c3a8a2e5d34b" + integrity sha512-v3at7PDwm8OiMf2fOpsdsSR0FSeOQU7wBb5bwcA5RoZ8vaqWmgi7Mdi8xLwl+dVUyX9EnQkcpisvK4qcwHGfVA== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/circuit-breaker-sdk" "^0.0.32" + "@helium/idls" "^0.0.32" + "@helium/spl-utils" "^0.0.32" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + +"@helium/treasury-management-sdk@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/treasury-management-sdk/-/treasury-management-sdk-0.1.4.tgz#6d3ad274c3d3a7209ebeca6f901f9356e62c973a" + integrity sha512-w7hUTsP+kMMH5f0M/0VqOQ2KzdRACuY5qDHPt4X7VvjgjWFnps/mIHBXV1P2hG2YZDN9CiCSMwwjT9MFHISUiA== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/circuit-breaker-sdk" "^0.1.4" + "@helium/idls" "^0.1.1" + "@helium/spl-utils" "^0.1.4" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + "@helium/treasury-management-sdk@^0.2.14": version "0.2.14" resolved "https://registry.yarnpkg.com/@helium/treasury-management-sdk/-/treasury-management-sdk-0.2.14.tgz#9a640c38f7e7de9e302c8fa3711b683735ca8285" @@ -2677,6 +2780,32 @@ bn.js "^5.2.0" bs58 "^4.0.1" +"@helium/voter-stake-registry-sdk@^0.0.32": + version "0.0.32" + resolved "https://registry.yarnpkg.com/@helium/voter-stake-registry-sdk/-/voter-stake-registry-sdk-0.0.32.tgz#e40d39188bc5fbf8c76173172624f30bf68dd806" + integrity sha512-7NyIx1dsYzxAv3/nN4XqVY7LPGDZNtPn6HuPYXu5WUjARrc/MEIK1gpvPyKPDU90MJ580hZwF2WDyVx4r9hPXw== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/idls" "^0.0.32" + "@helium/spl-utils" "^0.0.32" + "@metaplex-foundation/mpl-token-metadata" "^2.2.3" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + +"@helium/voter-stake-registry-sdk@^0.1.4": + version "0.1.4" + resolved "https://registry.yarnpkg.com/@helium/voter-stake-registry-sdk/-/voter-stake-registry-sdk-0.1.4.tgz#41d46d1b0364c710aff51df756ed5a2521bf96e7" + integrity sha512-8f+dWaS1IbSuybrvyvchuOd/NP9fCx8jCVyl02pKkURFZC0WdPckiaw+5kh2/y29nwwZJlVqdu7I7C2TR/6uyQ== + dependencies: + "@coral-xyz/anchor" "0.26.0" + "@helium/idls" "^0.1.1" + "@helium/spl-utils" "^0.1.4" + "@metaplex-foundation/mpl-token-metadata" "^2.2.3" + "@solana/spl-token" "^0.3.6" + bn.js "^5.2.0" + bs58 "^4.0.1" + "@helium/voter-stake-registry-sdk@^0.2.14": version "0.2.14" resolved "https://registry.yarnpkg.com/@helium/voter-stake-registry-sdk/-/voter-stake-registry-sdk-0.2.14.tgz#650fe667bf9cec21af66cd8123185a7526fed666" @@ -3246,10 +3375,10 @@ bn.js "^5.2.0" js-sha3 "^0.8.0" -"@metaplex-foundation/mpl-bubblegum@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@metaplex-foundation/mpl-bubblegum/-/mpl-bubblegum-0.7.0.tgz#b34067ad4fe846ceb60e47e49f221ecf4730add7" - integrity sha512-HCo6q+nh8M3KRv9/aUaZcJo5/vPJEeZwPGRDWkqN7lUXoMIvhd83fZi7MB1rIg1gwpVHfHqim0A02LCYKisWFg== +"@metaplex-foundation/mpl-bubblegum@^0.6.2": + version "0.6.2" + resolved "https://registry.yarnpkg.com/@metaplex-foundation/mpl-bubblegum/-/mpl-bubblegum-0.6.2.tgz#e1b098ccef10899b0d759a03e3d4b1ae7bdc9f0c" + integrity sha512-4tF7/FFSNtpozuIGD7gMKcqK2D49eVXZ144xiowC5H1iBeu009/oj2m8Tj6n4DpYFKWJ2JQhhhk0a2q7x0Begw== dependencies: "@metaplex-foundation/beet" "0.7.1" "@metaplex-foundation/beet-solana" "0.4.0" @@ -3258,6 +3387,7 @@ "@solana/spl-account-compression" "^0.1.4" "@solana/spl-token" "^0.1.8" "@solana/web3.js" "^1.50.1" + bn.js "^5.2.0" js-sha3 "^0.8.0" "@metaplex-foundation/mpl-candy-guard@^0.3.0": @@ -3866,6 +3996,18 @@ js-sha3 "^0.8.0" typescript-collections "^1.3.3" +"@solana/spl-account-compression@^0.1.5": + version "0.1.10" + resolved "https://registry.yarnpkg.com/@solana/spl-account-compression/-/spl-account-compression-0.1.10.tgz#b3135ce89349d6090832b3b1d89095badd57e969" + integrity sha512-IQAOJrVOUo6LCgeWW9lHuXo6JDbi4g3/RkQtvY0SyalvSWk9BIkHHe4IkAzaQw8q/BxEVBIjz8e9bNYWIAESNw== + dependencies: + "@metaplex-foundation/beet" "^0.7.1" + "@metaplex-foundation/beet-solana" "^0.4.0" + bn.js "^5.2.1" + borsh "^0.7.0" + js-sha3 "^0.8.0" + typescript-collections "^1.3.3" + "@solana/spl-token@0.3.6": version "0.3.6" resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.6.tgz#35473ad2ed71fe91e5754a2ac72901e1b8b26a42" @@ -3896,15 +4038,6 @@ "@solana/buffer-layout-utils" "^0.2.0" buffer "^6.0.3" -"@solana/spl-token@^0.3.8": - version "0.3.8" - resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.8.tgz#8e9515ea876e40a4cc1040af865f61fc51d27edf" - integrity sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/buffer-layout-utils" "^0.2.0" - buffer "^6.0.3" - "@solana/wallet-adapter-base@^0.9.17", "@solana/wallet-adapter-base@^0.9.2", "@solana/wallet-adapter-base@^0.9.21", "@solana/wallet-adapter-base@^0.9.22": version "0.9.22" resolved "https://registry.yarnpkg.com/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.22.tgz#97812eaf6aebe01e5fe714326b3c9a0614ae6112"