From 12a8f8eca712dac67666fefbe29f13be20e44b33 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Thu, 9 Mar 2023 15:26:34 +0000 Subject: [PATCH 1/2] fixed nft campaign claiming error --- pallets/reward/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/reward/src/lib.rs b/pallets/reward/src/lib.rs index 9ab92c8fd..0061664cb 100644 --- a/pallets/reward/src/lib.rs +++ b/pallets/reward/src/lib.rs @@ -619,7 +619,7 @@ pub mod pallet { pub fn claim_nft_reward_root( origin: OriginFor, id: CampaignId, - tokens: Vec<(ClassId, TokenId)>, + reward_tokens: Vec<(ClassId, TokenId)>, leaf_nodes: Vec, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -650,7 +650,7 @@ pub mod pallet { ensure!(!tokens.is_empty(), Error::::NoRewardFound); let mut new_claimed = claimed; - for token in tokens.clone() { + for token in reward_tokens.clone() { ensure!( reward.contains(&token) && !new_claimed.contains(&token), Error::::NoRewardFound @@ -663,7 +663,7 @@ pub mod pallet { campaign.claimed = RewardType::NftAssets(new_claimed); - Self::deposit_event(Event::::NftRewardClaimed(id, who, tokens)); + Self::deposit_event(Event::::NftRewardClaimed(id, who, reward_tokens)); Ok(()) } _ => Err(Error::::InvalidCampaignType.into()), From e314c1600bbb9c6e43e35abdd0f127e764a5c794 Mon Sep 17 00:00:00 2001 From: Aleksandar Brayanov Date: Thu, 9 Mar 2023 15:56:26 +0000 Subject: [PATCH 2/2] fixed build errors --- pallets/reward/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/reward/src/lib.rs b/pallets/reward/src/lib.rs index 0061664cb..6722a9350 100644 --- a/pallets/reward/src/lib.rs +++ b/pallets/reward/src/lib.rs @@ -614,7 +614,7 @@ pub mod pallet { /// - `leaf_nodes`: list of the merkle tree nodes required for merkle-proof calculation. /// /// Emits `RewardClaimed` if successful. - #[pallet::weight(T::WeightInfo::claim_nft_reward_root() * (1u64 + tokens.len() as u64))] + #[pallet::weight(T::WeightInfo::claim_nft_reward_root() * (1u64 + reward_tokens.len() as u64))] #[transactional] pub fn claim_nft_reward_root( origin: OriginFor, @@ -639,7 +639,7 @@ pub mod pallet { RewardType::NftAssets(reward) => match campaign.claimed.clone() { RewardType::NftAssets(claimed) => { let merkle_proof: Hash = - Self::calculate_nft_rewards_merkle_proof(&who, &tokens, &leaf_nodes)?; + Self::calculate_nft_rewards_merkle_proof(&who, &reward_tokens, &leaf_nodes)?; ensure!( Self::campaign_merkle_roots(id).contains(&merkle_proof),