aboutsummaryrefslogtreecommitdiff
path: root/accounts/abi/bind/util.go
diff options
context:
space:
mode:
authorTed Yin <[email protected]>2020-09-18 13:14:29 -0400
committerGitHub <[email protected]>2020-09-18 13:14:29 -0400
commitd048937c48753d9eaef771bf71820cf95d79df26 (patch)
tree1a7f65fcd72e77092525ab01625b8b9d365e3e40 /accounts/abi/bind/util.go
parent7d1388c743b4ec8f4a86bea95bfada785dee83f7 (diff)
parent7d8c85cf8895b0f998d8eafb02f99d5b689fcd59 (diff)
Merge pull request #34 from ava-labs/devv0.3.0-rc.5
Dev
Diffstat (limited to 'accounts/abi/bind/util.go')
-rw-r--r--accounts/abi/bind/util.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/accounts/abi/bind/util.go b/accounts/abi/bind/util.go
deleted file mode 100644
index b3ec22c..0000000
--- a/accounts/abi/bind/util.go
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package bind
-
-import (
- "context"
- "fmt"
- "time"
-
- "github.com/ava-labs/coreth/core/types"
- "github.com/ava-labs/go-ethereum/common"
- "github.com/ava-labs/go-ethereum/log"
-)
-
-// WaitMined waits for tx to be mined on the blockchain.
-// It stops waiting when the context is canceled.
-func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*types.Receipt, error) {
- queryTicker := time.NewTicker(time.Second)
- defer queryTicker.Stop()
-
- logger := log.New("hash", tx.Hash())
- for {
- receipt, err := b.TransactionReceipt(ctx, tx.Hash())
- if receipt != nil {
- return receipt, nil
- }
- if err != nil {
- logger.Trace("Receipt retrieval failed", "err", err)
- } else {
- logger.Trace("Transaction not yet mined")
- }
- // Wait for the next round.
- select {
- case <-ctx.Done():
- return nil, ctx.Err()
- case <-queryTicker.C:
- }
- }
-}
-
-// WaitDeployed waits for a contract deployment transaction and returns the on-chain
-// contract address when it is mined. It stops waiting when ctx is canceled.
-func WaitDeployed(ctx context.Context, b DeployBackend, tx *types.Transaction) (common.Address, error) {
- if tx.To() != nil {
- return common.Address{}, fmt.Errorf("tx is not contract creation")
- }
- receipt, err := WaitMined(ctx, b, tx)
- if err != nil {
- return common.Address{}, err
- }
- if receipt.ContractAddress == (common.Address{}) {
- return common.Address{}, fmt.Errorf("zero address")
- }
- // Check that code has indeed been deployed at the address.
- // This matters on pre-Homestead chains: OOG in the constructor
- // could leave an empty account behind.
- code, err := b.CodeAt(ctx, receipt.ContractAddress, nil)
- if err == nil && len(code) == 0 {
- err = ErrNoCodeAfterDeploy
- }
- return receipt.ContractAddress, err
-}