Commit 5e654403 authored by Ralph Pichler's avatar Ralph Pichler Committed by GitHub

fix goerli factory address (#749)

parent 5b44ec7f
...@@ -161,7 +161,7 @@ func (c *factory) ERC20Address(ctx context.Context) (common.Address, error) { ...@@ -161,7 +161,7 @@ func (c *factory) ERC20Address(ctx context.Context) (common.Address, error) {
func DiscoverFactoryAddress(chainID int64) (common.Address, bool) { func DiscoverFactoryAddress(chainID int64) (common.Address, bool) {
if chainID == 5 { if chainID == 5 {
// goerli // goerli
return common.HexToAddress("0x334394E8c891E77b1449084aaDD659920BB25247"), true return common.HexToAddress("0xA6B88705036F2a56807af157c116b7dfCDabf968"), true
} }
return common.Address{}, false return common.Address{}, false
} }
...@@ -6,8 +6,10 @@ package chequebook ...@@ -6,8 +6,10 @@ package chequebook
import ( import (
"context" "context"
"errors"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/pkg/logging" "github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/storage" "github.com/ethersphere/bee/pkg/storage"
...@@ -45,6 +47,25 @@ func Init( ...@@ -45,6 +47,25 @@ func Init(
if err != storage.ErrNotFound { if err != storage.ErrNotFound {
return nil, err return nil, err
} }
if swapInitialDeposit != 0 {
erc20Token, err := erc20BindingFunc(erc20Address, swapBackend)
if err != nil {
return nil, err
}
balance, err := erc20Token.BalanceOf(&bind.CallOpts{
Context: ctx,
}, overlayEthAddress)
if err != nil {
return nil, err
}
if balance.Cmp(big.NewInt(int64(swapInitialDeposit))) < 0 {
return nil, errors.New("insufficient token for initial deposit")
}
}
// if we don't yet have a chequebook, deploy a new one // if we don't yet have a chequebook, deploy a new one
logger.Info("deploying new chequebook") logger.Info("deploying new chequebook")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment