Skip to content

Commit

Permalink
rf: use rpc for network info rather from config
Browse files Browse the repository at this point in the history
  • Loading branch information
debendraoli committed Jun 6, 2024
1 parent d432c87 commit 9d5999d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions relayer/chains/wasm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type IClient interface {
Subscribe(ctx context.Context, _, query string) (<-chan coretypes.ResultEvent, error)
Unsubscribe(ctx context.Context, _, query string) error
GetFee(ctx context.Context, addr string, queryData []byte) (uint64, error)
GetNetworkInfo(ctx context.Context) (*coretypes.ResultStatus, error)
}

type Client struct {
Expand Down Expand Up @@ -225,6 +226,11 @@ func (c *Client) GetFee(ctx context.Context, addr string, queryData []byte) (uin
return fee, nil
}

// GetNetworkInfo returns the network information
func (c *Client) GetNetworkInfo(ctx context.Context) (*coretypes.ResultStatus, error) {
return c.ctx.Client.Status(ctx)
}

// Subscribe
func (c *Client) Subscribe(ctx context.Context, _, query string) (<-chan coretypes.ResultEvent, error) {
return c.ctx.Client.(*http.HTTP).Subscribe(ctx, "subscribe", query)
Expand Down
6 changes: 5 additions & 1 deletion relayer/chains/wasm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ func (c *Config) newClientContext(ctx context.Context) (sdkClient.Context, error
if err != nil {
return sdkClient.Context{}, err
}
networkInfo, err := cometRPCClient.Status(ctx)
if err != nil {
return sdkClient.Context{}, err
}

return sdkClient.Context{
CmdContext: ctx,
ChainID: c.ChainID,
ChainID: networkInfo.NodeInfo.Network,
Client: cometRPCClient,
NodeURI: c.RPCUrl,
Codec: codec.Codec,
Expand Down
1 change: 0 additions & 1 deletion relayer/chains/wasm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ func (p *Provider) logTxFailed(err error, txHash string, code relayTypes.Respons
func (p *Provider) logTxSuccess(height uint64, txHash string) {
p.logger.Info("successful transaction",
zap.Uint64("block_height", height),
zap.String("chain_id", p.cfg.ChainID),
zap.String("tx_hash", txHash),
)
}
Expand Down
1 change: 0 additions & 1 deletion relayer/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type ChainProvider interface {
// CommonConfig is the common configuration for all chain providers
type CommonConfig struct {
ChainName string `json:"-" yaml:"-"`
ChainID string `json:"chain-id" yaml:"chain-id"`
RPCUrl string `json:"rpc-url" yaml:"rpc-url"`
StartHeight uint64 `json:"start-height" yaml:"start-height"`
Address string `json:"address" yaml:"address"`
Expand Down

0 comments on commit 9d5999d

Please sign in to comment.