99} from "@helium/helium-react-hooks" ;
1010import { HNT_MINT , toBN , toNumber } from "@helium/spl-utils" ;
1111import {
12- Position ,
1312 PositionWithMeta ,
1413 calcLockupMultiplier ,
1514 useCreatePosition ,
@@ -19,7 +18,7 @@ import { useWallet } from "@/hooks/useWallet";
1918import { PublicKey } from "@solana/web3.js" ;
2019import BN from "bn.js" ;
2120import { Loader2 } from "lucide-react" ;
22- import React , { FC , useCallback , useMemo , useState } from "react" ;
21+ import React , { FC , useCallback , useEffect , useMemo , useState } from "react" ;
2322import { toast } from "sonner" ;
2423import {
2524 LockTokensForm ,
@@ -31,6 +30,7 @@ import { SubDaoSelection } from "./SubDaoSelection";
3130import { Button } from "./ui/button" ;
3231import { Dialog , DialogContent , DialogTrigger } from "./ui/dialog" ;
3332import { PositionPreview } from "./PositionPreview" ;
33+ import { MOBILE_SUB_DAO_KEY } from "@/lib/constants" ;
3434
3535export const CreatePositionModal : FC < React . PropsWithChildren < { } > > = ( {
3636 children,
@@ -42,29 +42,25 @@ export const CreatePositionModal: FC<React.PropsWithChildren<{}>> = ({
4242 const [ formValues , setFormValues ] = useState < LockTokensFormValues > ( ) ;
4343 const [ selectedSubDaoPk , setSelectedSubDaoPk ] = useState < PublicKey > ( ) ;
4444 const { publicKey : wallet } = useWallet ( ) ;
45- const {
46- network,
47- mint,
48- subDaos,
49- registrar,
50- refetch : refetchState ,
51- } = useGovernance ( ) ;
45+ const { mint, subDaos, registrar, refetch : refetchState } = useGovernance ( ) ;
5246 const { amount : ownedAmount , decimals } = useOwnedAmount ( wallet , mint ) ;
5347 const { error : createPositionError , createPosition } = useCreatePosition ( ) ;
5448 const steps = useMemo ( ( ) => ( mint . equals ( HNT_MINT ) ? 3 : 2 ) , [ mint ] ) ;
5549
50+ useEffect ( ( ) => {
51+ if ( subDaos && ! selectedSubDaoPk ) {
52+ setSelectedSubDaoPk (
53+ subDaos . find ( ( subDao ) => subDao . pubkey . equals ( MOBILE_SUB_DAO_KEY ) )
54+ ?. pubkey || undefined
55+ ) ;
56+ }
57+ } , [ subDaos , selectedSubDaoPk , setSelectedSubDaoPk ] ) ;
58+
5659 const maxLockupAmount =
5760 ownedAmount && decimals
5861 ? toNumber ( new BN ( ownedAmount . toString ( ) ) , decimals )
5962 : 0 ;
6063
61- const selectedSubDao = useMemo (
62- ( ) =>
63- selectedSubDaoPk &&
64- subDaos ?. find ( ( subDao ) => subDao . pubkey . equals ( selectedSubDaoPk ! ) ) ! ,
65- [ selectedSubDaoPk , subDaos ]
66- ) ;
67-
6864 const handleCalcLockupMultiplier = useCallback (
6965 ( lockupPeriodInDays : number ) =>
7066 ( registrar &&
@@ -165,9 +161,7 @@ export const CreatePositionModal: FC<React.PropsWithChildren<{}>> = ({
165161 const subheading =
166162 ( step === 1 &&
167163 "Boost your voting power by strategically locking your tokens for a specified period, opting for either a constant or decaying lockup" ) ||
168- ( steps > 2 &&
169- step === 2 &&
170- "Choose whether to delegate your tokens to a subnetwork for rewards" ) ||
164+ ( steps > 2 && step === 2 && "Choose a subnetwork to delegate to" ) ||
171165 ( step === steps && "Review your position before creating it" ) ;
172166
173167 return (
@@ -196,21 +190,18 @@ export const CreatePositionModal: FC<React.PropsWithChildren<{}>> = ({
196190 { steps > 2 && step === 2 && (
197191 < >
198192 < div className = "flex flex-col gap-2" >
193+ < div className = "flex flex-col gap-4 p-4 text-sm bg-slate-600 rounded" >
194+ Delegating your position to a subnetwork and voting regularly
195+ earns you HNT rewards. Select the subnetwork you believe offers
196+ the greatest potential for growth and impact. This choice does
197+ not affect the rewarded amount.
198+ </ div >
199199 < SubDaoSelection
200+ hideNoneOption
200201 selectedSubDaoPk = { selectedSubDaoPk }
201202 onSelect = { setSelectedSubDaoPk }
202203 />
203204 < div className = "flex flex-col gap-4 p-4 text-sm bg-slate-600 rounded" >
204- < div >
205- < span className = "font-medium" >
206- By selecting a subnetwork, you indicate that:
207- </ span >
208- < ul className = "flex flex-col px-6 list-disc font-light" >
209- < li > You believe in that subnetwork</ li >
210- < li > You want to help increase the subnetworks Protocol Score</ li >
211- < li > You are willing to be an active participant in governance in order to receive HNT rewards (which can be claimed on a daily basis)</ li >
212- </ ul >
213- </ div >
214205 < div >
215206 < span className = "font-medium" >
216207 Remember the following before you delegate:
0 commit comments