CatapultServer  v0.5.0.1 (Elephant)
RentalFeeObserver.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "ObserverTypes.h"
23 #include "catapult/model/Receipt.h"
24 
25 namespace catapult { namespace observers {
26 
28  template<typename TNotification>
31  return std::make_unique<ObserverType>(name + "RentalFeeObserver", [receiptType](
32  const auto& notification,
33  ObserverContext& context) {
34  if (NotifyMode::Rollback == context.Mode)
35  return;
36 
37  auto mosaicId = context.Resolvers.resolve(notification.MosaicId);
38  auto recipient = context.Resolvers.resolve(notification.Recipient);
39  model::BalanceTransferReceipt receipt(receiptType, notification.Sender, recipient, mosaicId, notification.Amount);
40  context.StatementBuilder().addReceipt(receipt);
41  });
42  }
43 }}
Receipt.h
catapult::observers::ObserverContext::StatementBuilder
ObserverStatementBuilder & StatementBuilder()
Statement builder.
Definition: ObserverContext.cpp:82
catapult::observers::ObserverContext
Context passed to all the observers.
Definition: ObserverContext.h:78
catapult::model::ResolverContext::resolve
MosaicId resolve(UnresolvedMosaicId mosaicId) const
Resolves mosaic id (mosaicId).
Definition: ResolverContext.cpp:41
ObserverTypes.h
catapult::observers::FunctionalNotificationObserverT
A notification observer implementation that wraps a function.
Definition: FunctionalNotificationObserver.h:29
catapult::model::ReceiptType
ReceiptType
Enumeration of receipt types.
Definition: ReceiptType.h:58
catapult::observers::ObserverContext::Resolvers
const model::ResolverContext Resolvers
Alias resolvers.
Definition: ObserverContext.h:98
catapult::observers::ObserverContext::Mode
const NotifyMode Mode
Notification mode.
Definition: ObserverContext.h:95
catapult::observers::NotificationObserverPointerT
std::unique_ptr< const NotificationObserverT< TNotification > > NotificationObserverPointerT
A notification observer (unique) pointer.
Definition: ObserverTypes.h:34
catapult::model::BalanceTransferReceipt
Binary layout for a balance transfer receipt.
Definition: Receipt.h:40
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::observers::ObserverStatementBuilder::addReceipt
void addReceipt(const model::Receipt &receipt)
Adds receipt to this builder.
Definition: ObserverStatementBuilder.cpp:43
catapult::observers::CreateRentalFeeObserver
NotificationObserverPointerT< TNotification > CreateRentalFeeObserver(const std::string &name, model::ReceiptType receiptType)
Creates a rental fee observer with name that adds receipts with receiptType.
Definition: RentalFeeObserver.h:29