-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: api events #153
feat: api events #153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, not sure about the id removal from the events. See inline comments for more context.
pallets/api/src/fungibles/mod.rs
Outdated
#[pallet::event] | ||
#[pallet::generate_deposit(pub(super) fn deposit_event)] | ||
pub enum Event<T: Config> { | ||
/// Event emitted when allowance by `owner` to `spender` changes. | ||
Approval { | ||
/// Token ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I think this is problematic. I understand it was probably removed to conform to the standard, but does ommitting it effectively make it useless? The events are emitted from a pallet managing multiple assets, so without knowing which asset id had an approval, is there any point? A contract call might be able to correlate the resulting events based on the extrinsic events, but if contract makes two calls to the fungibles pallet to create an allowance, for two different assets, how can we tell from the events which value matches which asset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But perhaps this brings us back to this comment.
In short, reason for adding events to the fungible pallet:
- standard compliance - the problem is that the events are not useful though (see frank's comment). In addition, when we do add the
asset_id
the events become the same as in pallet assets (e.g. Transferred) - pallet usage - we have an indicator how often the pallet is used. More interesting is how often the API is used
Would it be oke to start without events in the pallet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be oke to start without events in the pallet?
I would rather we start with something, even super simple events so we can be aware of if the API is being used on testnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I will then add the asset id
back in the Transfer
and Approval
event
A general heads up that all these PRs to the |
On it right away |
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## daan/api #153 +/- ##
============================================
+ Coverage 32.45% 33.62% +1.16%
============================================
Files 33 34 +1
Lines 2915 2995 +80
Branches 2915 2995 +80
============================================
+ Hits 946 1007 +61
- Misses 1946 1956 +10
- Partials 23 32 +9
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a small comment, good with whatever you decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more optimisation and a variable rename for consistency. Peter has a good point in terms of emitting events to determine usage, so hopefully a quick add.
[sc-1124] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last minor refactor then good for me.
Co-authored-by: Frank Bell <[email protected]>
Added events to contract library and pallet, including tests for the pallet.
Note: the weight for increase allowance has changed due to an extra storage read.
The events in the contract library will have to be demonstrated in an example contract. This will have to be done in a different PR.