diff --git a/Cargo.lock b/Cargo.lock index 778311c..5c5254a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -900,7 +900,7 @@ dependencies = [ [[package]] name = "nft-proxy" -version = "0.0.2" +version = "0.0.3" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/programs/nft_proxy/Cargo.toml b/programs/nft_proxy/Cargo.toml index c9699c1..0f6552a 100644 --- a/programs/nft_proxy/Cargo.toml +++ b/programs/nft_proxy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nft-proxy" -version = "0.0.2" +version = "0.0.3" description = "Created with Anchor" edition = "2021" diff --git a/programs/nft_proxy/src/instructions/unassign_proxy_v0.rs b/programs/nft_proxy/src/instructions/unassign_proxy_v0.rs index b8ba38e..62765b2 100644 --- a/programs/nft_proxy/src/instructions/unassign_proxy_v0.rs +++ b/programs/nft_proxy/src/instructions/unassign_proxy_v0.rs @@ -65,5 +65,12 @@ pub struct UnassignProxyV0<'info> { pub fn handler(ctx: Context) -> Result<()> { ctx.accounts.prev_proxy_assignment.next_voter = Pubkey::default(); + if ctx.accounts.prev_proxy_assignment.index == 0 { + ctx + .accounts + .prev_proxy_assignment + .close(ctx.accounts.rent_refund.to_account_info())?; + } + Ok(()) } diff --git a/tests/nft-voter.ts b/tests/nft-voter.ts index 327f9f9..81a0411 100644 --- a/tests/nft-voter.ts +++ b/tests/nft-voter.ts @@ -331,10 +331,8 @@ describe("nft-voter", () => { .rpc({ skipPreflight: true }); expect( - ( - await proxyProgram.account.proxyAssignmentV0.fetch(myProxy) - ).nextVoter.toBase58() - ).to.eq(PublicKey.default.toBase58()); + await proxyProgram.account.proxyAssignmentV0.fetchNullable(myProxy) + ).to.be.null; expect( await proxyProgram.account.proxyAssignmentV0.fetchNullable( toUnassignProxy