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

swap: pass the context to waitForTx directly #2053

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion contracts/swap/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (sf simpleSwapFactory) DeploySimpleSwap(auth *bind.TransactOpts, issuer com
return nil, err
}

receipt, err := WaitFunc(auth, sf.backend, tx)
receipt, err := WaitFunc(auth.Context, sf.backend, tx)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/swap/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s simpleContract) Withdraw(auth *bind.TransactOpts, amount *big.Int) (*typ
if err != nil {
return nil, err
}
return WaitFunc(auth, s.backend, tx)
return WaitFunc(auth.Context, s.backend, tx)
}

// Deposit sends an amount in ERC20 token to the chequebook and blocks until the transaction is mined
Expand Down Expand Up @@ -136,7 +136,7 @@ func (s simpleContract) Deposit(auth *bind.TransactOpts, amount *big.Int) (*type
if err != nil {
return nil, err
}
return WaitFunc(auth, s.backend, tx)
return WaitFunc(auth.Context, s.backend, tx)
}

// CashChequeBeneficiary cashes the cheque on the blockchain and blocks until the transaction is mined.
Expand All @@ -145,7 +145,7 @@ func (s simpleContract) CashChequeBeneficiary(opts *bind.TransactOpts, beneficia
if err != nil {
return nil, nil, err
}
receipt, err := WaitFunc(opts, s.backend, tx)
receipt, err := WaitFunc(opts.Context, s.backend, tx)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -225,9 +225,9 @@ func (s simpleContract) PaidOut(opts *bind.CallOpts, addr common.Address) (*big.
var WaitFunc = waitForTx

// waitForTx waits for transaction to be mined and returns the receipt
func waitForTx(auth *bind.TransactOpts, backend Backend, tx *types.Transaction) (*types.Receipt, error) {
func waitForTx(ctx context.Context, backend Backend, tx *types.Transaction) (*types.Receipt, error) {
// it blocks here until tx is mined
receipt, err := bind.WaitMined(auth.Context, backend, tx)
receipt, err := bind.WaitMined(ctx, backend, tx)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions swap/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ func TestContractIntegration(t *testing.T) {
}

// when testing, we don't need to wait for a transaction to be mined
func testWaitForTx(auth *bind.TransactOpts, backend cswap.Backend, tx *types.Transaction) (*types.Receipt, error) {
func testWaitForTx(ctx context.Context, backend cswap.Backend, tx *types.Transaction) (*types.Receipt, error) {

var stb *swapTestBackend
var ok bool
Expand All @@ -1254,7 +1254,7 @@ func testWaitForTx(auth *bind.TransactOpts, backend cswap.Backend, tx *types.Tra
}
stb.Commit()

receipt, err := backend.TransactionReceipt(context.TODO(), tx.Hash())
receipt, err := backend.TransactionReceipt(ctx, tx.Hash())
if err != nil {
return nil, err
}
Expand Down