diff --git a/utils/block.go b/utils/block.go index 20c34f6e2..d675e7475 100644 --- a/utils/block.go +++ b/utils/block.go @@ -102,26 +102,6 @@ func (*UtilsStruct) GetMinStakeAmount(client *ethclient.Client) (*big.Int, error return minStake, nil } -func (*UtilsStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { - var ( - minStake *big.Int - err error - ) - err = retry.Do( - func() error { - minStake, err = BlockManagerInterface.MinStake(client) - if err != nil { - log.Error("Error in fetching minimum stake amount.... Retrying") - return err - } - return nil - }, RetryInterface.RetryAttempts(core.MaxRetries)) - if err != nil { - return nil, err - } - return minStake, nil -} - func (*UtilsStruct) GetMaxAltBlocks(client *ethclient.Client) (uint8, error) { var ( maxAltBlocks uint8 diff --git a/utils/interface.go b/utils/interface.go index 039951312..eac87ca77 100644 --- a/utils/interface.go +++ b/utils/interface.go @@ -250,7 +250,7 @@ type StakeManagerUtils interface { GetStakerId(client *ethclient.Client, address common.Address) (uint32, error) GetStaker(*ethclient.Client, uint32) (bindings.StructsStaker, error) GetNumStakers(*ethclient.Client) (uint32, error) - GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) + MinSafeRazor(client *ethclient.Client) (*big.Int, error) Locks(client *ethclient.Client, address common.Address, address1 common.Address, lockType uint8) (types.Locks, error) MaxCommission(*ethclient.Client) (uint8, error) EpochLimitForUpdateCommission(*ethclient.Client) (uint16, error) diff --git a/utils/mocks/stake_manager_utils.go b/utils/mocks/stake_manager_utils.go index ba889b7da..3a407221b 100644 --- a/utils/mocks/stake_manager_utils.go +++ b/utils/mocks/stake_manager_utils.go @@ -41,29 +41,6 @@ func (_m *StakeManagerUtils) EpochLimitForUpdateCommission(_a0 *ethclient.Client return r0, r1 } -// GetMinSafeRazor provides a mock function with given fields: client -func (_m *StakeManagerUtils) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { - ret := _m.Called(client) - - var r0 *big.Int - if rf, ok := ret.Get(0).(func(*ethclient.Client) *big.Int); ok { - r0 = rf(client) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*big.Int) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { - r1 = rf(client) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // GetNumStakers provides a mock function with given fields: _a0 func (_m *StakeManagerUtils) GetNumStakers(_a0 *ethclient.Client) (uint32, error) { ret := _m.Called(_a0) @@ -169,6 +146,29 @@ func (_m *StakeManagerUtils) MaxCommission(_a0 *ethclient.Client) (uint8, error) return r0, r1 } +// MinSafeRazor provides a mock function with given fields: client +func (_m *StakeManagerUtils) MinSafeRazor(client *ethclient.Client) (*big.Int, error) { + ret := _m.Called(client) + + var r0 *big.Int + if rf, ok := ret.Get(0).(func(*ethclient.Client) *big.Int); ok { + r0 = rf(client) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { + r1 = rf(client) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // WithdrawInitiationPeriod provides a mock function with given fields: client func (_m *StakeManagerUtils) WithdrawInitiationPeriod(client *ethclient.Client) (uint8, error) { ret := _m.Called(client) diff --git a/utils/stake.go b/utils/stake.go index a1d70d022..ccfc95133 100644 --- a/utils/stake.go +++ b/utils/stake.go @@ -190,3 +190,23 @@ func (*UtilsStruct) GetStakerSRZRBalance(client *ethclient.Client, staker bindin } return sRZRBalance, nil } + +func (*UtilsStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { + var ( + minSafeRazor *big.Int + err error + ) + err = retry.Do( + func() error { + minSafeRazor, err = StakeManagerInterface.MinSafeRazor(client) + if err != nil { + log.Error("Error in fetching minimum safe razor.... Retrying") + return err + } + return nil + }, RetryInterface.RetryAttempts(core.MaxRetries)) + if err != nil { + return nil, err + } + return minSafeRazor, nil +} diff --git a/utils/struct-utils.go b/utils/struct-utils.go index 9e7dbd22f..2a2d3ab4e 100644 --- a/utils/struct-utils.go +++ b/utils/struct-utils.go @@ -151,7 +151,7 @@ func (s StakeManagerStruct) GetNumStakers(client *ethclient.Client) (uint32, err return stakeManager.GetNumStakers(&opts) } -func (s StakeManagerStruct) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { +func (s StakeManagerStruct) MinSafeRazor(client *ethclient.Client) (*big.Int, error) { stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client) return stakeManager.MinSafeRazor(&opts) }