Skip to content

Commit

Permalink
update web3.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler committed Oct 12, 2023
1 parent 68dc9eb commit f99908f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@solana/spl-token-registry": "0.2.4574",
"@solana/wallet-adapter-react": "0.15.33",
"@solana/wallet-standard-features": "1.0.0",
"@solana/web3.js": "1.64.0",
"@solana/web3.js": "1.67.2",
"@tradle/react-native-http": "2.0.1",
"@turf/bbox": "6.5.0",
"@turf/center": "6.5.0",
Expand Down
17 changes: 16 additions & 1 deletion src/features/account/AccountTokenScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Animated, {
useSharedValue,
} from 'react-native-reanimated'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { useModal } from '@storage/ModalsProvider'
import { useSolana } from '../../solana/SolanaProvider'
import { useAccountStorage } from '../../storage/AccountStorageProvider'
import { Activity } from '../../types/activity'
Expand Down Expand Up @@ -67,9 +68,10 @@ const AccountTokenScreen = () => {
const [topHeaderYPos, setTopHeaderYPos] = useState(0)
const [headerContainerYPos, setHeaderContainerYPos] = useState(0)
const listAnimatedPos = useSharedValue<number>(0)
const { cluster } = useSolana()
const { cluster, isDevnet } = useSolana()
const insets = useSafeAreaInsets()
const colors = useColors()
const { showModal } = useModal()
const [
onEndReachedCalledDuringMomentum,
setOnEndReachedCalledDuringMomentum,
Expand Down Expand Up @@ -496,6 +498,7 @@ const AccountTokenScreen = () => {
</Box>
</Animated.View>
{mint.equals(NATIVE_MINT) &&
!isDevnet &&
(amount || 0) < 0.02 * LAMPORTS_PER_SOL ? (
<Box
minHeight={topHeaderHeight}
Expand All @@ -507,6 +510,18 @@ const AccountTokenScreen = () => {
<Text variant="body2" color="black700">
{t('accountsScreen.solWarning')}
</Text>
<TouchableOpacityBox
marginTop="m"
justifyContent="center"
alignItems="center"
backgroundColor="orange500"
borderRadius="m"
onPress={() => showModal({ type: 'InsufficientSolConversion' })}
>
<Text variant="body1" padding="ms" color="black700">
{t('accountsScreen.solSwap')}
</Text>
</TouchableOpacityBox>
</Box>
) : (
<Box height={topHeaderHeight} />
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/useSimulatedTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AccountLayout, NATIVE_MINT, TOKEN_PROGRAM_ID } from '@solana/spl-token'
import {
AddressLookupTableAccount,
Connection,
Message,
LAMPORTS_PER_SOL,
ParsedAccountData,
PublicKey,
Expand Down Expand Up @@ -79,9 +78,7 @@ export function useSimulatedTransaction(
}

try {
fee =
(await c?.getFeeForMessage(t.message as Message, 'confirmed'))
.value || fee
fee = (await c?.getFeeForMessage(t.message, 'confirmed')).value || fee
} catch (err) {
logger.error(err)
}
Expand Down Expand Up @@ -134,6 +131,7 @@ export function useSimulatedTransaction(
),
),
]

const { blockhash } = await connection?.getLatestBlockhash()
transaction.message.recentBlockhash = blockhash
const result = await connection?.simulateTransaction(transaction, {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default {
},
solWarning:
'Your balance may not have enough SOL to cover all transactions. Solana wallets require a minimum of 0.00089088 SOL. We recommend keeping greater than 0.02 sol in your wallet for the best experience',
solSwap: 'Swap Tokens To SOL',
hideFilters: 'Hide Filters',
myTransactions: 'My Transactions',
showFilters: 'Show Filters',
Expand Down Expand Up @@ -389,7 +390,7 @@ export default {
},
insufficientSolConversionModal: {
title: 'Insufficient SOL',
body: 'You currently dont have enough SOL to perform this action. Please swap one of the following tokens to receive more SOL in order to continue. Tokens that you dont have any balance in will be disabled.',
body: 'Please swap one of the following tokens to receive more SOL in order to continue. Tokens that you dont have any balance in will be disabled.',
noBalance:
'You currently dont hold a balance of any of the tokens supported by this swap.',
},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4241,10 +4241,10 @@
"@wallet-standard/app" "^1.0.1"
"@wallet-standard/base" "^1.0.1"

"@solana/web3.js@1.64.0":
version "1.64.0"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.64.0.tgz#b7f5a976976039a0161242e94d6e1224ab5d30f9"
integrity sha512-AcFaoy48GxSmzBryVwB88C/UPJd/UQa+nFrO/uPc8ww6RCjanZY2vEZxdfTZub+q1NMUckwXpPwF32jJLe7SPA==
"@solana/web3.js@1.67.2":
version "1.67.2"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.67.2.tgz#6832139fb906ff2fb13390a81afab04d35b8aa0c"
integrity sha512-qfdV0m/qcTpoJsIwonvXJQz8YY5mrSfBVLS/Cp+MPaaUzDzkpSV7WU1QeHsj+dkHX82W37zuhhg/DadRJls7+g==
dependencies:
"@babel/runtime" "^7.12.5"
"@noble/ed25519" "^1.7.0"
Expand Down

0 comments on commit f99908f

Please sign in to comment.