-
Notifications
You must be signed in to change notification settings - Fork 1
/
ibc_send.go
32 lines (27 loc) · 960 Bytes
/
ibc_send.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package keeper
import (
"github.com/celinium-network/celinium/x/liquidstake/types"
sdk "github.com/cosmos/cosmos-sdk/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
"github.com/gogo/protobuf/proto"
)
func (k Keeper) sendIBCMsg(ctx sdk.Context, msgs []proto.Message, connectionID string, sender string) (uint64, string, error) {
data, err := icatypes.SerializeCosmosTx(k.cdc, msgs)
if err != nil {
return 0, "", err
}
packetData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: data,
}
timeoutTimestamp := ctx.BlockTime().UnixNano() + types.DefaultICATimeoutNanos
sendPortID, err := icatypes.NewControllerPortID(sender)
if err != nil {
return 0, "", err
}
sequence, err := k.icaCtlKeeper.SendTx(ctx, nil, connectionID, sendPortID, packetData, uint64(timeoutTimestamp)) //nolint:staticcheck //
if err != nil {
return 0, "", err
}
return sequence, sendPortID, nil
}