-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I fixed my own dumbass issue sending 1.5sols to fanout instead hodlin… #24
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod init_for_mint; | ||
pub mod init_parent; | ||
pub mod transfer_to_hodling; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::error::{OrArithError}; | ||
use crate::state::{Fanout}; | ||
use anchor_lang::prelude::*; | ||
|
||
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] | ||
pub struct TransferToArgs { | ||
pub bump_seed: u8, | ||
pub native_account_bump_seed: u8, | ||
} | ||
|
||
#[derive(Accounts)] | ||
#[instruction(args: TransferToArgs)] | ||
pub struct TransferToHodling<'info> { | ||
#[account( | ||
mut, | ||
seeds = [b"fanout-config", fanout.name.as_bytes()], | ||
bump = fanout.bump_seed, | ||
)] | ||
pub fanout: Box<Account<'info, Fanout>>, | ||
#[account(mut)] | ||
/// CHECK: Could be native or Token Account | ||
pub holding_account: UncheckedAccount<'info>, | ||
pub system_program: Program<'info, System>, | ||
pub rent: Sysvar<'info, Rent>, | ||
} | ||
pub fn transfer_to_hodling( | ||
ctx: Context<TransferToHodling>, | ||
_args: TransferToArgs | ||
) -> Result<()> { | ||
let fanout = &mut ctx.accounts.fanout.to_account_info(); | ||
let hodling = ctx.accounts.holding_account.to_account_info(); | ||
let snapshot: u64 = fanout.lamports(); | ||
|
||
**fanout.lamports.borrow_mut() = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to drop the fanout to below rent-exempt minimum? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. afaik from my previous work with candy machine refunds it will empty the thing and solana conveniently kicks it out (can't afford rent). It's ? a weird process? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh - good point - we don't want to destroy the fanout in this particular case. There's a function somewhere for RENT_EXEMPT_MINIMUM or w/e? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this example gets rent minimum and removes any extra lamports above that |
||
|
||
**hodling.lamports.borrow_mut() = hodling | ||
.lamports() | ||
.checked_add(snapshot) | ||
.or_arith_error()?; | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strongly dislike this name for a instruction in publicly available smart contract 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gm haha :) my PRs are always suggestions, some are lulzy && for the culture - this trend continues :) in a newer one I've used 'inverse_bruh' as a variable, much to @ChewingGlass dismay - and in one a long time ago @austbot had to rewrite most of my output to the CLI in favor of 'consider supporting free & open source developers'
I trust the maintainers to make calls about what's culture and what's better without the lulz