New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: enable withdraw all stake endpoint #3662
Conversation
return | ||
} | ||
logger.Debug("delete stake failed", "error", err) | ||
logger.Error(nil, "withdraw stake failed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message should be the same as the debug message.
|
||
func (c *contract) withdrawFromStake(ctx context.Context, stakedAmount *big.Int) (*types.Receipt, error) { | ||
var overlayAddr [32]byte | ||
copy(overlayAddr[:], c.overlay.Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the abi packing needs a [32]byte and not a byte slice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, it needs byte slice, just checked
|
||
func (c *contract) withdrawFromStake(ctx context.Context, stakedAmount *big.Int) (*types.Receipt, error) { | ||
var overlayAddr [32]byte | ||
copy(overlayAddr[:], c.overlay.Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the abi packing needs a [32]byte and not a byte slice
@@ -1056,6 +1056,23 @@ paths: | |||
$ref: "SwarmCommon.yaml#/components/responses/500" | |||
default: | |||
description: Default response | |||
delete: | |||
summary: Withdraw all staked amount. | |||
description: Be aware, this endpoint creates an on-chain transactions and transfers BZZ from the node's Ethereum account and hence directly manipulates the wallet balance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: we can either drop the an
or use transaction
(singular)
|
||
txHash, err := s.stakingContract.WithdrawAllStake(r.Context()) | ||
if err != nil { | ||
if errors.Is(err, staking.ErrInsufficientStake) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering: if we withdraw the entire amount of the stake, can we gen the insufficient stake
error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, this edge case deals with the fact that we did not have any stake to begin with
Checklist
Description
Adds an endpoint to delete all existing stake.
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):
This change is