From e5663b05b5179034659a32467b25cc1fb4c5fe6d Mon Sep 17 00:00:00 2001 From: febo Date: Mon, 26 Jun 2023 22:50:35 +0100 Subject: [PATCH 1/2] Bump version --- hydra/program/Cargo.lock | 2 +- hydra/program/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hydra/program/Cargo.lock b/hydra/program/Cargo.lock index 6586646956..d5bc8c2362 100644 --- a/hydra/program/Cargo.lock +++ b/hydra/program/Cargo.lock @@ -1017,7 +1017,7 @@ dependencies = [ [[package]] name = "mpl-hydra" -version = "0.3.0" +version = "0.4.1" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/hydra/program/Cargo.toml b/hydra/program/Cargo.toml index d76fd0ec5b..9aa5ea6f67 100644 --- a/hydra/program/Cargo.toml +++ b/hydra/program/Cargo.toml @@ -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 "] From 07c3a178d15a66966c805ccd4ad1386d4f3863ce Mon Sep 17 00:00:00 2001 From: febo Date: Mon, 26 Jun 2023 22:55:23 +0100 Subject: [PATCH 2/2] Formatting --- .../program/src/processors/add_member/nft.rs | 12 ++++++--- .../src/processors/add_member/wallet.rs | 12 ++++++--- .../processors/distribute/wallet_member.rs | 6 +++-- .../src/processors/init/init_for_mint.rs | 8 +++--- .../src/processors/init/init_parent.rs | 6 +++-- hydra/program/src/processors/mod.rs | 24 +++++++----------- .../remove_member/process_remove_member.rs | 9 ++++--- .../src/processors/signing/sign_metadata.rs | 4 +-- hydra/program/src/processors/stake/set.rs | 9 ++++--- hydra/program/src/processors/stake/set_for.rs | 9 ++++--- hydra/program/src/processors/stake/unstake.rs | 13 ++++++---- .../process_transfer_shares.rs | 6 +++-- hydra/program/src/utils/logic/calculation.rs | 6 +++-- hydra/program/src/utils/logic/distribution.rs | 18 ++++++++----- hydra/program/src/utils/logic/transfer.rs | 3 +-- hydra/program/src/utils/mod.rs | 25 +++++++++++-------- hydra/program/src/utils/validation/mod.rs | 14 ++++++----- 17 files changed, 105 insertions(+), 79 deletions(-) diff --git a/hydra/program/src/processors/add_member/nft.rs b/hydra/program/src/processors/add_member/nft.rs index 22af8c0b24..b945601e28 100644 --- a/hydra/program/src/processors/add_member/nft.rs +++ b/hydra/program/src/processors/add_member/nft.rs @@ -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}; diff --git a/hydra/program/src/processors/add_member/wallet.rs b/hydra/program/src/processors/add_member/wallet.rs index acfd3f9181..9ef3a45f00 100644 --- a/hydra/program/src/processors/add_member/wallet.rs +++ b/hydra/program/src/processors/add_member/wallet.rs @@ -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; diff --git a/hydra/program/src/processors/distribute/wallet_member.rs b/hydra/program/src/processors/distribute/wallet_member.rs index 5e522607eb..8f7626b079 100644 --- a/hydra/program/src/processors/distribute/wallet_member.rs +++ b/hydra/program/src/processors/distribute/wallet_member.rs @@ -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}; diff --git a/hydra/program/src/processors/init/init_for_mint.rs b/hydra/program/src/processors/init/init_for_mint.rs index efc42da7e5..f043da182e 100644 --- a/hydra/program/src/processors/init/init_for_mint.rs +++ b/hydra/program/src/processors/init/init_for_mint.rs @@ -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}; diff --git a/hydra/program/src/processors/init/init_parent.rs b/hydra/program/src/processors/init/init_parent.rs index 062b944d82..0d5549286f 100644 --- a/hydra/program/src/processors/init/init_parent.rs +++ b/hydra/program/src/processors/init/init_parent.rs @@ -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}; diff --git a/hydra/program/src/processors/mod.rs b/hydra/program/src/processors/mod.rs index e6f9edfa3d..534ac5f1a2 100644 --- a/hydra/program/src/processors/mod.rs +++ b/hydra/program/src/processors/mod.rs @@ -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::*, +}; diff --git a/hydra/program/src/processors/remove_member/process_remove_member.rs b/hydra/program/src/processors/remove_member/process_remove_member.rs index 2fead0f856..3751ecf746 100644 --- a/hydra/program/src/processors/remove_member/process_remove_member.rs +++ b/hydra/program/src/processors/remove_member/process_remove_member.rs @@ -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; diff --git a/hydra/program/src/processors/signing/sign_metadata.rs b/hydra/program/src/processors/signing/sign_metadata.rs index 310049c6a4..ceea8d713a 100644 --- a/hydra/program/src/processors/signing/sign_metadata.rs +++ b/hydra/program/src/processors/signing/sign_metadata.rs @@ -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; diff --git a/hydra/program/src/processors/stake/set.rs b/hydra/program/src/processors/stake/set.rs index e79fb0812e..4664b73b86 100644 --- a/hydra/program/src/processors/stake/set.rs +++ b/hydra/program/src/processors/stake/set.rs @@ -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)] diff --git a/hydra/program/src/processors/stake/set_for.rs b/hydra/program/src/processors/stake/set_for.rs index e72a96ce34..6030855bd4 100644 --- a/hydra/program/src/processors/stake/set_for.rs +++ b/hydra/program/src/processors/stake/set_for.rs @@ -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)] diff --git a/hydra/program/src/processors/stake/unstake.rs b/hydra/program/src/processors/stake/unstake.rs index 43b1f0530f..1dfdbebb78 100644 --- a/hydra/program/src/processors/stake/unstake.rs +++ b/hydra/program/src/processors/stake/unstake.rs @@ -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)] diff --git a/hydra/program/src/processors/transfer_shares/process_transfer_shares.rs b/hydra/program/src/processors/transfer_shares/process_transfer_shares.rs index 74d764742d..7028cfd67a 100644 --- a/hydra/program/src/processors/transfer_shares/process_transfer_shares.rs +++ b/hydra/program/src/processors/transfer_shares/process_transfer_shares.rs @@ -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::*; diff --git a/hydra/program/src/utils/logic/calculation.rs b/hydra/program/src/utils/logic/calculation.rs index bcd8aaaac2..a7c45e7f73 100644 --- a/hydra/program/src/utils/logic/calculation.rs +++ b/hydra/program/src/utils/logic/calculation.rs @@ -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 { diff --git a/hydra/program/src/utils/logic/distribution.rs b/hydra/program/src/utils/logic/distribution.rs index b8cb6aa95d..a72bcbb19b 100644 --- a/hydra/program/src/utils/logic/distribution.rs +++ b/hydra/program/src/utils/logic/distribution.rs @@ -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}; diff --git a/hydra/program/src/utils/logic/transfer.rs b/hydra/program/src/utils/logic/transfer.rs index a873b42458..f51d846fd2 100644 --- a/hydra/program/src/utils/logic/transfer.rs +++ b/hydra/program/src/utils/logic/transfer.rs @@ -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>( diff --git a/hydra/program/src/utils/mod.rs b/hydra/program/src/utils/mod.rs index 38a490ae80..8b615c1a65 100644 --- a/hydra/program/src/utils/mod.rs +++ b/hydra/program/src/utils/mod.rs @@ -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; @@ -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] = @@ -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 }) } diff --git a/hydra/program/src/utils/validation/mod.rs b/hydra/program/src/utils/validation/mod.rs index d41d72de55..67c005c412 100644 --- a/hydra/program/src/utils/validation/mod.rs +++ b/hydra/program/src/utils/validation/mod.rs @@ -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};