Skip to content

Commit

Permalink
[CLI] disable withdraw stake account command as SDK 5.0.6 does not im…
Browse files Browse the repository at this point in the history
…plement it
  • Loading branch information
ochaloup committed Nov 14, 2023
1 parent eb4d8b4 commit fe7d6c0
Showing 1 changed file with 39 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Marinade, MarinadeConfig } from '@marinade.finance/marinade-ts-sdk'
import { Command } from 'commander'
import { parsePubkey } from '@marinade.finance/cli-common'
import { PublicKey } from '@solana/web3.js'
import { executeTx } from '@marinade.finance/web3js-common'
import { getMarinadeCliContext } from '../../context'

export function installWithdrawStakeAccount(program: Command) {
Expand Down Expand Up @@ -39,42 +37,53 @@ export async function withdrawStakeAccount({
amountMsol: number
stakeAccount: PublicKey
}): Promise<void> {
const { connection, wallet, logger, simulate, printOnly } =
getMarinadeCliContext()
// const { connection, wallet, logger, simulate, printOnly } =
// getMarinadeCliContext()

const { wallet, logger } = getMarinadeCliContext()
logger.info(
'Withdrawing %d MSOLs from stake account: %s with wallet key %s',
amountMsol,
stakeAccount.toBase58(),
wallet.publicKey.toBase58()
)

const marinadeConfig = new MarinadeConfig({
connection: connection,
publicKey: wallet.publicKey,
})
const marinade = new Marinade(marinadeConfig)
logger.debug(
'A workaround could be (not sure if working in future) ' +
'to use version 5.0.6-beta of @marinade.finance/marinade-ts-sdk'
)
logger.debug(
'The SDK call was removed as it was decided not to be part of SDK' +
'and to be used only within contract interaction'
)
throw new Error('Not implemented in marinade-ts-sdk')

const {
transaction,
splitStakeAccountKeypair,
associatedMSolTokenAccountAddress,
} = await marinade.withdrawStakeAccount(amountMsol, stakeAccount)
// const marinadeConfig = new MarinadeConfig({
// connection: connection,
// publicKey: wallet.publicKey,
// })
// const marinade = new Marinade(marinadeConfig)

await executeTx({
connection,
errMessage: `Failed to withdraw stake account ${stakeAccount.toBase58()}`,
signers: [wallet, splitStakeAccountKeypair],
transaction,
logger,
simulate,
printOnly,
})
logger.info(
'Successfully withdrawn %d MSOLs from stake account %s. The MSOLs converted from MSOL ATA %s to SOL into wallet key account %s',
amountMsol,
stakeAccount.toBase58(),
associatedMSolTokenAccountAddress.toBase58(),
wallet.publicKey.toBase58()
)
// const {
// transaction,
// splitStakeAccountKeypair,
// associatedMSolTokenAccountAddress,
// } = await marinade.withdrawStakeAccount(amountMsol, stakeAccount)

// await executeTx({
// connection,
// errMessage: `Failed to withdraw stake account ${stakeAccount.toBase58()}`,
// signers: [wallet, splitStakeAccountKeypair],
// transaction,
// logger,
// simulate,
// printOnly,
// })
// logger.info(
// 'Successfully withdrawn %d MSOLs from stake account %s. The MSOLs converted from MSOL ATA %s to SOL into wallet key account %s',
// amountMsol,
// stakeAccount.toBase58(),
// associatedMSolTokenAccountAddress.toBase58(),
// wallet.publicKey.toBase58()
// )
}

0 comments on commit fe7d6c0

Please sign in to comment.