@@ -17,22 +17,26 @@ import VoteBySwitch from 'pages/dao/[symbol]/proposal/components/VoteBySwitch'
1717import Button from '@components/Button'
1818import Tooltip from '@components/Tooltip'
1919import { getStakeSchema } from '@utils/validations'
20- import { getConvertToStSolInstruction } from '@utils/instructionTools'
20+ import { getConvertToJitoSolInstruction } from '@utils/instructionTools'
2121import { getInstructionDataFromBase64 } from '@solana/spl-governance'
2222import useQueryContext from '@hooks/useQueryContext'
2323import { useRouter } from 'next/router'
2424import { notify } from '@utils/notifications'
2525import useCreateProposal from '@hooks/useCreateProposal'
2626import { AssetAccount } from '@utils/uiTypes/assets'
27- import { PublicKey } from '@solana/web3.js'
2827import useWalletOnePointOh from '@hooks/useWalletOnePointOh'
2928import { useRealmQuery } from '@hooks/queries/realm'
3029import useLegacyConnectionContext from '@hooks/useLegacyConnectionContext'
31- import {
32- LIDO_PROGRAM_ID ,
33- LIDO_PROGRAM_ID_DEVNET ,
34- } from '@constants/pubkeys/lido'
3530import { useVoteByCouncilToggle } from '@hooks/useVoteByCouncilToggle'
31+ import { PublicKey } from '@solana/web3.js'
32+
33+ export const JITOSOL_MINT_ADDRESS = new PublicKey (
34+ 'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn' ,
35+ )
36+
37+ export const JITO_STAKE_POOL_ACCOUNT = new PublicKey (
38+ 'Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb' ,
39+ )
3640
3741const defaultFormState = {
3842 destinationAccount : undefined ,
@@ -44,39 +48,35 @@ const defaultFormState = {
4448
4549const notConnectedMessage =
4650 'You need to be connected to your wallet to have the ability to create a staking proposal'
51+
4752const getProposalText = ( amount ) => {
48- return `Convert ${ amount } SOL to stSOL `
53+ return `Convert ${ amount } SOL to JitoSOL `
4954}
5055
51- const LIDO_ADDRESS = '49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn'
52- const STSOL_MINT = '7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj'
53-
54- const LIDO_ADDRESS_DEVNET = '8sqs4Jzs8uq7CEtimhXf32gioVUN3n5Qk65YMkNU5E4F'
55- const STSOL_MINT_DEVNET = '5nnLCgZn1EQaLj1ub8vYbQgBhkWi97x4JC5ARVPhci4V'
56-
57- const ConvertToStSol = ( ) => {
56+ const ConvertToJitoSol = ( ) => {
5857 const realm = useRealmQuery ( ) . data ?. result
5958 const { symbol } = useRealm ( )
6059 const { canUseTransferInstruction } = useGovernanceAssets ( )
6160 const { governedTokenAccounts } = useGovernanceAssets ( )
6261 const { fmtUrlWithCluster } = useQueryContext ( )
6362 const router = useRouter ( )
6463 const { handleCreateProposal } = useCreateProposal ( )
65-
6664 const connection = useLegacyConnectionContext ( )
6765 const wallet = useWalletOnePointOh ( )
6866 const currentAccount = useTreasuryAccountStore ( ( s ) => s . currentAccount )
6967
7068 const [ formErrors , setFormErrors ] = useState ( { } )
71- const [ stSolTokenAccounts , setStSolTokenAccounts ] = useState < AssetAccount [ ] > (
72- [ ] ,
73- )
7469 const [ form , setForm ] = useState < StakingViewForm > ( defaultFormState )
7570 const [ showOptions , setShowOptions ] = useState ( false )
7671 const { voteByCouncil, shouldShowVoteByCouncilToggle, setVoteByCouncil } =
7772 useVoteByCouncilToggle ( )
7873 const [ isLoading , setIsLoading ] = useState ( false )
7974
75+ const jitoSolTokenAccounts = governedTokenAccounts . filter (
76+ ( acc ) =>
77+ acc . extensions . mint ?. publicKey . toString ( ) ===
78+ JITOSOL_MINT_ADDRESS . toString ( ) ,
79+ )
8080 const mintMinAmount = form . governedTokenAccount ?. extensions ?. mint
8181 ? getMintMinAmountAsDecimal (
8282 form . governedTokenAccount . extensions . mint . account ,
@@ -90,27 +90,15 @@ const ConvertToStSol = () => {
9090 }
9191
9292 const handlePropose = async ( ) => {
93- setIsLoading ( true )
93+ if ( currentAccount ?. governance === undefined ) throw new Error ( )
9494
95- let config = {
96- lidoAddress : new PublicKey ( LIDO_ADDRESS ) ,
97- stSolMint : new PublicKey ( STSOL_MINT ) ,
98- programId : new PublicKey ( LIDO_PROGRAM_ID ) ,
99- }
100- if ( connection . cluster === 'devnet' ) {
101- config = {
102- lidoAddress : new PublicKey ( LIDO_ADDRESS_DEVNET ) ,
103- stSolMint : new PublicKey ( STSOL_MINT_DEVNET ) ,
104- programId : new PublicKey ( LIDO_PROGRAM_ID_DEVNET ) ,
105- }
106- }
107- const instruction : UiInstruction = await getConvertToStSolInstruction ( {
95+ setIsLoading ( true )
96+ const instruction : UiInstruction = await getConvertToJitoSolInstruction ( {
10897 schema,
10998 form,
11099 connection,
111100 wallet,
112101 setFormErrors,
113- config,
114102 } )
115103
116104 if ( instruction . isValid ) {
@@ -134,7 +122,7 @@ const ConvertToStSol = () => {
134122 const proposalAddress = await handleCreateProposal ( {
135123 title : form . title ? form . title : getProposalText ( form . amount ) ,
136124 description : form . description ? form . description : '' ,
137- governance : currentAccount ! . governance ! ,
125+ governance : currentAccount ? .governance ,
138126 instructionsData : [ instructionData ] ,
139127 voteByCouncil,
140128 isDraft : false ,
@@ -158,25 +146,15 @@ const ConvertToStSol = () => {
158146 // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree
159147 } , [ currentAccount , form . destinationAccount ] )
160148
161- useEffect ( ( ) => {
162- const stSolMint =
163- connection . cluster === 'devnet' ? STSOL_MINT_DEVNET : STSOL_MINT
164- const stSolAccounts = governedTokenAccounts . filter ( ( acc ) => {
165- return acc . extensions . mint ?. publicKey . toString ( ) === stSolMint
166- } )
167- setStSolTokenAccounts ( stSolAccounts )
168- // eslint-disable-next-line react-hooks/exhaustive-deps -- TODO please fix, it can cause difficult bugs. You might wanna check out https://bobbyhadz.com/blog/react-hooks-exhaustive-deps for info. -@asktree
169- } , [ connection . cluster ] )
170-
171149 return (
172150 < >
173- < h3 className = "mb-4 flex items-center" > Convert SOL to stSOL </ h3 >
174- < AccountLabel / >
151+ < h3 className = "mb-4 flex items-center" > Convert SOL to JitoSOL </ h3 >
152+ < AccountLabel > </ AccountLabel >
175153 < div className = "space-y-4 w-full pb-4" >
176- { stSolTokenAccounts . length > 0 && (
154+ { jitoSolTokenAccounts . length > 0 && (
177155 < GovernedAccountSelect
178- label = "stSOL Treasury account"
179- governedAccounts = { stSolTokenAccounts as AssetAccount [ ] }
156+ label = "JitoSOL Treasury account"
157+ governedAccounts = { jitoSolTokenAccounts as AssetAccount [ ] }
180158 shouldBeGoverned = { false }
181159 governance = { currentAccount ?. governance }
182160 value = { form . destinationAccount }
@@ -261,7 +239,7 @@ const ConvertToStSol = () => {
261239 propertyName : 'description' ,
262240 } )
263241 }
264- / >
242+ > </ Textarea >
265243 { shouldShowVoteByCouncilToggle && (
266244 < VoteBySwitch
267245 checked = { voteByCouncil }
@@ -289,4 +267,4 @@ const ConvertToStSol = () => {
289267 )
290268}
291269
292- export default ConvertToStSol
270+ export default ConvertToJitoSol
0 commit comments