mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-07 07:28:40 +00:00
fix
This commit is contained in:
parent
fa8590a5c8
commit
0729d2a99e
4 changed files with 17 additions and 4 deletions
|
|
@ -4,8 +4,10 @@
|
||||||
package {{.Package}}
|
package {{.Package}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
ethereum "github.com/ethereum/go-ethereum"
|
ethereum "github.com/ethereum/go-ethereum"
|
||||||
|
|
@ -27,6 +29,8 @@ var (
|
||||||
_ = types.BloomLookup
|
_ = types.BloomLookup
|
||||||
_ = event.NewSubscription
|
_ = event.NewSubscription
|
||||||
_ = abi.ConvertType
|
_ = abi.ConvertType
|
||||||
|
_ = time.Tick
|
||||||
|
_ = context.Background
|
||||||
)
|
)
|
||||||
|
|
||||||
{{$structs := .Structs}}
|
{{$structs := .Structs}}
|
||||||
|
|
@ -78,8 +82,9 @@ var (
|
||||||
}
|
}
|
||||||
{{range $pattern, $name := .Libraries}}
|
{{range $pattern, $name := .Libraries}}
|
||||||
{{decapitalise $name}}Addr, tx, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
{{decapitalise $name}}Addr, tx, _, _ := Deploy{{capitalise $name}}(auth, backend)
|
||||||
if err := bind.WaitAccepted(context.Background(), backend, tx.Hash()); err != nil {
|
ctx, _ := context.WithTimeout(context.Background(), 5 * time.Second)
|
||||||
return common.Address{}, nil, nil err
|
if err := bind.WaitAccepted(ctx, backend, tx); err != nil {
|
||||||
|
return common.Address{}, nil, nil, err
|
||||||
}
|
}
|
||||||
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
|
{{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:])
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,12 @@ func (m *MetaData) GetAbi() (*abi.ABI, error) {
|
||||||
|
|
||||||
// util.go
|
// util.go
|
||||||
|
|
||||||
|
// WaitAccepted waits for a tx to be accepted into the pool.
|
||||||
|
// It stops waiting when the context is canceled.
|
||||||
|
func WaitAccepted(ctx context.Context, b ContractBackend, tx *types.Transaction) error {
|
||||||
|
return bind2.WaitAccepted(ctx, b, tx.Hash())
|
||||||
|
}
|
||||||
|
|
||||||
// WaitMined waits for tx to be mined on the blockchain.
|
// WaitMined waits for tx to be mined on the blockchain.
|
||||||
// It stops waiting when the context is canceled.
|
// It stops waiting when the context is canceled.
|
||||||
func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*types.Receipt, error) {
|
func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*types.Receipt, error) {
|
||||||
|
|
|
||||||
|
|
@ -103,13 +103,15 @@ type ContractTransactor interface {
|
||||||
|
|
||||||
// PendingNonceAt retrieves the current pending nonce associated with an account.
|
// PendingNonceAt retrieves the current pending nonce associated with an account.
|
||||||
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
|
||||||
|
|
||||||
|
// TransactionByHash retrieves the transaction associated with the hash, if it exists in the pool.
|
||||||
|
TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
|
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
|
||||||
type DeployBackend interface {
|
type DeployBackend interface {
|
||||||
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
|
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
|
||||||
CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
|
CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
|
||||||
TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractFilterer defines the methods needed to access log events using one-off
|
// ContractFilterer defines the methods needed to access log events using one-off
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func WaitDeployed(ctx context.Context, b DeployBackend, hash common.Hash) (commo
|
||||||
return receipt.ContractAddress, err
|
return receipt.ContractAddress, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitAccepted(ctx context.Context, d DeployBackend, txHash common.Hash) error {
|
func WaitAccepted(ctx context.Context, d ContractBackend, txHash common.Hash) error {
|
||||||
queryTicker := time.NewTicker(time.Second)
|
queryTicker := time.NewTicker(time.Second)
|
||||||
defer queryTicker.Stop()
|
defer queryTicker.Stop()
|
||||||
logger := log.New("hash", txHash)
|
logger := log.New("hash", txHash)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue