From 81a30063023923a46dc55252a6349a0f5d44b77c Mon Sep 17 00:00:00 2001 From: nagdahimanshu Date: Thu, 25 Jan 2024 11:53:00 +0100 Subject: [PATCH] :ok_hand: Applied suggestions --- pkg/chain/contracts.go | 3 ++- pkg/encoding/encoding.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/chain/contracts.go b/pkg/chain/contracts.go index 0a03902..51e70f9 100644 --- a/pkg/chain/contracts.go +++ b/pkg/chain/contracts.go @@ -8,6 +8,7 @@ import ( "github.com/LiskHQ/op-fault-detector/pkg/encoding" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum-optimism/optimism/op-bindings/bindings" @@ -84,7 +85,7 @@ func (oc *OracleAccessor) GetL2Output(index *big.Int) (L2Output, error) { } return L2Output{ - OutputRoot: "0x" + common.Bytes2Hex(l2Output.OutputRoot[:]), + OutputRoot: hexutil.Encode(l2Output.OutputRoot[:]), L1Timestamp: encoding.ConvertBigIntToUint64(l2Output.Timestamp), L2BlockNumber: encoding.ConvertBigIntToUint64(l2Output.L2BlockNumber), L2OutputIndex: encoding.ConvertBigIntToUint64(index), diff --git a/pkg/encoding/encoding.go b/pkg/encoding/encoding.go index c09b416..23b5b93 100644 --- a/pkg/encoding/encoding.go +++ b/pkg/encoding/encoding.go @@ -5,7 +5,10 @@ import "math/big" // ConvertBigIntToUint64 converts big integer to integer. func ConvertBigIntToUint64(value *big.Int) uint64 { - valueToString, _ := new(big.Int).SetString(value.String(), 10) + valueToString, ok := new(big.Int).SetString(value.String(), 10) + if !ok { + panic("error while converting big integer to integer") + } return valueToString.Uint64() }