From 82d4f3102b0f4db53b1f6a0426d4337b58ea296d Mon Sep 17 00:00:00 2001 From: Mateusz Sekara Date: Tue, 22 Oct 2024 15:43:38 +0200 Subject: [PATCH] CI scripts linter fixes --- .../applications/ethsenderreceiver/main.go | 1 + core/scripts/ccip/ccip-revert-reason/main.go | 8 ++++---- core/scripts/ccip/debugreceiver/main.go | 6 +++--- .../liquiditymanager/multienv/multienv.go | 19 ++++++++++--------- .../ccip/liquiditymanager/opstack/finalize.go | 2 ++ .../opstack/prove_withdrawal.go | 1 + .../ccip/revert-reason/handler/reason.go | 6 +++--- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/core/scripts/ccip/applications/ethsenderreceiver/main.go b/core/scripts/ccip/applications/ethsenderreceiver/main.go index f6acad3e6b..93ba70d358 100644 --- a/core/scripts/ccip/applications/ethsenderreceiver/main.go +++ b/core/scripts/ccip/applications/ethsenderreceiver/main.go @@ -28,6 +28,7 @@ var ( senderABI = abihelpers.MustParseABI(ether_sender_receiver.EtherSenderReceiverABI) ) +// nolint func main() { switch os.Args[1] { case "inject-eth-liquidity": diff --git a/core/scripts/ccip/ccip-revert-reason/main.go b/core/scripts/ccip/ccip-revert-reason/main.go index d8504a0480..e357086306 100644 --- a/core/scripts/ccip/ccip-revert-reason/main.go +++ b/core/scripts/ccip/ccip-revert-reason/main.go @@ -13,7 +13,7 @@ import ( var ( errorCodeString = flag.String("errorCode", "", "Error code string (e.g. 0x08c379a0)") - chainId = flag.Uint64("chainId", 0, "Chain ID for the transaction (e.g. 420)") + chainID = flag.Uint64("chainId", 0, "Chain ID for the transaction (e.g. 420)") txHash = flag.String("txHash", "", "Transaction hash (e.g. 0x97be8559164442595aba46b5f849c23257905b78e72ee43d9b998b28eee78b84)") txRequester = flag.String("txRequester", "", "Transaction requester address (e.g. 0xe88ff73814fb891bb0e149f5578796fa41f20242)") rpcURL = flag.String("rpcURL", "", "RPC URL for the chain (can also be set in env var RPC_)") @@ -28,7 +28,7 @@ func main() { flag.Parse() - if *errorCodeString == "" && (*chainId == 0 || *txHash == "" || *txRequester == "") { + if *errorCodeString == "" && (*chainID == 0 || *txHash == "" || *txRequester == "") { flag.Usage() return } @@ -53,8 +53,8 @@ func getErrorString() (string, error) { } if *rpcURL == "" { - fmt.Printf("RPC URL not provided, looking for RPC_%d env var\n", *chainId) - envRPC := secrets.GetRPC(*chainId) + fmt.Printf("RPC URL not provided, looking for RPC_%d env var\n", *chainID) + envRPC := secrets.GetRPC(*chainID) rpcURL = &envRPC } diff --git a/core/scripts/ccip/debugreceiver/main.go b/core/scripts/ccip/debugreceiver/main.go index 5ea6084515..db742ed126 100644 --- a/core/scripts/ccip/debugreceiver/main.go +++ b/core/scripts/ccip/debugreceiver/main.go @@ -15,7 +15,7 @@ import ( ) type ccipAny struct { - SourceChainId *big.Int + SourceChainID *big.Int Sender []byte Data []byte Tokens []common.Address @@ -87,7 +87,7 @@ func main() { log[0].Data) panicErr(err) send := encodedMsg[0].(struct { - SourceChainId *big.Int `json:"sourceChainId"` + SourceChainID *big.Int `json:"sourceChainId"` SequenceNumber uint64 `json:"sequenceNumber"` Sender common.Address `json:"sender"` Receiver common.Address `json:"receiver"` @@ -106,7 +106,7 @@ func main() { {"internalType":"address[]","name":"tokens","type":"address[]"}, {"internalType":"uint256[]","name":"amounts","type":"uint256[]"}], "internalType":"structCCIP.Any2EVMMessage","name":"message","type":"tuple"}]`, - ccipAny{send.SourceChainId, sender, send.Data, send.Tokens, send.Amounts}) + ccipAny{send.SourceChainID, sender, send.Data, send.Tokens, send.Amounts}) panicErr(err) a, err := dest.CallContract(context.Background(), ethereum.CallMsg{ From: common.HexToAddress("0x2b7ab40413da5077e168546ea376920591aee8e7"), // offramp router diff --git a/core/scripts/ccip/liquiditymanager/multienv/multienv.go b/core/scripts/ccip/liquiditymanager/multienv/multienv.go index a198177505..4fc320316d 100644 --- a/core/scripts/ccip/liquiditymanager/multienv/multienv.go +++ b/core/scripts/ccip/liquiditymanager/multienv/multienv.go @@ -19,12 +19,12 @@ import ( // Environment variables used to configure // the environment for the rebalancer const ( - // OWNER_KEY is the private key used to deploy contracts and send funds to the rebalancer nodes - OWNER_KEY = "OWNER_KEY" - // RPC_ is the prefix for the environment variable that contains the RPC URL for a chain - RPC_ = "RPC_" - // WS_ is the prefix for the environment variable that contains the WebSocket URL for a chain - WS_ = "WS_" + // OwnerKey is the private key used to deploy contracts and send funds to the rebalancer nodes + OwnerKey = "OWNER_KEY" + // RPCPrefix is the prefix for the environment variable that contains the RPC URL for a chain + RPCPrefix = "RPC_" + // WebSocketPerfix is the prefix for the environment variable that contains the WebSocket URL for a chain + WebSocketPerfix = "WS_" ) type Env struct { @@ -35,6 +35,7 @@ type Env struct { WSURLs map[uint64]string } +// nolint func New(websocket bool, overrideNonce bool) Env { env := Env{ Transactors: make(map[uint64]*bind.TransactOpts), @@ -65,7 +66,7 @@ func New(websocket bool, overrideNonce bool) Env { } func GetRPC(chainID uint64) (string, error) { - envVariable := RPC_ + strconv.FormatUint(chainID, 10) + envVariable := RPCPrefix + strconv.FormatUint(chainID, 10) rpc := os.Getenv(envVariable) if rpc != "" { return rpc, nil @@ -74,7 +75,7 @@ func GetRPC(chainID uint64) (string, error) { } func GetWS(chainID uint64) (string, error) { - envVariable := WS_ + strconv.FormatUint(chainID, 10) + envVariable := WebSocketPerfix + strconv.FormatUint(chainID, 10) ws := os.Getenv(envVariable) if ws != "" { return ws, nil @@ -83,7 +84,7 @@ func GetWS(chainID uint64) (string, error) { } func GetTransactor(chainID *big.Int) *bind.TransactOpts { - ownerKey := os.Getenv(OWNER_KEY) + ownerKey := os.Getenv(OwnerKey) if ownerKey != "" { b, err := hex.DecodeString(ownerKey) if err != nil { diff --git a/core/scripts/ccip/liquiditymanager/opstack/finalize.go b/core/scripts/ccip/liquiditymanager/opstack/finalize.go index 4422b2656e..4966796940 100644 --- a/core/scripts/ccip/liquiditymanager/opstack/finalize.go +++ b/core/scripts/ccip/liquiditymanager/opstack/finalize.go @@ -22,6 +22,7 @@ const ( FinalizationActionFinalizeWithdrawal uint8 = 1 ) +// nolint func FinalizeL1( env multienv.Env, l1ChainID, @@ -55,6 +56,7 @@ func FinalizeL1( helpers.ConfirmTXMined(context.Background(), env.Clients[l1ChainID], tx, int64(l1ChainID), "FinalizeWithdrawalTransaction") } +// nolint func FinalizeWithdrawalViaRebalancer( env multienv.Env, l1ChainID, diff --git a/core/scripts/ccip/liquiditymanager/opstack/prove_withdrawal.go b/core/scripts/ccip/liquiditymanager/opstack/prove_withdrawal.go index 3eed3cba70..1718b33984 100644 --- a/core/scripts/ccip/liquiditymanager/opstack/prove_withdrawal.go +++ b/core/scripts/ccip/liquiditymanager/opstack/prove_withdrawal.go @@ -25,6 +25,7 @@ var ( encoderABI = abihelpers.MustParseABI(optimism_l1_bridge_adapter_encoder.OptimismL1BridgeAdapterEncoderMetaData.ABI) ) +// nolint func ProveWithdrawal( env multienv.Env, l1ChainID, diff --git a/core/scripts/ccip/revert-reason/handler/reason.go b/core/scripts/ccip/revert-reason/handler/reason.go index 7256b85856..d705774b76 100644 --- a/core/scripts/ccip/revert-reason/handler/reason.go +++ b/core/scripts/ccip/revert-reason/handler/reason.go @@ -44,13 +44,13 @@ func (h *BaseHandler) RevertReasonFromErrorCodeString(errorCodeString string) (s func (h *BaseHandler) RevertReasonFromTx(txHash string) (string, error) { // Need a node URL // NOTE: this node needs to run in archive mode - ethUrl := h.cfg.NodeURL - if ethUrl == "" { + ethURL := h.cfg.NodeURL + if ethURL == "" { panicErr(errors.New("you must define ETH_NODE env variable")) } requester := h.cfg.FromAddress - ec, err := ethclient.Dial(ethUrl) + ec, err := ethclient.Dial(ethURL) panicErr(err) errorString, _ := GetErrorForTx(ec, txHash, requester)