Skip to content

Commit

Permalink
lint & format
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-cha committed Aug 14, 2024
1 parent 4d334a0 commit 2b227fe
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 42 deletions.
3 changes: 2 additions & 1 deletion executor/batch/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"

sdk "github.com/cosmos/cosmos-sdk/types"

ophosttypes "github.com/initia-labs/OPinit/x/ophost/types"

executortypes "github.com/initia-labs/opinit-bots-go/executor/types"
Expand Down
12 changes: 6 additions & 6 deletions executor/batch/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type Status struct {
LastBatchSubmissionTime time.Time `json:"last_batch_submission_time"`
}

func (b BatchSubmitter) GetStatus() Status {
fileSize, _ := b.batchFileSize()
func (bs BatchSubmitter) GetStatus() Status {
fileSize, _ := bs.batchFileSize()

return Status{
Node: b.node.GetStatus(),
BatchInfo: b.BatchInfo().BatchInfo,
Node: bs.node.GetStatus(),
BatchInfo: bs.BatchInfo().BatchInfo,
CurrentBatchFileSize: fileSize,
LastBatchEndBlockNumber: b.LastBatchEndBlockNumber,
LastBatchSubmissionTime: b.lastSubmissionTime,
LastBatchEndBlockNumber: bs.LastBatchEndBlockNumber,
LastBatchSubmissionTime: bs.lastSubmissionTime,
}
}
3 changes: 2 additions & 1 deletion executor/batch/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"encoding/binary"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"

sdk "github.com/cosmos/cosmos-sdk/types"

opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
"github.com/initia-labs/opinit-bots-go/txutils"
)
Expand Down
1 change: 1 addition & 0 deletions executor/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"go.uber.org/zap"

"github.com/cometbft/cometbft/crypto/merkle"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
3 changes: 2 additions & 1 deletion executor/child/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"strconv"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"

sdk "github.com/cosmos/cosmos-sdk/types"

nodetypes "github.com/initia-labs/opinit-bots-go/node/types"
"go.uber.org/zap"
)
Expand Down
3 changes: 2 additions & 1 deletion executor/child/msgs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package child

import (
sdk "github.com/cosmos/cosmos-sdk/types"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (ch Child) GetMsgFinalizeTokenDeposit(
Expand Down
3 changes: 2 additions & 1 deletion executor/child/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"encoding/json"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"

sdk "github.com/cosmos/cosmos-sdk/types"

executortypes "github.com/initia-labs/opinit-bots-go/executor/types"
"github.com/initia-labs/opinit-bots-go/node/rpcclient"
)
Expand Down
3 changes: 2 additions & 1 deletion executor/host/msgs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package host

import (
sdk "github.com/cosmos/cosmos-sdk/types"
ophosttypes "github.com/initia-labs/OPinit/x/ophost/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (h Host) GetMsgProposeOutput(
Expand Down
31 changes: 20 additions & 11 deletions executor/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@ import (

type Status struct {
BridgeId int64 `json:"bridge_id"`
Host host.Status `json:"host"`
Child child.Status `json:"child"`
Batch batch.Status `json:"batch"`
DA nodetypes.Status `json:"da"`
Host host.Status `json:"host,omitempty"`
Child child.Status `json:"child,omitempty"`
Batch batch.Status `json:"batch,omitempty"`
DA nodetypes.Status `json:"da,omitempty"`
}

func (e Executor) GetStatus() Status {
return Status{
BridgeId: e.host.BridgeId(),
Host: e.host.GetStatus(),
Child: e.child.GetStatus(),
Batch: e.batch.GetStatus(),
DA: e.batch.DA().GetNodeStatus(),
func (ex Executor) GetStatus() Status {
s := Status{
BridgeId: ex.host.BridgeId(),
}
if ex.host != nil {
s.Host = ex.host.GetStatus()
}
if ex.child != nil {
s.Child = ex.child.GetStatus()
}
if ex.batch != nil {
s.Batch = ex.batch.GetStatus()
if ex.batch.DA() != nil {
s.DA = ex.batch.DA().GetNodeStatus()
}
}
return s
}
3 changes: 2 additions & 1 deletion executor/types/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package types
import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
btypes "github.com/initia-labs/opinit-bots-go/node/broadcaster/types"
nodetypes "github.com/initia-labs/opinit-bots-go/node/types"
"github.com/initia-labs/opinit-bots-go/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type DANode interface {
Expand Down
3 changes: 2 additions & 1 deletion keys/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package keys

import (
"cosmossdk.io/x/tx/signing"
"github.com/cosmos/gogoproto/proto"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
"github.com/cosmos/gogoproto/proto"
)

type RegisterInterfaces func(registry codectypes.InterfaceRegistry)
Expand Down
3 changes: 2 additions & 1 deletion keys/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package keys
import (
"io"

"github.com/cosmos/go-bip39"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/go-bip39"
)

func GetKeyBase(chainId string, dir string, cdc codec.Codec, userInput io.Reader) (keyring.Keyring, error) {
Expand Down
3 changes: 2 additions & 1 deletion node/broadcaster/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (

rpccoretypes "github.com/cometbft/cometbft/rpc/core/types"

"github.com/pkg/errors"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/pkg/errors"

btypes "github.com/initia-labs/opinit-bots-go/node/broadcaster/types"
"github.com/initia-labs/opinit-bots-go/node/rpcclient"
Expand Down
3 changes: 2 additions & 1 deletion node/broadcaster/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"time"

"github.com/initia-labs/opinit-bots-go/keys"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/initia-labs/opinit-bots-go/keys"
)

type BuildTxWithMessagesFn func(context.Context, []sdk.Msg) ([]byte, string, error)
Expand Down
20 changes: 9 additions & 11 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"github.com/pkg/errors"

"cosmossdk.io/core/address"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/initia-labs/opinit-bots-go/node/broadcaster"
"github.com/initia-labs/opinit-bots-go/node/rpcclient"
nodetypes "github.com/initia-labs/opinit-bots-go/node/types"
"github.com/initia-labs/opinit-bots-go/types"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
)

type Node struct {
Expand Down Expand Up @@ -189,17 +190,14 @@ func (n Node) MustGetBroadcaster() *broadcaster.Broadcaster {
}

func (n Node) GetStatus() nodetypes.Status {
pendingTxs := 0
sequence := uint64(0)
if n.broadcaster != nil {
pendingTxs = n.broadcaster.LenLocalPendingTx()
sequence = n.broadcaster.GetTxf().Sequence()
}
return nodetypes.Status{
s := nodetypes.Status{
LastProcessedBlockHeight: n.GetHeight(),
PendingTxs: pendingTxs,
Sequence: sequence,
}
if n.broadcaster != nil {
s.PendingTxs = n.broadcaster.LenLocalPendingTx()
s.Sequence = n.broadcaster.GetTxf().Sequence()
}
return s
}

func (n Node) GetRPCClient() *rpcclient.RPCClient {
Expand Down
3 changes: 2 additions & 1 deletion node/rpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
client2 "github.com/cometbft/cometbft/rpc/client"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
gogogrpc "github.com/cosmos/gogoproto/grpc"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
legacyerrors "github.com/cosmos/cosmos-sdk/types/errors"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
gogogrpc "github.com/cosmos/gogoproto/grpc"

clienthttp "github.com/initia-labs/opinit-bots-go/client"
)
Expand Down
4 changes: 2 additions & 2 deletions node/types/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package types

type Status struct {
LastProcessedBlockHeight uint64 `json:"last_processed_block_height"`
PendingTxs int `json:"pending_txs"`
Sequence uint64 `json:"sequence"`
PendingTxs int `json:"pending_txs,omitempty"`
Sequence uint64 `json:"sequence,omitempty"`
}

0 comments on commit 2b227fe

Please sign in to comment.