Skip to content

Commit

Permalink
Bump hydra version (#1127)
Browse files Browse the repository at this point in the history
* Bump version

* Formatting
  • Loading branch information
febo authored Jun 26, 2023
1 parent 76e33af commit 1c0d8e0
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 81 deletions.
2 changes: 1 addition & 1 deletion hydra/program/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hydra/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mpl-hydra"
version = "0.3.0"
version = "0.4.1"
edition = "2021"
description = "Collective account pooling, fan out wallet, dao treasury, all of the things you need to FAN OUT"
authors = ["Metaplex Developers <[email protected]>"]
Expand Down
12 changes: 8 additions & 4 deletions hydra/program/src/processors/add_member/nft.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use super::arg::AddMemberArgs;

use crate::state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE};
use crate::utils::logic::calculation::*;
use crate::utils::validation::{assert_membership_model, assert_owned_by, assert_valid_metadata};
use crate::MembershipModel;
use crate::{
state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE},
utils::{
logic::calculation::*,
validation::{assert_membership_model, assert_owned_by, assert_valid_metadata},
},
MembershipModel,
};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token};

Expand Down
12 changes: 8 additions & 4 deletions hydra/program/src/processors/add_member/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use super::arg::AddMemberArgs;
use crate::state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE};
use crate::utils::logic::calculation::*;
use crate::utils::validation::{assert_membership_model, assert_owned_by, assert_owned_by_one};
use crate::MembershipModel;
use crate::{
state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE},
utils::{
logic::calculation::*,
validation::{assert_membership_model, assert_owned_by, assert_owned_by_one},
},
MembershipModel,
};
use anchor_lang::prelude::*;
use anchor_spl::token::Token;

Expand Down
6 changes: 4 additions & 2 deletions hydra/program/src/processors/distribute/wallet_member.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::MembershipModel;
use anchor_lang::prelude::*;

use crate::state::{Fanout, FanoutMembershipVoucher};
use crate::utils::validation::*;
use crate::{
state::{Fanout, FanoutMembershipVoucher},
utils::validation::*,
};

use crate::utils::logic::distribution::{distribute_mint, distribute_native};
use anchor_spl::token::{Mint, Token};
Expand Down
8 changes: 5 additions & 3 deletions hydra/program/src/processors/init/init_for_mint.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::error::HydraError;
use crate::state::{Fanout, FanoutMint};
use crate::utils::validation::assert_ata;
use crate::{
error::HydraError,
state::{Fanout, FanoutMint},
utils::validation::assert_ata,
};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, TokenAccount};

Expand Down
6 changes: 4 additions & 2 deletions hydra/program/src/processors/init/init_parent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::error::HydraError;
use crate::state::{Fanout, MembershipModel};
use crate::{
error::HydraError,
state::{Fanout, MembershipModel},
};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token};

Expand Down
24 changes: 9 additions & 15 deletions hydra/program/src/processors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ pub mod signing;
pub mod stake;
pub mod transfer_shares;

pub use self::add_member::arg::*;
pub use self::add_member::nft::*;
pub use self::add_member::wallet::*;
pub use self::distribute::nft_member::*;
pub use self::distribute::token_member::*;
pub use self::distribute::wallet_member::*;
pub use self::init::init_for_mint::*;
pub use self::init::init_parent::*;
pub use self::remove_member::process_remove_member::*;
pub use self::remove_member::process_remove_member::*;
pub use self::signing::sign_metadata::*;
pub use self::stake::set::*;
pub use self::stake::set_for::*;
pub use self::stake::unstake::*;
pub use self::transfer_shares::process_transfer_shares::*;
pub use self::{
add_member::{arg::*, nft::*, wallet::*},
distribute::{nft_member::*, token_member::*, wallet_member::*},
init::{init_for_mint::*, init_parent::*},
remove_member::process_remove_member::*,
signing::sign_metadata::*,
stake::{set::*, set_for::*, unstake::*},
transfer_shares::process_transfer_shares::*,
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::state::{Fanout, FanoutMembershipVoucher};
use crate::utils::logic::calculation::*;
use crate::utils::validation::assert_owned_by;
use crate::MembershipModel;
use crate::{
state::{Fanout, FanoutMembershipVoucher},
utils::{logic::calculation::*, validation::assert_owned_by},
MembershipModel,
};
use anchor_lang::prelude::*;

use crate::error::HydraError;
Expand Down
4 changes: 1 addition & 3 deletions hydra/program/src/processors/signing/sign_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::error::HydraError;
use crate::state::Fanout;
use crate::utils::validation::assert_owned_by;
use crate::{error::HydraError, state::Fanout, utils::validation::assert_owned_by};
use anchor_lang::prelude::*;

use spl_token::solana_program::program::invoke_signed;
Expand Down
9 changes: 5 additions & 4 deletions hydra/program/src/processors/stake/set.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::error::{HydraError, OrArithError};
use crate::state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE};
use crate::{
error::{HydraError, OrArithError},
state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE},
};

use crate::utils::validation::*;
use crate::MembershipModel;
use crate::{utils::validation::*, MembershipModel};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token, TokenAccount};
#[derive(Accounts)]
Expand Down
9 changes: 5 additions & 4 deletions hydra/program/src/processors/stake/set_for.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::error::{HydraError, OrArithError};
use crate::state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE};
use crate::{
error::{HydraError, OrArithError},
state::{Fanout, FanoutMembershipVoucher, FANOUT_MEMBERSHIP_VOUCHER_SIZE},
};

use crate::utils::validation::*;
use crate::MembershipModel;
use crate::{utils::validation::*, MembershipModel};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token, TokenAccount};
#[derive(Accounts)]
Expand Down
13 changes: 8 additions & 5 deletions hydra/program/src/processors/stake/unstake.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use crate::error::OrArithError;
use crate::state::{Fanout, FanoutMembershipVoucher};
use crate::{
error::OrArithError,
state::{Fanout, FanoutMembershipVoucher},
};

use crate::utils::validation::*;
use anchor_lang::prelude::*;
use anchor_lang::solana_program::sysvar;
use anchor_lang::solana_program::sysvar::instructions::get_instruction_relative;
use anchor_lang::{
prelude::*,
solana_program::{sysvar, sysvar::instructions::get_instruction_relative},
};
use anchor_spl::token::{Mint, Token, TokenAccount};

#[derive(Accounts)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::error::HydraError;
use crate::state::{Fanout, FanoutMembershipVoucher};
use crate::{
error::HydraError,
state::{Fanout, FanoutMembershipVoucher},
};

use crate::MembershipModel;
use anchor_lang::prelude::*;
Expand Down
6 changes: 4 additions & 2 deletions hydra/program/src/utils/logic/calculation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::error::{HydraError, OrArithError};
use crate::state::{Fanout, FanoutMembershipMintVoucher, FanoutMembershipVoucher, FanoutMint};
use crate::{
error::{HydraError, OrArithError},
state::{Fanout, FanoutMembershipMintVoucher, FanoutMembershipVoucher, FanoutMint},
};
use anchor_lang::prelude::*;

pub fn calculate_inflow_change(total_inflow: u64, last_inflow: u64) -> Result<u64> {
Expand Down
18 changes: 12 additions & 6 deletions hydra/program/src/utils/logic/distribution.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use crate::state::{Fanout, FanoutMembershipVoucher, FANOUT_ACCOUNT_SIZE, HOLDING_ACCOUNT_SIZE};
use crate::utils::logic::calculation::*;
use crate::utils::logic::transfer::{transfer_from_mint_holding, transfer_native};
use crate::utils::parse_fanout_mint;
use crate::utils::validation::*;
use crate::utils::*;
use crate::{
state::{Fanout, FanoutMembershipVoucher, FANOUT_ACCOUNT_SIZE, HOLDING_ACCOUNT_SIZE},
utils::{
logic::{
calculation::*,
transfer::{transfer_from_mint_holding, transfer_native},
},
parse_fanout_mint,
validation::*,
*,
},
};
use anchor_lang::prelude::*;
use anchor_spl::token::{Mint, Token};

Expand Down
3 changes: 1 addition & 2 deletions hydra/program/src/utils/logic/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::HydraError;
use crate::state::Fanout;
use crate::{error::HydraError, state::Fanout};
use anchor_lang::prelude::*;

pub fn transfer_from_mint_holding<'info>(
Expand Down
25 changes: 14 additions & 11 deletions hydra/program/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
pub mod logic;
pub mod validation;

use crate::error::HydraError;
use crate::state::{FanoutMembershipMintVoucher, FanoutMint, FANOUT_MINT_MEMBERSHIP_VOUCHER_SIZE};
use crate::utils::validation::{assert_derivation, assert_owned_by};
use anchor_lang::prelude::*;
use anchor_lang::solana_program::program::invoke_signed;
use anchor_lang::solana_program::system_instruction;
use crate::{
error::HydraError,
state::{FanoutMembershipMintVoucher, FanoutMint, FANOUT_MINT_MEMBERSHIP_VOUCHER_SIZE},
utils::validation::{assert_derivation, assert_owned_by},
};
use anchor_lang::{
prelude::*,
solana_program::{program::invoke_signed, system_instruction},
};
use anchor_spl::token::TokenAccount;
use std::convert::TryInto;

Expand Down Expand Up @@ -138,7 +141,7 @@ pub fn parse_mint_membership_voucher<'info>(
fanout_mint: *fanout_mint,
last_inflow: total_inflow,
bump_seed: mint_membership_voucher_bump,
stake_time: stake_time
stake_time,
}
} else {
let mut membership_data: &[u8] =
Expand All @@ -151,10 +154,10 @@ pub fn parse_mint_membership_voucher<'info>(
}
// If this account was staked before at a different time, clear it out.
if stake_time != membership.stake_time {
membership.last_inflow = total_inflow;
membership.stake_time = stake_time;
}
membership.last_inflow = total_inflow;
membership.stake_time = stake_time;
}

membership
})
}
14 changes: 8 additions & 6 deletions hydra/program/src/utils/validation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::error::HydraError;
use crate::state::{Fanout, MembershipModel};
use anchor_lang::prelude::*;
use anchor_lang::solana_program::instruction::Instruction;
use anchor_lang::solana_program::program_memory::sol_memcmp;
use anchor_lang::solana_program::pubkey::PUBKEY_BYTES;
use crate::{
error::HydraError,
state::{Fanout, MembershipModel},
};
use anchor_lang::{
prelude::*,
solana_program::{instruction::Instruction, program_memory::sol_memcmp, pubkey::PUBKEY_BYTES},
};
use anchor_spl::token::TokenAccount;
use mpl_token_metadata::state::{Metadata, TokenMetadataAccount};

Expand Down

0 comments on commit 1c0d8e0

Please sign in to comment.