From 183440a66610843fb863502302d3b967cb32b1b7 Mon Sep 17 00:00:00 2001 From: kevinssgh Date: Fri, 5 Apr 2024 13:08:11 -0400 Subject: [PATCH] moved sdk client flag to zetabridge struct --- zetaclient/config/types.go | 4 -- zetaclient/zetabridge/broadcast.go | 2 +- zetaclient/zetabridge/zetacore_bridge.go | 48 +++++++++++++----------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index beb5db63bb..b53bcc17dd 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -25,10 +25,6 @@ type ClientConfiguration struct { SignerName string `json:"signer_name" mapstructure:"signer_name"` SignerPasswd string `json:"signer_passwd"` HsmMode bool `json:"hsm_mode"` - - // UseMockSDKClient is a flag that determines whether the mock cosmos sdk client should be used, primarily for - // unit testing - UseMockSDKClient bool `json:"use_mock_sdk_client"` } type EVMConfig struct { diff --git a/zetaclient/zetabridge/broadcast.go b/zetaclient/zetabridge/broadcast.go index 096adca3c3..58fddbd223 100644 --- a/zetaclient/zetabridge/broadcast.go +++ b/zetaclient/zetabridge/broadcast.go @@ -173,7 +173,7 @@ func (b *ZetaCoreBridge) GetContext() (client.Context, error) { ctx = ctx.WithLegacyAmino(b.encodingCfg.Amino) ctx = ctx.WithAccountRetriever(authtypes.AccountRetriever{}) - if b.cfg.UseMockSDKClient { + if b.enableMockSDKClient { ctx = ctx.WithClient(b.mockSDKClient) } else { remote := b.cfg.ChainRPC diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index af6f9414d2..0de3f994b0 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -43,8 +43,12 @@ type ZetaCoreBridge struct { zetaChain chains.Chain stop chan struct{} pause chan struct{} - mockSDKClient rpcclient.Client Telemetry *metrics.TelemetryServer + + // enableMockSDKClient is a flag that determines whether the mock cosmos sdk client should be used, primarily for + // unit testing + enableMockSDKClient bool + mockSDKClient rpcclient.Client } // NewZetaCoreBridge create a new instance of ZetaCoreBridge @@ -60,12 +64,11 @@ func NewZetaCoreBridge( // main module logger logger := log.With().Str("module", "CoreBridge").Logger() cfg := config.ClientConfiguration{ - ChainHost: fmt.Sprintf("%s:1317", chainIP), - SignerName: signerName, - SignerPasswd: "password", - ChainRPC: fmt.Sprintf("%s:26657", chainIP), - HsmMode: hsmMode, - UseMockSDKClient: false, + ChainHost: fmt.Sprintf("%s:1317", chainIP), + SignerName: signerName, + SignerPasswd: "password", + ChainRPC: fmt.Sprintf("%s:26657", chainIP), + HsmMode: hsmMode, } grpcConn, err := grpc.Dial( @@ -89,20 +92,21 @@ func NewZetaCoreBridge( } return &ZetaCoreBridge{ - logger: logger, - grpcConn: grpcConn, - accountNumber: accountsMap, - seqNumber: seqMap, - cfg: cfg, - encodingCfg: app.MakeEncodingConfig(), - keys: k, - broadcastLock: &sync.RWMutex{}, - stop: make(chan struct{}), - zetaChainID: chainID, - zetaChain: zetaChain, - pause: make(chan struct{}), - mockSDKClient: nil, - Telemetry: telemetry, + logger: logger, + grpcConn: grpcConn, + accountNumber: accountsMap, + seqNumber: seqMap, + cfg: cfg, + encodingCfg: app.MakeEncodingConfig(), + keys: k, + broadcastLock: &sync.RWMutex{}, + stop: make(chan struct{}), + zetaChainID: chainID, + zetaChain: zetaChain, + pause: make(chan struct{}), + Telemetry: telemetry, + enableMockSDKClient: false, + mockSDKClient: nil, }, nil } @@ -277,5 +281,5 @@ func (b *ZetaCoreBridge) Unpause() { func (b *ZetaCoreBridge) EnableMockSDKClient(client rpcclient.Client) { b.mockSDKClient = client - b.cfg.UseMockSDKClient = true + b.enableMockSDKClient = true }