Skip to content

Commit

Permalink
feat: add chain processor implementation (cosmos#924)
Browse files Browse the repository at this point in the history
* feat: add chain processor implementation

* fix: go-schnorrkel version fix

* fix: go mod update dockertest
  • Loading branch information
TxCorpi0x authored and oshorefueled committed Oct 20, 2022
1 parent 8c6d418 commit 9ea528a
Show file tree
Hide file tree
Showing 4 changed files with 437 additions and 9 deletions.
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/99designs/keyring v1.2.1
github.com/ComposableFi/go-substrate-rpc-client/v4 v4.0.1-0.20220820010439-71c9d526f2f5
github.com/ComposableFi/go-substrate-rpc-client/v4 v4.0.1-0.20220819133021-62ed9987ea7c
github.com/avast/retry-go/v4 v4.1.0
github.com/cosmos/cosmos-sdk v0.46.1
github.com/cosmos/ibc-go/v5 v5.0.0
Expand All @@ -18,7 +18,7 @@ require (
github.com/prometheus/client_golang v1.12.2
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
github.com/strangelove-ventures/lens v0.5.2-0.20220822201013-1e7ffd450f20
github.com/strangelove-ventures/lens v0.5.2-0.20220810214843-6af97ce869d8
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.21
go.uber.org/multierr v1.8.0
Expand All @@ -38,7 +38,7 @@ require (
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
Expand Down Expand Up @@ -188,5 +188,3 @@ require (
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

replace github.com/ChainSafe/go-schnorrkel v1.0.0 => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
29 changes: 29 additions & 0 deletions relayer/chains/substrate/event_parser.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package substrate

import (
rpcclienttypes "github.com/ComposableFi/go-substrate-rpc-client/v4/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
"github.com/cosmos/relayer/v2/relayer/processor"
"github.com/cosmos/relayer/v2/relayer/provider"
)

// ibcMessagesFromTransaction parses all events within a transaction to find IBC messages
func (scp *SubstrateChainProcessor) handleIBCMessagesFromEvents(ibcEvents rpcclienttypes.IBCEventsQueryResult, height uint64, c processor.IBCMessagesCache) error {
//TODO implement me
panic("implement me")
}

// client info attributes and methods
type clientInfo struct {
Height clienttypes.Height `json:"height"`
ClientID string `json:"client_id"`
ClientType uint32 `json:"client_type"`
ConsensusHeight clienttypes.Height `json:"consensus_height"`
}

func (c clientInfo) ClientState() provider.ClientState {
return provider.ClientState{
ClientID: c.ClientID,
ConsensusHeight: c.ConsensusHeight,
}
}
30 changes: 26 additions & 4 deletions relayer/chains/substrate/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path"
"time"

rpcclient "github.com/ComposableFi/go-substrate-rpc-client/v4"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types"
Expand Down Expand Up @@ -84,10 +85,31 @@ func (sp *SubstrateProvider) Init() error {
}

type SubstrateProvider struct {
log *zap.Logger
Keybase keystore.Keyring
PCfg SubstrateProviderConfig
Input io.Reader
log *zap.Logger
Keybase keystore.Keyring
RPCClient *rpcclient.SubstrateAPI
PCfg SubstrateProviderConfig
Input io.Reader
}

type SubstrateIBCHeader struct{}

// noop to implement processor.IBCHeader
func (h SubstrateIBCHeader) IBCHeaderIndicator() {
//TODO implement me
panic("implement me")
}

func (h SubstrateIBCHeader) Height() uint64 {
//TODO implement me
panic("implement me")
return 0
}

func (h SubstrateIBCHeader) ConsensusState() ibcexported.ConsensusState {
//TODO implement me
panic("implement me")
return nil
}

func (sp *SubstrateProvider) BlockTime(ctx context.Context, height int64) (time.Time, error) {
Expand Down
Loading

0 comments on commit 9ea528a

Please sign in to comment.