F
Flow8mo ago
joshua

joshua | Flow (2024-05-06)

I updated to the latest preview of flow-go-sdk, cadence, and emulator and I am getting this error in my Go tests now:
./nft_test_helpers.go:37:19: evt.Value.Fields undefined (type cadence.Event has no field or method Fields)
./nft_test_helpers.go:37:19: evt.Value.Fields undefined (type cadence.Event has no field or method Fields)
This is my code:
type Withdrawn struct {
nftType string
id uint64
uuid uint64
from string
providerUuid uint64
}

type WithdrawnEvent flow.Event

func (evt WithdrawnEvent) NftType() cadence.String {
return evt.Value.Fields[0].(cadence.String)
}
type Withdrawn struct {
nftType string
id uint64
uuid uint64
from string
providerUuid uint64
}

type WithdrawnEvent flow.Event

func (evt WithdrawnEvent) NftType() cadence.String {
return evt.Value.Fields[0].(cadence.String)
}
I checked the cadence value code for events and tried fields, and getFieldValues() but those aren't found either.
github.com/onflow/cadence v1.0.0-preview.25
github.com/onflow/flow-emulator v1.0.0-preview.22
github.com/onflow/flow-go-sdk v1.0.0-preview.25
github.com/onflow/cadence v1.0.0-preview.25
github.com/onflow/flow-emulator v1.0.0-preview.22
github.com/onflow/flow-go-sdk v1.0.0-preview.25
Any idea what I should be using there to get a field from an event?
4 Replies
Needle
Needle8mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
turbolent
turbolent8mo ago
This is one of the Go API breaking changes in one of the last releases: https://github.com/onflow/cadence/releases/tag/v1.0.0-preview.24. As discussed in the office hours, we'll need to document this better
joshua
joshuaOP8mo ago
So what do I change it to in order to access it? It looks like the things in the events section of values.go didn't work
turbolent
turbolent8mo ago
I'm working on writing this up, I'll ping you once it's done @joshua | Flow see https://www.notion.so/flowfoundation/Cadence-Forum-Post-Update-3d1ed5be20684c1dacecc1392ae4ffe4?pvs=4#63212bd012474eafba216a166d04e2f0 for the draft of what is going to get published soon. please leave feedback @joshua | Flow Thanks for the feedback! Could you please have another look? If the examples look OK, I'll post
Want results from more Discord servers?
Add your server