Skip to content

Commit

Permalink
sync solana programs changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpe7s committed Aug 18, 2024
1 parent dc55157 commit a964207
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import software.sava.rpc.json.http.response.AccountInfo;
import software.sava.solana.programs.clients.NativeProgramAccountClient;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -67,12 +66,4 @@ static Map<PublicKey, FundAccount> filterFundAccounts(final List<AccountInfo<Fun
Instruction initializeAndDelegateStake(final FundPDA stakeAccountPDA,
final PublicKey validatorVoteAccount,
final long lamports);

Instruction deactivateStakeAccounts(final Collection<PublicKey> stakeAccounts);

Instruction withdrawFromStakeAccounts(final Collection<PublicKey> stakeAccounts);

Instruction deactivateStakeAccount(final PublicKey stakeAccount);

Instruction withdrawFromStakeAccount(final PublicKey stakeAccount);
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,23 @@ private Instruction deactivateStakeAccounts() {
}

@Override
public Instruction deactivateStakeAccounts(final Collection<PublicKey> stakeAccounts) {
return deactivateStakeAccounts().extraAccounts(stakeAccounts, AccountMeta.CREATE_WRITE);
public Instruction deactivateStakeAccount(final StakeAccount stakeAccount) {
return deactivateStakeAccounts().extraAccount(stakeAccount.address(), AccountMeta.CREATE_WRITE);
}

@Override
public Instruction deactivateStakeAccount(final PublicKey stakeAccount) {
return deactivateStakeAccounts().extraAccount(stakeAccount, AccountMeta.CREATE_WRITE);
public List<Instruction> deactivateStakeAccountInfos(final Collection<AccountInfo<StakeAccount>> stakeAccounts) {
final var extraAccounts = stakeAccounts.stream().map(AccountInfo::pubKey).toList();
return List.of(deactivateStakeAccounts().extraAccounts(extraAccounts, AccountMeta.CREATE_WRITE));
}

private Instruction withdrawFromStakeAccounts() {
@Override
public List<Instruction> deactivateStakeAccounts(final Collection<StakeAccount> stakeAccounts) {
final var extraAccounts = stakeAccounts.stream().map(StakeAccount::address).toList();
return List.of(deactivateStakeAccounts().extraAccounts(extraAccounts, AccountMeta.CREATE_WRITE));
}

private Instruction closeStakeAccounts() {
return GlamProgram.withdrawFromStakeAccounts(
invokedProgram,
manager.publicKey(),
Expand All @@ -491,13 +498,14 @@ private Instruction withdrawFromStakeAccounts() {
}

@Override
public Instruction withdrawFromStakeAccounts(final Collection<PublicKey> stakeAccounts) {
return withdrawFromStakeAccounts().extraAccounts(stakeAccounts, AccountMeta.CREATE_WRITE);
public Instruction closeStakeAccount(final AccountInfo<StakeAccount> stakeAccountInfo) {
return closeStakeAccounts().extraAccount(stakeAccountInfo.pubKey(), AccountMeta.CREATE_WRITE);
}

@Override
public Instruction withdrawFromStakeAccount(final PublicKey stakeAccount) {
return withdrawFromStakeAccounts().extraAccount(stakeAccount, AccountMeta.CREATE_WRITE);
public List<Instruction> closeStakeAccounts(final Collection<AccountInfo<StakeAccount>> stakeAccounts) {
final var extraAccounts = stakeAccounts.stream().map(AccountInfo::pubKey).toList();
return List.of(closeStakeAccounts().extraAccounts(extraAccounts, AccountMeta.CREATE_WRITE));
}

@Override
Expand Down

0 comments on commit a964207

Please sign in to comment.