From 3d21e9af3b7d12395b1405b09e0d963f19939a18 Mon Sep 17 00:00:00 2001 From: librelois <c@elo.tf> Date: Fri, 15 Jul 2022 14:18:58 +0200 Subject: [PATCH] fix(account): bug #85 When a self-sufficient accounts receive money for the first time, that should trigger the random id assignment --- pallets/duniter-account/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 0615fbd99..17d890eaf 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -284,13 +284,11 @@ where let result = f(&mut some_data)?; let is_providing = some_data.is_some(); if !was_providing && is_providing { - if !frame_system::Pallet::<T>::account_exists(account_id) { - // If the account does not exist, we should program its creation - PendingNewAccounts::<T>::insert(account_id, ()); - } else { - // If the account already exists, we should register increment providers directly + if frame_system::Pallet::<T>::account_exists(account_id) { + // If the account is self-sufficient, we should increment providers directly frame_system::Pallet::<T>::inc_providers(account_id); } + PendingNewAccounts::<T>::insert(account_id, ()); } else if was_providing && !is_providing { match frame_system::Pallet::<T>::dec_providers(account_id)? { frame_system::DecRefStatus::Reaped => return Ok(result), -- GitLab