forked from hyperledger-labs/yui-ibc-solidity
/
types.go
53 lines (48 loc) · 1.8 KB
/
types.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ethereum
import (
connectiontypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
commitmenttypes "github.com/cosmos/ibc-go/v4/modules/core/23-commitment/types"
"github.com/cosmos/ibc-go/v4/modules/core/exported"
"github.com/hyperledger-labs/yui-ibc-solidity/pkg/contract/ibchandler"
"github.com/hyperledger-labs/yui-ibc-solidity/pkg/contract/ibchost"
)
func connectionEndToPB(conn ibchost.ConnectionEndData) connectiontypes.ConnectionEnd {
connpb := connectiontypes.ConnectionEnd{
ClientId: conn.ClientId,
Versions: []*connectiontypes.Version{},
State: connectiontypes.State(conn.State),
DelayPeriod: conn.DelayPeriod,
Counterparty: connectiontypes.Counterparty{
ClientId: conn.Counterparty.ClientId,
ConnectionId: conn.Counterparty.ConnectionId,
Prefix: commitmenttypes.MerklePrefix(conn.Counterparty.Prefix),
},
}
for _, v := range conn.Versions {
ver := connectiontypes.Version(v)
connpb.Versions = append(connpb.Versions, &ver)
}
return connpb
}
func channelToPB(chann ibchost.ChannelData) channeltypes.Channel {
return channeltypes.Channel{
State: channeltypes.State(chann.State),
Ordering: channeltypes.Order(chann.Ordering),
Counterparty: channeltypes.Counterparty(chann.Counterparty),
ConnectionHops: chann.ConnectionHops,
Version: chann.Version,
}
}
func pbToHandlerHeight(height exported.Height) ibchandler.HeightData {
return ibchandler.HeightData{
RevisionNumber: height.GetRevisionNumber(),
RevisionHeight: height.GetRevisionHeight(),
}
}
func pbToHostHeight(height exported.Height) ibchost.HeightData {
return ibchost.HeightData{
RevisionNumber: height.GetRevisionNumber(),
RevisionHeight: height.GetRevisionHeight(),
}
}