Skip to content

Commit

Permalink
fix: pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Mar 14, 2024
1 parent 68e2090 commit 2410bcf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bee-configs:
welcome-message: "Welcome to the Swarm, this is a local cluster!"
warmup-time: 0s
allow-private-cidrs: true
withdraw-address: 0xec44cb15b1b033e74d55ac5d0e24d861bde54532
withdrawal-addresses-whitelist: 0xec44cb15b1b033e74d55ac5d0e24d861bde54532

bootnode-local:
_inherit: "bee-local"
Expand Down
6 changes: 3 additions & 3 deletions pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ func (c *Client) WithdrawStake(ctx context.Context) (string, error) {
return c.debug.Stake.WithdrawStake(ctx)
}

// WithdrawStake withdraws stake
// WalletBalance fetches the balance for the given token
func (c *Client) WalletBalance(ctx context.Context, token string) (*big.Int, error) {
resp, err := c.debug.Node.Wallet(ctx)
if err != nil {
Expand All @@ -864,8 +864,8 @@ func (c *Client) WalletBalance(ctx context.Context, token string) (*big.Int, err
}

// Withdraw transfers token from eth address to the provided address
func (c *Client) Withdraw(ctx context.Context, token, addr string) error {
resp, err := c.debug.Node.Withdraw(ctx, token, addr)
func (c *Client) Withdraw(ctx context.Context, token, addr string, amount int64) error {
resp, err := c.debug.Node.Withdraw(ctx, token, addr, amount)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bee/debugapi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ func (n *NodeService) Wallet(ctx context.Context) (resp Wallet, err error) {
}

// Withdraw calls wallet withdraw endpoint
func (n *NodeService) Withdraw(ctx context.Context, token, addr string) (tx common.Hash, err error) {
endpoint := fmt.Sprintf("/wallet/withdraw/%s?address=%s&amount=1000000", token, addr)
func (n *NodeService) Withdraw(ctx context.Context, token, addr string, amount int64) (tx common.Hash, err error) {
endpoint := fmt.Sprintf("/wallet/withdraw/%s?address=%s&amount=%d", token, addr, amount)

r := struct {
TransactionHash common.Hash `json:"transactionHash"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/bee.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type BeeConfig struct {
Verbosity *uint64 `yaml:"verbosity"`
WelcomeMessage *string `yaml:"welcome-message"`
WarmupTime *time.Duration `yaml:"warmup-time"`
WithdrawAddress *string `yaml:"withdraw-address"`
WithdrawAddress *string `yaml:"withdrawal-addresses-whitelist"`
}

// Export exports BeeConfig to orchestration.Config
Expand Down
2 changes: 1 addition & 1 deletion pkg/orchestration/k8s/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tracing-service-name: {{.TracingServiceName}}
verbosity: {{.Verbosity}}
welcome-message: {{.WelcomeMessage}}
warmup-time: {{.WarmupTime}}
withdraw-address: {{.WithdrawAddress}}
withdrawal-addresses-whitelist: {{.WithdrawAddress}}
`
)

Expand Down
6 changes: 4 additions & 2 deletions pkg/test/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ type Wallet struct {
BZZ, Native *big.Int
}

const amount int64 = 1000000

func (b *BeeV2) Withdraw(ctx context.Context, token, addr string) error {
before, err := b.client.WalletBalance(ctx, token)
if err != nil {
return fmt.Errorf("(%s) wallet balance %w", b.name, err)
}

if err := b.client.Withdraw(ctx, token, addr); err != nil {
if err := b.client.Withdraw(ctx, token, addr, amount); err != nil {
return fmt.Errorf("(%s) withdraw balance %w", b.name, err)
}

Expand All @@ -120,7 +122,7 @@ func (b *BeeV2) Withdraw(ctx context.Context, token, addr string) error {
return fmt.Errorf("(%s) wallet balance %w", b.name, err)
}

want := big.NewInt(0).Sub(before, big.NewInt(1000000))
want := big.NewInt(0).Sub(before, big.NewInt(amount))

if after.Cmp(want) > 0 {
return fmt.Errorf("incorrect balance after withdraw:\ngot %d\nwant %d", after, want)
Expand Down

0 comments on commit 2410bcf

Please sign in to comment.