Skip to content
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

feat(nexus): gmp events metadata #2187

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

6 changes: 6 additions & 0 deletions proto/axelar/axelarnet/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ message FeePaid {
cosmos.base.v1beta1.Coin fee = 3 [ (gogoproto.nullable) = false ];
string refund_recipient = 4;
string asset = 5; // registered asset name in nexus
string source_chain = 6
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
string destination_chain = 7
[ (gogoproto.casttype) =
"github.com/axelarnetwork/axelar-core/x/nexus/exported.ChainName" ];
}

message ContractCallSubmitted {
Expand Down
20 changes: 18 additions & 2 deletions proto/axelar/nexus/v1beta1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,25 @@ message MessageReceived {

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

@milapsheth milapsheth Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about this one? Let's add it here for consistency as well. I think axelarscan might have requested this at some point as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can add, they didn't ask for this


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
10 changes: 6 additions & 4 deletions x/axelarnet/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ func (s msgServer) CallContract(c context.Context, req *types.CallContractReques
}

feePaidEvent := types.FeePaid{
MessageID: msgID,
Recipient: req.Fee.Recipient,
Fee: req.Fee.Amount,
Asset: token.GetDenom(),
MessageID: msgID,
Recipient: req.Fee.Recipient,
Fee: req.Fee.Amount,
Asset: token.GetDenom(),
SourceChain: msg.GetSourceChain(),
DestinationChain: msg.GetDestinationChain(),
}
if req.Fee.RefundRecipient != nil {
feePaidEvent.RefundRecipient = req.Fee.RefundRecipient.String()
Expand Down
17 changes: 10 additions & 7 deletions x/axelarnet/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd
id, txID, nonce := n.GenerateMessageID(ctx)

// ignore token for call contract
_, err := deductFee(ctx, b, msg.Fee, token, id)
_, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, nexus.ChainName(msg.DestinationChain))
if err != nil {
return err
}
Expand Down Expand Up @@ -287,7 +287,7 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd
func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error {
id, txID, nonce := n.GenerateMessageID(ctx)

token, err := deductFee(ctx, b, msg.Fee, token, id)
token, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, nexus.ChainName(msg.DestinationChain))
if err != nil {
return err
}
Expand Down Expand Up @@ -392,20 +392,23 @@ func extractTokenFromPacketData(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.
}

// deductFee pays the fee and returns the updated transfer amount with the fee deducted
func deductFee(ctx sdk.Context, b types.BankKeeper, fee *Fee, token keeper.Coin, msgID string) (keeper.Coin, error) {
func deductFee(ctx sdk.Context, b types.BankKeeper, fee *Fee, token keeper.Coin, msgID string, sourceChain nexus.ChainName, destinationChain nexus.ChainName) (keeper.Coin, error) {
haiyizxx marked this conversation as resolved.
Show resolved Hide resolved
if fee == nil {
return token, nil
}

feeAmount := funcs.MustOk(sdk.NewIntFromString(fee.Amount))
coin := sdk.NewCoin(funcs.Must(token.GetOriginalDenom()), feeAmount)
recipient := funcs.Must(sdk.AccAddressFromBech32(fee.Recipient))
destinationChain = nexus.ChainName(strings.ToLower(destinationChain.String()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary? It's the same type. Is this about casing? If so, can you add a comment?


feePaidEvent := types.FeePaid{
MessageID: msgID,
Recipient: recipient,
Fee: coin,
Asset: token.GetDenom(),
MessageID: msgID,
Recipient: recipient,
Fee: coin,
Asset: token.GetDenom(),
SourceChain: sourceChain,
DestinationChain: destinationChain,
}
if fee.RefundRecipient != nil {
feePaidEvent.RefundRecipient = *fee.RefundRecipient
Expand Down
Loading
Loading