Skip to content

Commit

Permalink
add stake account decode and proposed by filed to proposal title (#2334)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrzezinski94 authored May 28, 2024
1 parent c13ab30 commit a215210
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 1,118 deletions.
2 changes: 0 additions & 2 deletions Strategies/protocols/foresight/tools.ts

This file was deleted.

239 changes: 0 additions & 239 deletions components/instructions/programs/foresight.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions components/instructions/programs/names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PublicKey } from '@solana/web3.js'
import { consts as foresightConsts } from '@foresight-tmp/foresight-sdk/'
import {
LIDO_PROGRAM_ID,
LIDO_PROGRAM_ID_DEVNET,
Expand Down Expand Up @@ -63,7 +62,6 @@ const PROGRAM_NAMES = {
'Raydium Voter Stake Registry Program',
VoteMBhDCqGLRgYpp9o7DGyq81KNmwjXQRAHStjtJsS:
'Marinade Voter Stake Registry Program',
[foresightConsts.PROGRAM_ID]: 'Foresight Dex',
[NAME_PROGRAM_ID.toBase58()]: 'Solana Name Service Program',
AwyKDr1Z5BfdvK3jX1UWopyjsJSV5cq4cuJpoYLofyEn: 'Validator Dao',
Stake11111111111111111111111111111111111111: 'Stake Program',
Expand Down
43 changes: 43 additions & 0 deletions components/instructions/programs/stake.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Connection, LAMPORTS_PER_SOL } from '@solana/web3.js'
import { AccountMetaData } from '@solana/spl-governance'
import * as BufferLayout from '@solana/buffer-layout'
import dayjs from 'dayjs'

export const STAKE_INSTRUCTIONS = {
Stake11111111111111111111111111111111111111: {
Expand Down Expand Up @@ -60,5 +61,47 @@ export const STAKE_INSTRUCTIONS = {
return <></>
},
},
6: {
name: 'Stake Program - Unlock',
accounts: [{ name: 'Stake Account' }, { name: 'Vote Account' }],
getDataUI: async (
_connection: Connection,
_data: Uint8Array,
_accounts: AccountMetaData[]
) => {
const layout = BufferLayout.struct<any['Unlock']>([
BufferLayout.u32('instruction'),
BufferLayout.u8('hasUnixTimestamp'),
BufferLayout.ns64('unixTimestamp'),
BufferLayout.u8('hasEpoch'),
//add epoch field if needed
BufferLayout.u8('hasCustodian'),
//add custodian field if needed
])
const data = layout.decode(Buffer.from(_data))
const accData = await _connection.getParsedAccountInfo(
_accounts[0].pubkey
)
const stakeMeta = accData.value?.data['parsed'].info.meta
return (
<>
<div className="mb-3">
<div>Staker: {stakeMeta.authorized.staker}</div>
<div>Withdraw authority: {stakeMeta.authorized.staker}</div>
<div>Lockup authority: {stakeMeta.lockup.custodian}</div>
</div>
<div>
Unlock date:{' '}
{dayjs.unix(data.unixTimestamp).format('DD-MM-YYYY HH:mm')}
</div>
{(data.hasEpoch !== 0 || data.hasCustodian !== 0) && (
<div className="text-red mt-3">
Warning! detected epoch or custodian change
</div>
)}
</>
)
},
},
},
}
5 changes: 0 additions & 5 deletions components/instructions/tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import { VOTE_STAKE_REGISTRY_INSTRUCTIONS } from './programs/voteStakeRegistry'
import { MARINADE_INSTRUCTIONS } from './programs/marinade'
import { SOLEND_PROGRAM_INSTRUCTIONS } from './programs/solend'
import { ATA_PROGRAM_INSTRUCTIONS } from './programs/associatedTokenAccount'
import { governance as foresightGov } from '@foresight-tmp/foresight-sdk'
import { ConnectionContext } from '@utils/connection'
import { NFT_VOTER_INSTRUCTIONS } from './programs/nftVotingClient'
import { FORESIGHT_INSTRUCTIONS } from './programs/foresight'
import { LIDO_INSTRUCTIONS } from './programs/lido'
import { NAME_SERVICE_INSTRUCTIONS } from './programs/nameService'
import { TOKEN_AUCTION_INSTRUCTIONS } from './programs/tokenAuction'
Expand Down Expand Up @@ -107,8 +105,6 @@ export const ACCOUNT_NAMES = {
MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac: 'MNGO Token Mint',
H7uqouPsJkeEiLpCEoC1qYVVquDrZan6ZfdPK2gS44zm: 'FORE Devnet Token Mint',
'4ahVJVavHM8DZCtjX6YuKSTFx6KJwRPmVCJtjdQYdUU7': 'FORE Mainnet Token Mint',
[foresightGov.DEVNET_TREASURY.toBase58()]: 'Foresight Devnet Governance',
[foresightGov.MAINNET_TREASURY.toBase58()]: 'Foresight Mainnet Governance',
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: 'USDC Token Mint',

MyHd6a7HWKTMeJMHBkrbMq4hZwZxwn9x7dxXcopQ4Wd: 'OMH Token',
Expand Down Expand Up @@ -488,7 +484,6 @@ export const INSTRUCTION_DESCRIPTORS = {
...LIDO_INSTRUCTIONS,
...SWITCHBOARD_INSTRUCTIONS,
...SOLEND_PROGRAM_INSTRUCTIONS,
...FORESIGHT_INSTRUCTIONS,
...ATA_PROGRAM_INSTRUCTIONS,
...SYSTEM_INSTRUCTIONS,
...VOTE_STAKE_REGISTRY_INSTRUCTIONS,
Expand Down
Loading

0 comments on commit a215210

Please sign in to comment.