-
Notifications
You must be signed in to change notification settings - Fork 189
Added mint event type to NotificationDB #433
Conversation
@@ -231,11 +229,18 @@ def __init__(self, event_type, event_payload, contract_hash, block_number, tx_ha | |||
self.amount = int(BigInteger.FromBytes(event_payload[3])) if isinstance(event_payload[3], bytes) else int(event_payload[3]) | |||
self.is_standard_notify = True | |||
|
|||
elif plen == 3 and self.notify_type == NotifyType.REFUND: | |||
elif self.notify_type == NotifyType.REFUND and plen >= 3: # Might have more arguments |
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.
Saw some contracts that have 4 arguments, using this signature:
OnRefund = RegisterAction('refund', 'addr_to', 'amount', '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.
Interesting, I wonder what the 4th argument is?
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.
whether it's gas or neo?
elif self.notify_type == NotifyType.MINT and plen == 3: | ||
self.addr_to = UInt160(data=self.event_payload[1]) if len(self.event_payload[1]) == 20 else empty | ||
self.amount = int(BigInteger.FromBytes(event_payload[2])) if isinstance(event_payload[2], bytes) else int(event_payload[2]) | ||
self.addr_from = self.contract_hash |
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.
Is this the correct approach? I know that there isn't a defined standard around minting yet, but many smart contracts use a null
from
address for the minting operations. I realize this is just for the mint SC event notification, but I do wonder if this would be expected for someone writing an event handler. Probably not a big deal, but I thought I'd raise it as a consideration anyway...
In my database I'm considering the all zeroes public key as the "minting source", since most contracts seem to have used that approach. I would encourage this approach to be the standard, to keep behavior uniform. |
What current issue(s) does this address, or what feature is it adding?
Added mint events to the NotificationDB.
How did you solve this problem?
Updated
NotificationDB.py
andSmartContractEvent.py
How did you make sure your solution works?
Added a test, but not live tested.
Couldn't get any current mint events on my bootstrapped chains. Is there an easy way to test it, besides on a private net and deploying a NEP-5 SC? (Reminds me, we should a NEP-5 SC to the privatenet default)
Are there any special changes in the code that we should be aware of?
No
Please check the following, if applicable:
make lint
?make test
?CHANGELOG.rst
? (if not, please do)