Skip to content

Commit

Permalink
Fix crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass committed Dec 13, 2023
1 parent 02b0da3 commit 0aadb19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@helium/lazy-distributor-sdk": "^0.4.0",
"@helium/onboarding": "^4.10.3",
"@helium/proto-ble": "4.0.0",
"@helium/react-native-sdk": "^3.0.1",
"@helium/react-native-sdk": "^3.0.2",
"@helium/spl-utils": "^0.4.0",
"@helium/transactions": "4.8.1",
"@helium/treasury-management-sdk": "^0.4.0",
Expand Down
13 changes: 8 additions & 5 deletions src/features/swaps/SwapScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const SwapScreen = () => {
const validInputMints = useMemo(() => {
if (isDevnet)
return [HNT_MINT.toBase58(), MOBILE_MINT.toBase58(), IOT_MINT.toBase58()]
return [...routeMap.keys()].filter((key) => visibleTokens.has(key))
return [...routeMap.keys()].filter((key) => key && visibleTokens.has(key))
}, [visibleTokens, routeMap, isDevnet])

const validOutputMints = useMemo(() => {
Expand All @@ -140,7 +140,9 @@ const SwapScreen = () => {
.get(inputMint?.toBase58() || '')
?.filter(
(key) =>
visibleTokens.has(key) && !inputMint.equals(new PublicKey(key)),
key &&
visibleTokens.has(key) &&
!inputMint.equals(new PublicKey(key)),
) || []

return inputMint.equals(HNT_MINT)
Expand Down Expand Up @@ -252,6 +254,7 @@ const SwapScreen = () => {
if (!inputMint.equals(HNT_MINT) && !outputMint.equals(DC_MINT)) {
if (
validOutputMints &&
validOutputMints[0] &&
!validOutputMints?.includes(outputMint?.toBase58() || '')
) {
setOutputMint(new PublicKey(validOutputMints[0]))
Expand Down Expand Up @@ -383,15 +386,15 @@ const SwapScreen = () => {

return {
mint: pk,
selected: inputMint.equals(pk),
selected: pk ? inputMint.equals(pk) : false,
}
}),
[SelectorMode.youReceive]: validOutputMints.map((mint) => {
const pk = new PublicKey(mint)

return {
mint: pk,
selected: outputMint.equals(pk),
selected: pk ? outputMint.equals(pk) : false,
}
}),
}
Expand Down Expand Up @@ -573,7 +576,7 @@ const SwapScreen = () => {
)

const handleSwapTokens = useCallback(async () => {
if (connection) {
if (connection && currentAccount?.solanaAddress) {
try {
setSwapping(true)

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2707,10 +2707,10 @@
dependencies:
protobufjs "^6.11.3"

"@helium/react-native-sdk@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@helium/react-native-sdk/-/react-native-sdk-3.0.1.tgz#1e5d0d9ce74405206aca2364dfad1efa43dd3cb4"
integrity sha512-KdslCmd2gt8HC4icDTmi+FnLdAxTxY9OA83uPmn6m6PU2naQJDpCJWrRB/O8R4YgsjbZqpILbTnZG9hscPTtOw==
"@helium/react-native-sdk@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@helium/react-native-sdk/-/react-native-sdk-3.0.2.tgz#8ca616e6175b13f37edbd5c6ce93f47d002ded02"
integrity sha512-cnL3u3Im5mbIioEgzd1DwryFJ54CAY5K/trs035eHUt8ub2Fp65Cy4TLT4HSNOlZX8CgNrhWyowporLv7eVg1A==
dependencies:
"@azure/core-asynciterator-polyfill" "^1.0.2"
"@coral-xyz/anchor" "^0.26.0"
Expand Down

0 comments on commit 0aadb19

Please sign in to comment.