Skip to content

Commit

Permalink
feat(nexus): gmp events metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
haiyizxx committed Sep 26, 2024
1 parent 2c52c94 commit 359710c
Show file tree
Hide file tree
Showing 4 changed files with 407 additions and 58 deletions.
6 changes: 6 additions & 0 deletions docs/proto/proto-docs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions proto/axelar/nexus/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,37 @@ message MessageReceived {
[ (gogoproto.nullable) = false ];
exported.v1beta1.CrossChainAddress recipient = 4
[ (gogoproto.nullable) = false ];
string source_chain = 5
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
string destination_chain = 6
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
}

message MessageProcessing { string id = 1 [ (gogoproto.customname) = "ID" ]; }
message MessageProcessing {
string id = 1 [ (gogoproto.customname) = "ID" ];
}

message MessageExecuted { string id = 1 [ (gogoproto.customname) = "ID" ]; }
message MessageExecuted {
string id = 1 [ (gogoproto.customname) = "ID" ];
string source_chain = 2
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
string destination_chain = 3
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
}

message MessageFailed { string id = 1 [ (gogoproto.customname) = "ID" ]; }
message MessageFailed {
string id = 1 [ (gogoproto.customname) = "ID" ];
string source_chain = 2
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
string destination_chain = 3
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
}

message WasmMessageRouted {
exported.v1beta1.WasmMessage message = 1 [ (gogoproto.nullable) = false ];
Expand Down
22 changes: 16 additions & 6 deletions x/nexus/keeper/general_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ func (k Keeper) SetMessageExecuted(ctx sdk.Context, id string) error {

m.Status = exported.Executed

funcs.MustNoErr(ctx.EventManager().EmitTypedEvent(&types.MessageExecuted{ID: m.ID}))
funcs.MustNoErr(ctx.EventManager().EmitTypedEvent(&types.MessageExecuted{
ID: m.ID,
SourceChain: m.GetSourceChain(),
DestinationChain: m.GetDestinationChain(),
}))

return k.setMessage(ctx, m)
}
Expand All @@ -71,7 +75,11 @@ func (k Keeper) SetMessageFailed(ctx sdk.Context, id string) error {

m.Status = exported.Failed

funcs.MustNoErr(ctx.EventManager().EmitTypedEvent(&types.MessageFailed{ID: m.ID}))
funcs.MustNoErr(ctx.EventManager().EmitTypedEvent(&types.MessageFailed{
ID: m.ID,
SourceChain: m.GetSourceChain(),
DestinationChain: m.GetDestinationChain(),
}))

return k.setMessage(ctx, m)
}
Expand Down Expand Up @@ -149,10 +157,12 @@ func (k Keeper) SetNewMessage(ctx sdk.Context, msg exported.GeneralMessage) erro
}

funcs.MustNoErr(ctx.EventManager().EmitTypedEvent(&types.MessageReceived{
ID: msg.ID,
PayloadHash: msg.PayloadHash,
Sender: msg.Sender,
Recipient: msg.Recipient,
ID: msg.ID,
PayloadHash: msg.PayloadHash,
Sender: msg.Sender,
Recipient: msg.Recipient,
SourceChain: msg.GetSourceChain(),
DestinationChain: msg.GetDestinationChain(),
}))

return k.setMessage(ctx, msg)
Expand Down
Loading

0 comments on commit 359710c

Please sign in to comment.