github.com/CommerciumBlockchain/go-commercium@v0.0.0-20220709212705-b46438a77516/accounts/abi/bind/backend.go (about) 1 // Copyright 2022 Commercium 2 // Copyright 2015 The go-ethereum Authors 3 // This file is part of the go-ethereum library. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 18 package bind 19 20 import ( 21 "context" 22 "errors" 23 "math/big" 24 25 "github.com/CommerciumBlockchain/go-commercium" 26 "github.com/CommerciumBlockchain/go-commercium/common" 27 "github.com/CommerciumBlockchain/go-commercium/core/types" 28 ) 29 30 var ( 31 // ErrNoCode is returned by call and transact operations for which the requested 32 // recipient contract to operate on does not exist in the state db or does not 33 // have any code associated with it (i.e. suicided). 34 ErrNoCode = errors.New("no contract code at given address") 35 36 // This error is raised when attempting to perform a pending state action 37 // on a backend that doesn't implement PendingContractCaller. 38 ErrNoPendingState = errors.New("backend does not support pending state") 39 40 // This error is returned by WaitDeployed if contract creation leaves an 41 // empty contract behind. 42 ErrNoCodeAfterDeploy = errors.New("no contract code after deployment") 43 ) 44 45 // ContractCaller defines the methods needed to allow operating with a contract on a read 46 // only basis. 47 type ContractCaller interface { 48 // CodeAt returns the code of the given account. This is needed to differentiate 49 // between contract internal errors and the local chain being out of sync. 50 CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) 51 // ContractCall executes an Ethereum contract call with the specified data as the 52 // input. 53 CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) 54 } 55 56 // PendingContractCaller defines methods to perform contract calls on the pending state. 57 // Call will try to discover this interface when access to the pending state is requested. 58 // If the backend does not support the pending state, Call returns ErrNoPendingState. 59 type PendingContractCaller interface { 60 // PendingCodeAt returns the code of the given account in the pending state. 61 PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) 62 // PendingCallContract executes an Ethereum contract call against the pending state. 63 PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) 64 } 65 66 // ContractTransactor defines the methods needed to allow operating with a contract 67 // on a write only basis. Besides the transacting method, the remainder are helpers 68 // used when the user does not provide some needed values, but rather leaves it up 69 // to the transactor to decide. 70 type ContractTransactor interface { 71 // PendingCodeAt returns the code of the given account in the pending state. 72 PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error) 73 // PendingNonceAt retrieves the current pending nonce associated with an account. 74 PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) 75 SendTransaction(ctx context.Context, tx *types.Transaction) error 76 } 77 78 // ContractFilterer defines the methods needed to access log events using one-off 79 // queries or continuous event subscriptions. 80 type ContractFilterer interface { 81 // FilterLogs executes a log filter operation, blocking during execution and 82 // returning all the results in one batch. 83 // 84 // TODO(karalabe): Deprecate when the subscription one can return past data too. 85 FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) 86 87 // SubscribeFilterLogs creates a background log filtering operation, returning 88 // a subscription immediately, which can be used to stream the found events. 89 SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) 90 } 91 92 // DeployBackend wraps the operations needed by WaitMined and WaitDeployed. 93 type DeployBackend interface { 94 TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) 95 CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error) 96 } 97 98 // ContractBackend defines the methods needed to work with contracts on a read-write basis. 99 type ContractBackend interface { 100 ContractCaller 101 ContractTransactor 102 ContractFilterer 103 }