-
Notifications
You must be signed in to change notification settings - Fork 240
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
Problem: no packet info for indexed field in ibc relayer event #1662
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,22 +17,24 @@ | |
RelayerEvents map[string]*EventDescriptor | ||
IcaEvents map[string]*EventDescriptor | ||
RelayerValueDecoders = ValueDecoders{ | ||
channeltypes.AttributeKeyDataHex: ConvertPacketData, | ||
transfertypes.AttributeKeyAmount: ConvertAmount, | ||
banktypes.AttributeKeyRecipient: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeySpender: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyReceiver: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeySender: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyMinter: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyBurner: ConvertAccAddressFromBech32, | ||
channeltypes.AttributeKeySequence: ReturnStringAsIs, | ||
channeltypes.AttributeKeySrcPort: ReturnStringAsIs, | ||
channeltypes.AttributeKeySrcChannel: ReturnStringAsIs, | ||
channeltypes.AttributeKeyDstPort: ReturnStringAsIs, | ||
channeltypes.AttributeKeyDstChannel: ReturnStringAsIs, | ||
channeltypes.AttributeKeyConnectionID: ReturnStringAsIs, | ||
ibcfeetypes.AttributeKeyFee: ReturnStringAsIs, | ||
transfertypes.AttributeKeyDenom: ReturnStringAsIs, | ||
channeltypes.AttributeKeyDataHex: ConvertPacketData, | ||
transfertypes.AttributeKeyAmount: ConvertAmount, | ||
banktypes.AttributeKeyRecipient: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeySpender: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyReceiver: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeySender: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyMinter: ConvertAccAddressFromBech32, | ||
banktypes.AttributeKeyBurner: ConvertAccAddressFromBech32, | ||
channeltypes.AttributeKeySequence: ConvertUint64, | ||
channeltypes.AttributeKeySrcPort: ReturnStringAsIs, | ||
cronoseventstypes.AttributeKeySrcPortInfo: ReturnStringAsIs, | ||
channeltypes.AttributeKeySrcChannel: ReturnStringAsIs, | ||
cronoseventstypes.AttributeKeySrcChannelInfo: ReturnStringAsIs, | ||
channeltypes.AttributeKeyDstPort: ReturnStringAsIs, | ||
channeltypes.AttributeKeyDstChannel: ReturnStringAsIs, | ||
channeltypes.AttributeKeyConnectionID: ReturnStringAsIs, | ||
ibcfeetypes.AttributeKeyFee: ReturnStringAsIs, | ||
transfertypes.AttributeKeyDenom: ReturnStringAsIs, | ||
} | ||
IcaValueDecoders = ValueDecoders{ | ||
cronoseventstypes.AttributeKeySeq: ConvertUint64, | ||
|
@@ -59,13 +61,17 @@ | |
if !ok { | ||
return nil, nil | ||
} | ||
return desc.ConvertEvent(event.Attributes, RelayerValueDecoders) | ||
replaceAttrs := map[string]string{ | ||
cronoseventstypes.AttributeKeySrcPortInfo: channeltypes.AttributeKeySrcPort, | ||
cronoseventstypes.AttributeKeySrcChannelInfo: channeltypes.AttributeKeySrcChannel, | ||
} | ||
return desc.ConvertEvent(event.Attributes, RelayerValueDecoders, replaceAttrs) | ||
Comment on lines
+64
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add test coverage for the new attribute replacement logic. The new attribute replacement logic is not covered by tests. Please add test cases to verify the correct mapping of Would you like me to help generate test cases? Here's a suggested test structure: func TestRelayerConvertEvent_AttributeReplacement(t *testing.T) {
testCases := []struct {
name string
event sdk.Event
expected *ethtypes.Log
}{
{
name: "should replace port info attributes",
event: sdk.Event{
Type: "ibc_transfer",
Attributes: []sdk.Attribute{
{Key: cronoseventstypes.AttributeKeySrcPortInfo, Value: "transfer"},
{Key: cronoseventstypes.AttributeKeySrcChannelInfo, Value: "channel-0"},
},
},
// Add expected values
},
// Add more test cases
}
// Implement test logic
} 🧰 Tools🪛 GitHub Check: codecov/patch
|
||
} | ||
|
||
func IcaConvertEvent(event sdk.Event) (*ethtypes.Log, error) { | ||
desc, ok := IcaEvents[event.Type] | ||
if !ok { | ||
return nil, nil | ||
} | ||
return desc.ConvertEvent(event.Attributes, IcaValueDecoders) | ||
return desc.ConvertEvent(event.Attributes, IcaValueDecoders, map[string]string{}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package types | ||
|
||
const ( | ||
EventTypeSubmitMsgsResult = "submit_msgs_result" | ||
AttributeKeySeq = "seq" | ||
EventTypeSubmitMsgsResult = "submit_msgs_result" | ||
AttributeKeySeq = "seq" | ||
AttributeKeySrcPortInfo = "packet_src_port_info" | ||
AttributeKeySrcChannelInfo = "packet_src_channel_info" | ||
) |
Check warning
Code scanning / CodeQL
Iteration over map Warning