Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Error handling improved in etherman/etherman.go (#40)
Browse files Browse the repository at this point in the history
* error handling improved in etherman/etherman.go

* '%s' changed to '%w' for wrapped errors in etherman.go
  • Loading branch information
nivida authored Jan 12, 2024
1 parent 6356805 commit bb5db6b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions etherman/etherman.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package etherman
import (
"context"
"errors"
"fmt"
"github.com/0xPolygon/beethoven/config"
"math/big"
"time"
Expand Down Expand Up @@ -92,12 +93,12 @@ func (e *Etherman) CallContract(ctx context.Context, call ethereum.CallMsg, bloc
func (e *Etherman) getRollupContractAddress(rollupId uint32) (common.Address, error) {
contract, err := polygonrollupmanager.NewPolygonrollupmanager(e.config.L1.RollupManagerContract, e.ethClient)
if err != nil {
return common.Address{}, err
return common.Address{}, fmt.Errorf("error instantiating 'PolygonRollupManager' contract: %w", err)
}

rollupData, err := contract.RollupIDToRollupData(&bind.CallOpts{Pending: false}, rollupId)
if err != nil {
return common.Address{}, err
return common.Address{}, fmt.Errorf("error receiving the 'RollupData' struct: %w", err)
}

return rollupData.RollupContract, nil
Expand All @@ -106,12 +107,12 @@ func (e *Etherman) getRollupContractAddress(rollupId uint32) (common.Address, er
func (e *Etherman) getTrustedSequencerAddress(rollupId uint32) (common.Address, error) {
rollupContractAddress, err := e.getRollupContractAddress(rollupId)
if err != nil {
return common.Address{}, err
return common.Address{}, fmt.Errorf("error requesting the 'PolygonZkEvm' contract address from 'PolygonRollupManager': %w", err)
}

contract, err := polygonzkevm.NewPolygonzkevm(rollupContractAddress, e.ethClient)
if err != nil {
return common.Address{}, err
return common.Address{}, fmt.Errorf("error instantiating 'PolygonZkEvm' contract: %w", err)
}

return contract.TrustedSequencer(&bind.CallOpts{Pending: false})
Expand Down

0 comments on commit bb5db6b

Please sign in to comment.