A lot of event field types ( cadence.Type from TransactionResult.Events[].Value.EventType.Fields[].Type ) has a nil value, is this expected?
EventType.Fields[].Type with nil values:
flow.AccountKeyAdded publicKey
flow.AccountKeyRemoved publicKey
flow.AccountCodeUpdated codeHash
flow.AccountCodeUpdated contracts
A.0b2a3299cc857e29.TopShot.Withdraw from
A.c1e4f4f4c4257510.Market.MomentWithdrawn owner
A.0b2a3299cc857e29.TopShot.Deposit to
A.c1e4f4f4c4257510.Market.CutPercentageChanged seller
A.c1e4f4f4c4257510.Market.MomentListed seller
A.ead892083b3e2c6c.DapperUtilityCoin.TokensWithdrawn from
A.ead892083b3e2c6c.DapperUtilityCoin.TokensDeposited to
A.e544175ee0461c4b.TokenForwarding.ForwardedDeposit from
A.c1e4f4f4c4257510.Market.MomentPurchased seller
A.0b2a3299cc857e29.TopShot.PlayCreated metadata
A.1654653399040a61.FlowToken.TokensWithdrawn from
A.1654653399040a61.FlowToken.TokensDeposited to
Other event field types has the correct type (e.g. UInt64 , Address , etc)
This is because the fields from those events are optionals. They are often used to show who the owner of the resource is when the event is emitted, but if the resource isn’t stored in an account when the event is emitted, the field is nil.
I see, I think EventType.Fields[].Type should contain a cadence.OptionalType value rather than nil if an event field type is an optional.
Because even event field optionals with a value has a nil value in their EventType.Fields[].Type
For example the first event in this transaction: 0x2ea2e9ba55600c4662237cf07c0fffb0d1a245cb676af93503fc46cecfd373e5, the from field that I get from Events[0].Value.Fields[1] has a value of address 0xdf73817b133cd960 but Events[0].Value.EventType.Fields[1].Type is nil
For now I’m using json.Encode on the value which provide the correct type for optionals.
However it might not work for all events as some field’s value are actually nil (since it’s an optional) so it’ll be better to have the type correctly defined in cadence.Field as the source of truth for the type of event fields.