Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update purchase.rs
  • Loading branch information
shawntabrizi committed Apr 29, 2022
commit c575fda210818c06909715976a811f4d8594e3b4
44 changes: 24 additions & 20 deletions runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A [new] account was created.
AccountCreated(T::AccountId),
/// Someone's account validity was updated. [who, validity]
ValidityUpdated(T::AccountId, AccountValidity),
/// Someone's purchase balance was updated. [who, free, locked]
BalanceUpdated(T::AccountId, BalanceOf<T>, BalanceOf<T>),
/// A payout was made to a purchaser. [who, free, locked]
PaymentComplete(T::AccountId, BalanceOf<T>, BalanceOf<T>),
/// A new payment account was set. [who]
PaymentAccountSet(T::AccountId),
AccountCreated { who: T::AccountId },
/// Someone's account validity was updated.
ValidityUpdated { who: T::AccountId, validity: AccountValidity },
/// Someone's purchase balance was updated.
BalanceUpdated { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A payout was made to a purchaser.
PaymentComplete { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A new payment account was set.
PaymentAccountSet { who: T::AccountId },
/// A new statement was set.
StatementUpdated,
/// A new statement was set. `[block_number]`
UnlockBlockUpdated(T::BlockNumber),
UnlockBlockUpdated { block_number: T::BlockNumber },
}

#[pallet::error]
Expand Down Expand Up @@ -222,7 +222,7 @@ pub mod pallet {
vat: Permill::zero(),
};
Accounts::<T>::insert(&who, status);
Self::deposit_event(Event::<T>::AccountCreated(who));
Self::deposit_event(Event::<T>::AccountCreated { who });
Ok(())
}

Expand Down Expand Up @@ -251,7 +251,7 @@ pub mod pallet {
Ok(())
},
)?;
Self::deposit_event(Event::<T>::ValidityUpdated(who, validity));
Self::deposit_event(Event::<T>::ValidityUpdated { who, validity });
Ok(())
}

Expand Down Expand Up @@ -283,7 +283,11 @@ pub mod pallet {
Ok(())
},
)?;
Self::deposit_event(Event::<T>::BalanceUpdated(who, free_balance, locked_balance));
Self::deposit_event(Event::<T>::BalanceUpdated {
who,
free: free_balance,
locked: locked_balance,
});
Ok(())
}

Expand Down Expand Up @@ -346,11 +350,11 @@ pub mod pallet {

// Setting the user account to `Completed` ends the purchase process for this user.
status.validity = AccountValidity::Completed;
Self::deposit_event(Event::<T>::PaymentComplete(
who.clone(),
status.free_balance,
status.locked_balance,
));
Self::deposit_event(Event::<T>::PaymentComplete {
who: who.clone(),
free: status.free_balance,
locked: status.locked_balance,
});
Ok(())
},
)?;
Expand All @@ -367,7 +371,7 @@ pub mod pallet {
T::ConfigurationOrigin::ensure_origin(origin)?;
// Possibly this is worse than having the caller account be the payment account?
PaymentAccount::<T>::put(who.clone());
Self::deposit_event(Event::<T>::PaymentAccountSet(who));
Self::deposit_event(Event::<T>::PaymentAccountSet { who });
Ok(())
}

Expand Down Expand Up @@ -402,7 +406,7 @@ pub mod pallet {
);
// Possibly this is worse than having the caller account be the payment account?
UnlockBlock::<T>::set(unlock_block);
Self::deposit_event(Event::<T>::UnlockBlockUpdated(unlock_block));
Self::deposit_event(Event::<T>::UnlockBlockUpdated { block_number: unlock_block });
Ok(())
}
}
Expand Down