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 d9e80a2 commit 83139d5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ beforeAll(async () => {
shellMatchers()
})

describe('Withdraw stake account using CLI', () => {
// Withdraw stake account SDK call is not implemented
describe.skip('Withdraw stake account using CLI', () => {
it('withdraw stake account', async () => {
// Fill SOLs to authority key that's used by Marinade as fee payer
await transfer({ to: STAKE_ACCOUNT_TO_WITHDRAW_AUTHORITY.publicKey })
Expand Down
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 83139d5

Please sign in to comment.