Skip to content

Commit

Permalink
fix: rename staked amount to withdrawable stake (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinconic authored Aug 29, 2024
1 parent 7fe190f commit fc9212f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/bee/api/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type StakingService service

type getStakeResponse struct {
StakedAmount *bigint.BigInt `json:"stakedAmount"`
WithdrawableStake *bigint.BigInt `json:"withdrawableStake"`
}
type stakeDepositResponse struct {
TxHash string `json:"txhash"`
Expand All @@ -32,14 +32,14 @@ func (s *StakingService) DepositStake(ctx context.Context, amount *big.Int) (txH
return r.TxHash, nil
}

// GetStakedAmount gets stake
func (s *StakingService) GetStakedAmount(ctx context.Context) (stakedAmount *big.Int, err error) {
// GetWithdrawableStake gets stake
func (s *StakingService) GetWithdrawableStake(ctx context.Context) (withdrawableStake *big.Int, err error) {
r := new(getStakeResponse)
err = s.client.requestJSON(ctx, http.MethodGet, "/stake", nil, r)
if err != nil {
return nil, err
}
return r.StakedAmount.Int, nil
return r.WithdrawableStake.Int, nil
}

// MigrateStake withdraws stake
Expand Down
2 changes: 1 addition & 1 deletion pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func (c *Client) DepositStake(ctx context.Context, amount *big.Int) (string, err

// GetStake returns stake amount
func (c *Client) GetStake(ctx context.Context) (*big.Int, error) {
return c.api.Stake.GetStakedAmount(ctx)
return c.api.Stake.GetWithdrawableStake(ctx)
}

// MigrateStake withdraws stake
Expand Down
6 changes: 3 additions & 3 deletions pkg/check/stake/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
}

// should allow increasing the stake amount
stakedAmount := new(big.Int).Add(o.Amount, big.NewInt(1))
withdrawableStake := new(big.Int).Add(o.Amount, big.NewInt(1))

_, err = client.DepositStake(ctx, big.NewInt(1))
if err != nil {
return fmt.Errorf("increase stake amount: %w", err)
}

if err := expectStakeAmountIs(ctx, client, stakedAmount); err != nil {
if err := expectStakeAmountIs(ctx, client, withdrawableStake); err != nil {
return err
}

Expand All @@ -127,7 +127,7 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
return errors.New("withdraw from running contract should fail")
}

if err := expectStakeAmountIs(ctx, client, stakedAmount); err != nil {
if err := expectStakeAmountIs(ctx, client, withdrawableStake); err != nil {
return err
}

Expand Down

0 comments on commit fc9212f

Please sign in to comment.