Skip to content

Commit

Permalink
Cancel transaction if not enough sol and not converting
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornM9 committed Aug 15, 2023
1 parent 426655d commit 3467e97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ Follow the instructions for "React Native CLI Quickstart" found [here](https://r
```bash
yarn
```
- Fill out your env.sample with your values and rename it to `.env`. Set up a Mapbox account and generate a public and private key for the access token and download token environment variables.

- Create a netrc file to authenticate with mapbox
```bash
touch ~/.netrc
nano ~/.netrc
```
- Insert your mapbox authentication details
```bash
machine api.mapbox.com
login mapbox
password <INSERT API TOKEN>
```
- Install Pods
```bash
yarn pod-install
Expand Down
11 changes: 8 additions & 3 deletions src/features/collectables/ClaimAllRewardsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ClaimAllRewardsScreen = () => {
const { showOKCancelAlert } = useAlert()
const { anchorProvider } = useSolana()
const showHNTConversionAlert = useCallback(async () => {
if (!anchorProvider || !hntSolConvertTransaction) return
if (!anchorProvider || !hntSolConvertTransaction) return false

const decision = await showOKCancelAlert({
title: t('browserScreen.insufficientSolToPayForFees'),
Expand All @@ -50,7 +50,7 @@ const ClaimAllRewardsScreen = () => {
}),
})

if (!decision) return
if (!decision) return false
const signed = await anchorProvider.wallet.signTransaction(
hntSolConvertTransaction,
)
Expand All @@ -62,6 +62,7 @@ const ClaimAllRewardsScreen = () => {
},
'confirmed',
)
return true
}, [
anchorProvider,
hntSolConvertTransaction,
Expand Down Expand Up @@ -92,7 +93,11 @@ const ClaimAllRewardsScreen = () => {
setClaimError(undefined)
setRedeeming(true)
if (!hasEnoughSol) {
await showHNTConversionAlert()
const success = await showHNTConversionAlert()
if (!success) {
setRedeeming(false)
return
}
}

const balanceChanges: BalanceChange[] = []
Expand Down

0 comments on commit 3467e97

Please sign in to comment.