Skip to content

Commit

Permalink
feat: build message directly in send function
Browse files Browse the repository at this point in the history
  • Loading branch information
dtkhanh-smartosc committed May 9, 2024
1 parent c08eb2c commit 37709c5
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 103 deletions.
13 changes: 13 additions & 0 deletions relayer/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ const (
EpochPeriod = 5
ClientTrustingPeriod = EpochPeriod * 24 * time.Hour
OgmiosEndpoint = "OGMIOS_ENDPOINT"

MsgCreateClient = "/ibc.core.client.v1.MsgCreateClient"
MsgUpdateClient = "/ibc.core.client.v1.MsgUpdateClient"
MsgConnectionOpenInit = "/ibc.core.connection.v1.MsgConnectionOpenInit"
MsgConnectionOpenAck = "/ibc.core.connection.v1.MsgConnectionOpenAck"
MsgChannelOpenInit = "/ibc.core.channel.v1.MsgChannelOpenInit"
MsgChannelOpenAck = "/ibc.core.channel.v1.MsgChannelOpenAck"
MsgApplicationTransfer = "/ibc.applications.transfer.v1.MsgTransfer"
MsgRecvPacket = "/ibc.core.channel.v1.MsgRecvPacket"
MsgAcknowledgement = "/ibc.core.channel.v1.MsgAcknowledgement"

MsgTimeoutRefresh = "/ibc.core.channel.v1.MsgChannelCloseInit" //todo: find a better solution for this msg
MsgTimeOut = "/ibc.core.channel.v1.MsgTimeout"
)
16 changes: 5 additions & 11 deletions relayer/relayer/chains/cardano/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package cardano

import (
"fmt"

"google.golang.org/protobuf/types/known/anypb"
"github.com/gogo/protobuf/proto"

"github.com/cardano/relayer/v1/relayer/provider"
"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -13,17 +12,15 @@ import (

type CardanoMessage struct {
Msg sdk.Msg
UnsignedTx *anypb.Any
SetSigner func(string) //callback to update the Msg Signer field
FeegrantDisabled bool //marks whether this message type should ALWAYS disable feegranting (use the default signer)
}

// After call getting unsigned msg from gateway pls set UnsignedTx
func NewCardanoMessage(msg sdk.Msg, unsignedTx *anypb.Any, optionalSetSigner func(string)) provider.RelayerMessage {
func NewCardanoMessage(msg sdk.Msg, optionalSetSigner func(string)) provider.RelayerMessage {
return CardanoMessage{
Msg: msg,
UnsignedTx: unsignedTx,
SetSigner: optionalSetSigner,
Msg: msg,
SetSigner: optionalSetSigner,
}
}

Expand Down Expand Up @@ -54,10 +51,7 @@ func (cm CardanoMessage) Type() string {
}

func (cm CardanoMessage) MsgBytes() ([]byte, error) {
if cm.UnsignedTx == nil {
return nil, fmt.Errorf("UnsignedTx is nil")
}
return cm.UnsignedTx.Value, nil
return proto.Marshal(cm.Msg)
}

// MarshalLogObject is used to encode cm to a zap logger with the zap.Object field type.
Expand Down

0 comments on commit 37709c5

Please sign in to comment.