-
Notifications
You must be signed in to change notification settings - Fork 751
Closed
Labels
testingTesting package and unit/integration testsTesting package and unit/integration teststype: code hygieneClean up code but without changing functionality or interfacesClean up code but without changing functionality or interfaces
Description
At the moment we have multiple methods to parse out specific event attributes (examples below).
As per the discussion here #6648 (comment)
Maybe we can find a clean way to more generically pick out values that we need.
// ParseProposalIDFromEvents parses events emitted from MsgSubmitProposal and returns proposalID
func ParseProposalIDFromEvents(events []abci.Event) (uint64, error) {
for _, event := range events {
for _, attribute := range event.Attributes {
if attribute.Key == "proposal_id" {
return strconv.ParseUint(attribute.Value, 10, 64)
}
}
}
return 0, fmt.Errorf("proposalID event attribute not found")
}
// ParsePacketSequenceFromEvents parses events emitted from MsgRecvPacket and returns the packet sequence
func ParsePacketSequenceFromEvents(events []abci.Event) (uint64, error) {
for _, event := range events {
for _, attribute := range event.Attributes {
if attribute.Key == "packet_sequence" {
return strconv.ParseUint(attribute.Value, 10, 64)
}
}
}
return 0, fmt.Errorf("packet sequence event attribute not found")
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testingTesting package and unit/integration testsTesting package and unit/integration teststype: code hygieneClean up code but without changing functionality or interfacesClean up code but without changing functionality or interfaces