Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

swap, contracts, vendor: move to ERC20 #1964

Merged
merged 25 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
69df570
swap, contracts, vendor: move to ERC20
ralph-pichler Nov 19, 2019
9c9a098
swap, contracts/swap: seperate deposit from deploy, remove deployLoop…
Eknir Nov 20, 2019
f596ccf
swap, contracts/swap: attempt to use a new factory with updated bindings
Eknir Nov 22, 2019
d854d25
Merge branch 'master' into swap-erc20
Eknir Nov 22, 2019
f35d25a
swap: update go bindings
ralph-pichler Nov 22, 2019
e66bb7b
swap, contracts/swap: update prompter
Eknir Nov 22, 2019
edece0f
swap, contracts/swap: initialDeposit => deposit
Eknir Nov 22, 2019
4b07c3b
contracts/swap balanceOf exported
Eknir Nov 22, 2019
470b638
contracts/swap: replace common.HexToAddress(TODO)
Eknir Nov 22, 2019
0c130f5
contracts/swap: replace Wei with ERC20-token
Eknir Nov 22, 2019
e57aae3
swap, contracts/swap: rename BalanceOf to BalanceAtTokenContract
Eknir Nov 22, 2019
318ed6f
swap: remove debug print, replace context.TODO() with context.Backgro…
Eknir Nov 22, 2019
a2269d9
cmd/swarm, swap: change initialDeposit to deposit
Eknir Nov 25, 2019
9222fcf
api/config, cmd/swarm, swap: rename flag swap-deposit to swap-deposit…
Eknir Nov 25, 2019
64fee90
swap, contracts/swap: more elaborate comments remove big.NewInt(0)
Eknir Nov 27, 2019
00995da
swap: add t to newTestBackend
Eknir Nov 27, 2019
a60c2a5
rename noDepsit to skipDeposit
Eknir Nov 27, 2019
5f037d0
contracts/swap: update default factory address for Ropsten
Eknir Nov 27, 2019
f83b73b
Merge branch 'master' into swap-erc20
Eknir Nov 27, 2019
62059de
swap: documentation to promptDepositAmount, log for skipping deposit,…
Eknir Nov 27, 2019
d78f18b
swap: capitilization and comment ErrSkipDeposit
Eknir Nov 28, 2019
152674d
swap: indentation
Eknir Nov 28, 2019
24855a1
swap: small improvements
Eknir Dec 2, 2019
2609d99
Merge branch 'master' into swap-erc20
Eknir Dec 3, 2019
2acd3b2
swap: last review Marcello
Eknir Dec 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ type Config struct {
SwapEnabled bool // whether SWAP incentives are enabled
SwapPaymentThreshold uint64 // honey amount at which a payment is triggered
SwapDisconnectThreshold uint64 // honey amount at which a peer disconnects
SwapInitialDeposit uint64 // initial deposit amount to the chequebook
SwapSkipDeposit bool // do not ask the user to deposit during boot sequence
SwapDepositAmount uint64 // deposit amount to the chequebook
SwapLogPath string // dir to swap related audit logs
Contract common.Address // address of the chequebook contract
SwapChequebookFactory common.Address // address of the chequebook factory contract
Expand Down Expand Up @@ -92,7 +93,8 @@ func NewConfig() *Config {
FileStoreParams: storage.NewFileStoreParams(),
SwapBackendURL: "",
SwapEnabled: false,
SwapInitialDeposit: swap.DefaultInitialDepositAmount,
SwapSkipDeposit: false,
SwapDepositAmount: swap.DefaultDepositAmount,
SwapPaymentThreshold: swap.DefaultPaymentThreshold,
SwapDisconnectThreshold: swap.DefaultDisconnectThreshold,
SwapLogPath: "",
Expand Down
11 changes: 8 additions & 3 deletions cmd/swarm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const (
SwarmEnvNetworkID = "SWARM_NETWORK_ID"
SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR"
SwarmEnvChequebookFactoryAddr = "SWARM_SWAP_CHEQUEBOOK_FACTORY_ADDR"
SwarmEnvInitialDeposit = "SWARM_INITIAL_DEPOSIT"
SwarmEnvSwapSkipDeposit = "SWARM_SWAP_SKIP_DEPOSIT"
SwarmEnvSwapDepositAmount = "SWARM_SWAP_DEPOSIT_AMOUNT"
SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE"
SwarmEnvSwapBackendURL = "SWARM_SWAP_BACKEND_URL"
SwarmEnvSwapPaymentThreshold = "SWARM_SWAP_PAYMENT_THRESHOLD"
Expand Down Expand Up @@ -210,8 +211,12 @@ func flagsOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Confi
if swapLogPath := ctx.GlobalString(SwarmSwapLogPathFlag.Name); currentConfig.SwapEnabled && swapLogPath != "" {
currentConfig.SwapLogPath = swapLogPath
}
if initialDepo := ctx.GlobalUint64(SwarmSwapInitialDepositFlag.Name); initialDepo != 0 {
currentConfig.SwapInitialDeposit = initialDepo

if skipDeposit := ctx.GlobalBool(SwarmSwapSkipDepositFlag.Name); skipDeposit {
currentConfig.SwapSkipDeposit = true
}
if deposit := ctx.GlobalUint64(SwarmSwapDepositAmountFlag.Name); deposit != 0 {
currentConfig.SwapDepositAmount = deposit
}
if paymentThreshold := ctx.GlobalUint64(SwarmSwapPaymentThresholdFlag.Name); paymentThreshold != 0 {
currentConfig.SwapPaymentThreshold = paymentThreshold
Expand Down
13 changes: 9 additions & 4 deletions cmd/swarm/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ var (
Value: network.DefaultNetworkID,
EnvVar: SwarmEnvNetworkID,
}
SwarmSwapInitialDepositFlag = cli.StringFlag{
Name: "swap-initial-deposit",
Usage: "Initial deposit amount for swap chequebook",
EnvVar: SwarmEnvInitialDeposit,
SwarmSwapDepositAmountFlag = cli.StringFlag{
Name: "swap-deposit-amount",
Usage: "Deposit amount for swap chequebook",
EnvVar: SwarmEnvSwapDepositAmount,
}
SwarmSwapSkipDepositFlag = cli.BoolFlag{
Name: "swap-skip-deposit",
Usage: "Don't deposit during boot sequence",
EnvVar: SwarmEnvSwapSkipDeposit,
}
SwarmSwapChequebookAddrFlag = cli.StringFlag{
Name: "swap-chequebook",
Expand Down
3 changes: 2 additions & 1 deletion cmd/swarm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func init() {
SwarmSwapLogPathFlag,
SwarmSwapChequebookAddrFlag,
SwarmSwapChequebookFactoryFlag,
SwarmSwapInitialDepositFlag,
SwarmSwapSkipDepositFlag,
SwarmSwapDepositAmountFlag,
// end of swap flags
SwarmNoSyncFlag,
SwarmLightNodeEnabled,
Expand Down
11 changes: 5 additions & 6 deletions contracts/swap/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
chequebookFactory "github.com/ethersphere/go-sw3/contracts-v0-1-1/simpleswapfactory"
chequebookFactory "github.com/ethersphere/go-sw3/contracts-v0-2-0/simpleswapfactory"
)

var (
Expand All @@ -19,7 +19,7 @@ var (
// Deployments maps from network ids to deployed contract factories
Deployments = map[uint64]common.Address{
// Ropsten
3: common.HexToAddress("0x2e9C43E186eaF4fee10799d67e75f8CFc5BA3a0c"),
ralph-pichler marked this conversation as resolved.
Show resolved Hide resolved
3: common.HexToAddress("0x878Ccb2e3c2973767e431bAec86D1EFd809480d5"),
}
)

Expand Down Expand Up @@ -64,21 +64,20 @@ func (sf simpleSwapFactory) VerifySelf() error {
if err != nil {
return err
}

referenceCode := common.FromHex(chequebookFactory.SimpleSwapFactoryDeployedCode)
if !bytes.Equal(code, referenceCode) {
return errors.New("not a valid factory contract")
}

return nil
}

// DeploySimpleSwap deploys a new SimpleSwap contract from the factory and returns the ready to use Contract abstraction
func (sf simpleSwapFactory) DeploySimpleSwap(auth *bind.TransactOpts, issuer common.Address, defaultHardDepositTimeoutDuration *big.Int) (Contract, error) {
// for some reason the automatic gas estimation is too low
// this value was determind by deploying through truffle and rounding up to the next 100000
// this value was determined by experimentation and is higher than what works in truffle
// this might be due to the simulated backend running on a different evm version
// the deployment cost should always be constant
auth.GasLimit = 1700000
auth.GasLimit = 2000000
tx, err := sf.instance.DeploySimpleSwap(auth, issuer, defaultHardDepositTimeoutDuration)
if err != nil {
return nil, err
Expand Down
92 changes: 62 additions & 30 deletions contracts/swap/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (
"errors"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
contract "github.com/ethersphere/go-sw3/contracts-v0-1-1/simpleswap"
contract "github.com/ethersphere/go-sw3/contracts-v0-2-0/erc20simpleswap"
)

var (
Expand All @@ -45,14 +44,18 @@ type Backend interface {

// Contract interface defines the methods exported from the underlying go-bindings for the smart contract
type Contract interface {
// Withdraw attempts to withdraw Wei from the chequebook
Withdraw(auth *bind.TransactOpts, backend Backend, amount *big.Int) (*types.Receipt, error)
ralph-pichler marked this conversation as resolved.
Show resolved Hide resolved
// Withdraw attempts to withdraw ERC20-token from the chequebook
Withdraw(auth *bind.TransactOpts, amount *big.Int) (*types.Receipt, error)
mortelli marked this conversation as resolved.
Show resolved Hide resolved
// Deposit sends a raw transaction to the chequebook, triggering the fallback—depositing amount
Deposit(auth *bind.TransactOpts, backend Backend, amout *big.Int) (*types.Receipt, error)
Deposit(auth *bind.TransactOpts, amout *big.Int) (*types.Receipt, error)
// CashChequeBeneficiary cashes the cheque by the beneficiary
CashChequeBeneficiary(auth *bind.TransactOpts, beneficiary common.Address, cumulativePayout *big.Int, ownerSig []byte) (*CashChequeResult, *types.Receipt, error)
// LiquidBalance returns the LiquidBalance (total balance in Wei - total hard deposits in Wei) of the chequebook
// LiquidBalance returns the LiquidBalance (total balance in ERC20-token - total hard deposits in ERC20-token) of the chequebook
LiquidBalance(auth *bind.CallOpts) (*big.Int, error)
//Token returns the address of the ERC20 contract, used by the chequebook
Token(auth *bind.CallOpts) (common.Address, error)
//BalanceAtTokenContract returns the balance of the account for the underlying ERC20 contract of the chequebook
BalanceAtTokenContract(opts *bind.CallOpts, account common.Address) (*big.Int, error)
// ContractParams returns contract info (e.g. deployed address)
ContractParams() *Params
// Issuer returns the contract owner from the blockchain
Expand Down Expand Up @@ -80,23 +83,16 @@ type Params struct {
}

type simpleContract struct {
instance *contract.SimpleSwap
instance *contract.ERC20SimpleSwap
address common.Address
backend Backend
}

// Deploy deploys an instance of the underlying contract and returns its instance and the transaction identifier
func Deploy(auth *bind.TransactOpts, backend Backend, owner common.Address, harddepositTimeout time.Duration) (Contract, *types.Transaction, error) {
addr, tx, instance, err := contract.DeploySimpleSwap(auth, backend, owner, big.NewInt(int64(harddepositTimeout)))
c := simpleContract{instance: instance, address: addr, backend: backend}
return c, tx, err
}

// InstanceAt creates a new instance of a contract at a specific address.
// It assumes that there is an existing contract instance at the given address, or an error is returned
// This function is needed to communicate with remote Swap contracts (e.g. sending a cheque)
func InstanceAt(address common.Address, backend Backend) (Contract, error) {
instance, err := contract.NewSimpleSwap(address, backend)
instance, err := contract.NewERC20SimpleSwap(address, backend)
if err != nil {
return nil, err
}
Expand All @@ -105,29 +101,42 @@ func InstanceAt(address common.Address, backend Backend) (Contract, error) {
}

// Withdraw withdraws amount from the chequebook and blocks until the transaction is mined
func (s simpleContract) Withdraw(auth *bind.TransactOpts, backend Backend, amount *big.Int) (*types.Receipt, error) {
func (s simpleContract) Withdraw(auth *bind.TransactOpts, amount *big.Int) (*types.Receipt, error) {
tx, err := s.instance.Withdraw(auth, amount)
if err != nil {
return nil, err
}
return WaitFunc(auth, backend, tx)
return WaitFunc(auth, s.backend, tx)
}

// Deposit sends a transaction to the chequebook, which deposits the amount set in Auth.Value and blocks until the transaction is mined
func (s simpleContract) Deposit(auth *bind.TransactOpts, backend Backend, amount *big.Int) (*types.Receipt, error) {
rawSimpleSwap := contract.SimpleSwapRaw{Contract: s.instance}
if auth.Value != big.NewInt(0) {
return nil, fmt.Errorf("Deposit value can only be set via amount parameter")
}
if amount == big.NewInt(0) {
// Deposit sends an amount in ERC20 token to the chequebook and blocks until the transaction is mined
func (s simpleContract) Deposit(auth *bind.TransactOpts, amount *big.Int) (*types.Receipt, error) {
if amount.Cmp(&big.Int{}) == 0 {
return nil, fmt.Errorf("Deposit amount cannot be equal to zero")
}
auth.Value = amount
tx, err := rawSimpleSwap.Transfer(auth)
// get ERC20Instance at the address of token which is registered in the chequebook
tokenAddress, err := s.Token(nil)
if err != nil {
return nil, err
}
token, err := contract.NewERC20(tokenAddress, s.backend)
if err != nil {
return nil, err
}
// check if we have sufficient balance
balance, err := s.BalanceAtTokenContract(nil, auth.From)
mortelli marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
if balance.Cmp(amount) == -1 {
Eknir marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("Not enough ERC20 balance at %x for account %x", tokenAddress, auth.From)
}
// transfer ERC20 to the chequebook
tx, err := token.Transfer(auth, s.address, amount)
if err != nil {
return nil, err
}
return WaitFunc(auth, backend, tx)
return WaitFunc(auth, s.backend, tx)
}

// CashChequeBeneficiary cashes the cheque on the blockchain and blocks until the transaction is mined.
Expand Down Expand Up @@ -164,16 +173,39 @@ func (s simpleContract) CashChequeBeneficiary(opts *bind.TransactOpts, beneficia
return result, receipt, nil
}

// LiquidBalance returns the LiquidBalance (total balance in Wei - total hard deposits in Wei) of the chequebook
// LiquidBalance returns the LiquidBalance (total balance in ERC20-token - total hard deposits in ERC20-token) of the chequebook
func (s simpleContract) LiquidBalance(opts *bind.CallOpts) (*big.Int, error) {
return s.instance.LiquidBalance(opts)
}

//Token returns the address of the ERC20 contract, used by the chequebook
func (s simpleContract) Token(opts *bind.CallOpts) (common.Address, error) {
mortelli marked this conversation as resolved.
Show resolved Hide resolved
return s.instance.Token(opts)
}

//BalanceAtTokenContract returns the balance of the account for the underlying ERC20 contract of the chequebook
func (s simpleContract) BalanceAtTokenContract(opts *bind.CallOpts, account common.Address) (*big.Int, error) {
mortelli marked this conversation as resolved.
Show resolved Hide resolved
// get ERC20Instance at the address of token which is registered in the chequebook
tokenAddress, err := s.Token(opts)
if err != nil {
return nil, err
}
token, err := contract.NewERC20(tokenAddress, s.backend)
if err != nil {
return nil, err
}
balance, err := token.BalanceOf(opts, account)
if err != nil {
return nil, err
}
return balance, nil
}

// ContractParams returns contract information
func (s simpleContract) ContractParams() *Params {
return &Params{
ContractCode: contract.SimpleSwapBin,
ContractAbi: contract.SimpleSwapABI,
ContractCode: contract.ERC20SimpleSwapBin,
ContractAbi: contract.ERC20SimpleSwapABI,
ContractAddress: s.address,
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/ethereum/go-ethereum v1.9.2
github.com/ethersphere/go-sw3 v0.1.1
github.com/ethersphere/go-sw3 v0.2.1
github.com/fatih/color v1.7.0 // indirect
github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc
github.com/go-kit/kit v0.9.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ github.com/elastic/gosigar v0.0.0-20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/ethereum/go-ethereum v1.9.2 h1:RMIHDO/diqXEgORSVzYx8xW9x2+S32PoAX5lQwya0Lw=
github.com/ethereum/go-ethereum v1.9.2/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY=
github.com/ethersphere/go-sw3 v0.1.1 h1:czLnLSU0/XJLJt/GyPiEAds9YYnIgZZzfy+OQyiYQtk=
github.com/ethersphere/go-sw3 v0.1.1/go.mod h1:HukT0aZ6QdW/d7zuD/0g5xlw6ewu9QeqHojxLDsaERQ=
github.com/ethersphere/go-sw3 v0.2.1 h1:+i660uWzhRbT1YO7MAeuxzn+jUeYOTc8rGRVjsKaw+4=
github.com/ethersphere/go-sw3 v0.2.1/go.mod h1:HukT0aZ6QdW/d7zuD/0g5xlw6ewu9QeqHojxLDsaERQ=
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down
7 changes: 2 additions & 5 deletions swap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ const (
// DefaultPaymentThreshold is set to be equivalent to requesting and serving 10mb of data (2441 chunks (4096 bytes) = 10 mb, 10^7 bytes = 10 mb)
DefaultPaymentThreshold = 2441*RetrieveRequestPrice + (10^7)*ChunkDeliveryPrice // 4096 * 2441 = 10 mb,
DefaultDisconnectThreshold = 20 * DefaultPaymentThreshold
// DefaultInitialDepositAmount is the default amount to send to the contract when initially deploying
// DefaultDepositAmount is the default amount to send to the contract when initially deploying
mortelli marked this conversation as resolved.
Show resolved Hide resolved
// NOTE: deliberate value for now; needs experimentation
DefaultInitialDepositAmount = 0
deployRetries = 5
// delay between retries
deployDelay = 1 * time.Second
DefaultDepositAmount = 0
mortelli marked this conversation as resolved.
Show resolved Hide resolved
// This is the amount of time in seconds which an issuer has to wait to decrease the harddeposit of a beneficiary.
// The smart-contract allows for setting this variable differently per beneficiary
defaultHarddepositTimeoutDuration = 24 * time.Hour
Expand Down
1 change: 1 addition & 0 deletions swap/prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ but it could potentially be any currency the oracle and Swarm support,
allowing for a multi-currency design.
*/

//TODO: this calculations make little sense now, after update to ERC20-enabled chequebook
// Placeholder prices
// Based on a very crude calculation: average monthly cost for bandwidth in the US / average monthly usage of bandwidth in the US
// $67 / 190GB = $0.35 / GB
Expand Down
4 changes: 2 additions & 2 deletions swap/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func TestHandshakeInvalidContract(t *testing.T) {
// A second swap instance is created for easy creation of a chequebook contract which is deployed to the simulated backend
// We send a EmitChequeMsg to the creditor which handles the cheque and sends a ConfirmChequeMsg
func TestEmitCheque(t *testing.T) {
testBackend := newTestBackend()
testBackend := newTestBackend(t)
protocolTester, clean, err := newSwapTester(t, testBackend)
defer clean()
if err != nil {
Expand Down Expand Up @@ -326,7 +326,7 @@ func TestEmitCheque(t *testing.T) {
// One protocol tester is created and then Add with a value above the payment threshold is called for another node
// we expect a EmitChequeMsg to be sent, then we send a ConfirmChequeMsg to the swap instance
func TestTriggerPaymentThreshold(t *testing.T) {
testBackend := newTestBackend()
testBackend := newTestBackend(t)
log.Debug("create test swap")
protocolTester, clean, err := newSwapTester(t, testBackend)
defer clean()
Expand Down
18 changes: 16 additions & 2 deletions swap/simulations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/ethereum/go-ethereum/p2p/simulations"
"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
"github.com/ethereum/go-ethereum/rpc"
contractFactory "github.com/ethersphere/go-sw3/contracts-v0-1-1/simpleswapfactory"
contractFactory "github.com/ethersphere/go-sw3/contracts-v0-2-0/simpleswapfactory"
cswap "github.com/ethersphere/swarm/contracts/swap"
"github.com/ethersphere/swarm/network/simulation"
"github.com/ethersphere/swarm/p2p/protocols"
Expand Down Expand Up @@ -215,7 +215,21 @@ func newSharedBackendSwaps(t *testing.T, nodeCount int) (*swapSimulationParams,
defaultBackend := backends.NewSimulatedBackend(alloc, gasLimit)
defaultBackend.Commit()

factoryAddress, _, _, err := contractFactory.DeploySimpleSwapFactory(bind.NewKeyedTransactor(keys[0]), defaultBackend)
tokenAddress, _, token, err := contractFactory.DeployERC20Mintable(bind.NewKeyedTransactor(keys[0]), defaultBackend)
if err != nil {
return nil, err
}
defaultBackend.Commit()

for i := 0; i < nodeCount; i++ {
mortelli marked this conversation as resolved.
Show resolved Hide resolved
_, err = token.Mint(bind.NewKeyedTransactor(keys[0]), addrs[i], big.NewInt(10000*int64(RetrieveRequestPrice)))
if err != nil {
return nil, err
}
defaultBackend.Commit()
}

factoryAddress, _, _, err := contractFactory.DeploySimpleSwapFactory(bind.NewKeyedTransactor(keys[0]), defaultBackend, tokenAddress)
if err != nil {
t.Fatalf("Error while deploying factory: %v", err)
}
Expand Down
Loading