From fe7d6c08744d545289d2ee603ce7bea53fc9df95 Mon Sep 17 00:00:00 2001 From: Ondra Chaloupka Date: Tue, 14 Nov 2023 13:53:29 +0100 Subject: [PATCH] [CLI] disable withdraw stake account command as SDK 5.0.6 does not implement it --- .../commands/manage/withdrawStakeAccount.ts | 69 +++++++++++-------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/packages/marinade-ts-cli/src/commands/manage/withdrawStakeAccount.ts b/packages/marinade-ts-cli/src/commands/manage/withdrawStakeAccount.ts index cd58d25..724983d 100644 --- a/packages/marinade-ts-cli/src/commands/manage/withdrawStakeAccount.ts +++ b/packages/marinade-ts-cli/src/commands/manage/withdrawStakeAccount.ts @@ -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) { @@ -39,9 +37,10 @@ export async function withdrawStakeAccount({ amountMsol: number stakeAccount: PublicKey }): Promise { - 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, @@ -49,32 +48,42 @@ export async function withdrawStakeAccount({ 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() + // ) }