Skip to content

Commit

Permalink
upgrade mango client (#41)
Browse files Browse the repository at this point in the history
* upgrade mango client

* yarn lock fix

* fix build
  • Loading branch information
abrzezinski94 authored Nov 25, 2024
1 parent 06d4208 commit e655a76
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 506 deletions.
32 changes: 18 additions & 14 deletions actions/createProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { deduplicateObjsFilter } from '@utils/instructionTools'
import { NftVoterClient } from '@utils/uiTypes/NftVoterClient'
import { fetchProgramVersion } from '@hooks/queries/useProgramVersionQuery'
import { chargeFee, PROPOSAL_FEE } from './createChargeFee'
import { bs58 } from '@coral-xyz/anchor/dist/cjs/utils/bytes'

export interface InstructionDataWithHoldUpTime {
data: InstructionData | null
Expand Down Expand Up @@ -108,12 +107,15 @@ export const createProposal = async (

const proposalSeed = Keypair.generate().publicKey

const [proposalKey] = PublicKey.findProgramAddressSync([
Buffer.from('governance'),
governance.toBytes(),
governingTokenMint.toBytes(),
proposalSeed.toBytes()
], realm.owner)
const [proposalKey] = PublicKey.findProgramAddressSync(
[
Buffer.from('governance'),
governance.toBytes(),
governingTokenMint.toBytes(),
proposalSeed.toBytes(),
],
realm.owner
)

//will run only if plugin is connected with realm
const plugin = await client?.withUpdateVoterWeightRecord(
Expand All @@ -123,13 +125,15 @@ export const createProposal = async (
governance
)

if (instructions.length && client?.voterWeightPluginDetails.plugins?.voterWeight[0].name === "bonk") {
instructions[0].data =
Buffer.concat([
instructions[0].data.slice(0,9),
governance.toBuffer(),
instructions[0].data.slice(41)
])
if (
instructions.length &&
client?.voterWeightPluginDetails.plugins?.voterWeight[0].name === 'bonk'
) {
instructions[0].data = Buffer.concat([
instructions[0].data.slice(0, 9),
governance.toBuffer(),
instructions[0].data.slice(41),
])

instructions[0].keys[5].pubkey = governance
instructions[0].keys[6].pubkey = proposalKey
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@blockworks-foundation/mango-mints-redemption": "0.0.11",
"@blockworks-foundation/mango-v4": "0.33.5",
"@blockworks-foundation/mango-v4": "0.33.7",
"@blockworks-foundation/mango-v4-settings": "0.14.24",
"@blockworks-foundation/mangolana": "0.0.18",
"@bonfida/spl-name-service": "0.1.47",
Expand Down Expand Up @@ -96,7 +96,7 @@
"@solana/spl-governance": "0.3.28",
"@solana/spl-stake-pool": "1.1.5",
"@solana/spl-token": "0.1.8",
"@solana/spl-token-new": "npm:@solana/[email protected].8",
"@solana/spl-token-new": "npm:@solana/[email protected].9",
"@solana/wallet-adapter-backpack": "0.1.13",
"@solana/wallet-adapter-base": "0.9.22",
"@solana/wallet-adapter-exodus": "0.1.17",
Expand Down
Loading

0 comments on commit e655a76

Please sign in to comment.