From a9642077122a07e7234cd68883e17d040b2b6317 Mon Sep 17 00:00:00 2001 From: jpe7s Date: Sun, 18 Aug 2024 12:25:08 -0500 Subject: [PATCH] sync solana programs changes. --- .../glam/GlamProgramAccountClient.java | 9 ------- .../glam/GlamProgramAccountClientImpl.java | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClient.java b/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClient.java index 61a3b99..1dd6726 100644 --- a/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClient.java +++ b/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClient.java @@ -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; @@ -67,12 +66,4 @@ static Map filterFundAccounts(final List stakeAccounts); - - Instruction withdrawFromStakeAccounts(final Collection stakeAccounts); - - Instruction deactivateStakeAccount(final PublicKey stakeAccount); - - Instruction withdrawFromStakeAccount(final PublicKey stakeAccount); } diff --git a/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClientImpl.java b/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClientImpl.java index a4d90fc..0349492 100644 --- a/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClientImpl.java +++ b/programs/src/main/java/software/sava/anchor/programs/glam/GlamProgramAccountClientImpl.java @@ -469,16 +469,23 @@ private Instruction deactivateStakeAccounts() { } @Override - public Instruction deactivateStakeAccounts(final Collection 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 deactivateStakeAccountInfos(final Collection> 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 deactivateStakeAccounts(final Collection 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(), @@ -491,13 +498,14 @@ private Instruction withdrawFromStakeAccounts() { } @Override - public Instruction withdrawFromStakeAccounts(final Collection stakeAccounts) { - return withdrawFromStakeAccounts().extraAccounts(stakeAccounts, AccountMeta.CREATE_WRITE); + public Instruction closeStakeAccount(final AccountInfo 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 closeStakeAccounts(final Collection> stakeAccounts) { + final var extraAccounts = stakeAccounts.stream().map(AccountInfo::pubKey).toList(); + return List.of(closeStakeAccounts().extraAccounts(extraAccounts, AccountMeta.CREATE_WRITE)); } @Override