Documentation
¶
Overview ¶
Package contract is a generated GoMock package.
Index ¶
- Variables
- type Contract
- func (c *Contract) CheckBal(instance IGoldcoin, address string) (*big.Int, error)
- func (c *Contract) Deploy() (instance *goldcoin.Goldcoin, addrHash string, txHash string, err error)
- func (c *Contract) Load() *goldcoin.Goldcoin
- func (c *Contract) Reciept() (*types.Receipt, error)
- func (c *Contract) TransferTokens(instance IGoldcoin, recieverAddr string, amountStr string) (*types.Transaction, error)
- type IBlockchain
- type IGoldcoin
- type MockIBlockchain
- func (m *MockIBlockchain) CallContract(ctx context.Context, call go_ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (m *MockIBlockchain) ChainID(ctx context.Context) (*big.Int, error)
- func (m *MockIBlockchain) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (m *MockIBlockchain) EXPECT() *MockIBlockchainMockRecorder
- func (m *MockIBlockchain) EstimateGas(ctx context.Context, call go_ethereum.CallMsg) (uint64, error)
- func (m *MockIBlockchain) FilterLogs(ctx context.Context, query go_ethereum.FilterQuery) ([]types.Log, error)
- func (m *MockIBlockchain) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (m *MockIBlockchain) PendingCallContract(ctx context.Context, call go_ethereum.CallMsg) ([]byte, error)
- func (m *MockIBlockchain) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
- func (m *MockIBlockchain) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (m *MockIBlockchain) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (m *MockIBlockchain) SubscribeFilterLogs(ctx context.Context, query go_ethereum.FilterQuery, ch chan<- types.Log) (go_ethereum.Subscription, error)
- func (m *MockIBlockchain) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (go_ethereum.Subscription, error)
- func (m *MockIBlockchain) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (m *MockIBlockchain) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (m *MockIBlockchain) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
- func (m *MockIBlockchain) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type MockIBlockchainMockRecorder
- func (mr *MockIBlockchainMockRecorder) CallContract(ctx, call, blockNumber interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) ChainID(ctx interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) CodeAt(ctx, contract, blockNumber interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) EstimateGas(ctx, call interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) FilterLogs(ctx, query interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) HeaderByNumber(ctx, number interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) PendingCallContract(ctx, call interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) PendingCodeAt(ctx, contract interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) PendingNonceAt(ctx, account interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) SendTransaction(ctx, tx interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) SubscribeFilterLogs(ctx, query, ch interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) SubscribeNewHead(ctx, ch interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) SuggestGasPrice(ctx interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) SuggestGasTipCap(ctx interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) TransactionByHash(ctx, txHash interface{}) *gomock.Call
- func (mr *MockIBlockchainMockRecorder) TransactionReceipt(ctx, txHash interface{}) *gomock.Call
- type MockIGoldcoin
- type MockIGoldcoinMockRecorder
Constants ¶
This section is empty.
Variables ¶
var Deploy = goldcoin.DeployGoldcoin
A variable that is assigned to the function `goldcoin.DeployGoldcoin` : this is for testing purpose, for monkeypatching this variable needs to be public
Functions ¶
This section is empty.
Types ¶
type Contract ¶
type Contract struct {
Client IBlockchain
}
func NewContract ¶
func NewContract(c IBlockchain) *Contract
> The function `NewContract` takes an interface `IBlockchain` as an argument and returns a pointer to a `Contract` struct
func (*Contract) Deploy ¶
func (c *Contract) Deploy() (instance *goldcoin.Goldcoin, addrHash string, txHash string, err error)
Deploying the contract to the blockchain.
func (*Contract) TransferTokens ¶
func (c *Contract) TransferTokens(instance IGoldcoin, recieverAddr string, amountStr string) (*types.Transaction, error)
Transfer tokens from owner address to reciever address
type IBlockchain ¶
type IBlockchain interface { // ChainID retrieves the current chain ID for transaction replay protection. ChainID(ctx context.Context) (*big.Int, error) // CodeAt returns the code of the given account. This is needed to differentiate // between contract internal errors and the local chain being out of sync. CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) // ContractCall executes an Ethereum contract call with the specified data as the // input. CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) // PendingCodeAt returns the code of the given account in the pending state. PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) // PendingCallContract executes an Ethereum contract call against the pending state. PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) // PendingNonceAt retrieves the current pending nonce associated with an account. PendingNonceAt(ctx context.Context, account common.Address) (uint64, error) // SuggestGasPrice retrieves the currently suggested gas price to allow a timely // execution of a transaction. SuggestGasPrice(ctx context.Context) (*big.Int, error) // SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow // a timely execution of a transaction. SuggestGasTipCap(ctx context.Context) (*big.Int, error) // EstimateGas tries to estimate the gas needed to execute a specific // transaction based on the current pending state of the backend blockchain. // There is no guarantee that this is the true gas limit requirement as other // transactions may be added or removed by miners, but it should provide a basis // for setting a reasonable default. EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error) // SendTransaction injects the transaction into the pending pool for execution. SendTransaction(ctx context.Context, tx *types.Transaction) error // FilterLogs executes a log filter operation, blocking during execution and // returning all the results in one batch. // // TODO(karalabe): Deprecate when the subscription one can return past data too. FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) // SubscribeFilterLogs creates a background log filtering operation, returning // a subscription immediately, which can be used to stream the found events. SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) // SubscribeNewHead returns an event subscription for a new header. SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) // TransactionByHash checks the pool of pending transactions in addition to the // blockchain. The isPending return value indicates whether the transaction has been // mined yet. Note that the transaction may not be part of the canonical chain even if // it's not pending. TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) // BlockNumber returns the most recent block number //BlockNumber(ctx context.Context) (uint64, error) // HeaderByNumber returns a block header from the current canonical chain. If // number is nil, the latest known header is returned. HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) }
Below interface is directly refereced from https://github.com/bonedaddy/go-defi/blob/main/utils/blockchain.go IBlockchain is a generalized interface for interacting with the ethereum blockchain it satisfies all functions required by the ethclient, and simulated backend types. This allows you to use ethclient and the simulated backend interchangeably which is particularly useful for testing
type IGoldcoin ¶
type IGoldcoin interface { Transfer(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) // BalanceOf is a free data retrieval call binding the contract method 0x70a08231. // Solidity: function balanceOf(address account) view returns(uint256) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) }
Defining the interface for the goldcoin contract.
type MockIBlockchain ¶
type MockIBlockchain struct {
// contains filtered or unexported fields
}
MockIBlockchain is a mock of IBlockchain interface
func NewMockIBlockchain ¶
func NewMockIBlockchain(ctrl *gomock.Controller) *MockIBlockchain
NewMockIBlockchain creates a new mock instance
func (*MockIBlockchain) CallContract ¶
func (m *MockIBlockchain) CallContract(ctx context.Context, call go_ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract mocks base method
func (*MockIBlockchain) CodeAt ¶
func (m *MockIBlockchain) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt mocks base method
func (*MockIBlockchain) EXPECT ¶
func (m *MockIBlockchain) EXPECT() *MockIBlockchainMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockIBlockchain) EstimateGas ¶
func (m *MockIBlockchain) EstimateGas(ctx context.Context, call go_ethereum.CallMsg) (uint64, error)
EstimateGas mocks base method
func (*MockIBlockchain) FilterLogs ¶
func (m *MockIBlockchain) FilterLogs(ctx context.Context, query go_ethereum.FilterQuery) ([]types.Log, error)
FilterLogs mocks base method
func (*MockIBlockchain) HeaderByNumber ¶
func (m *MockIBlockchain) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByNumber mocks base method
func (*MockIBlockchain) PendingCallContract ¶
func (m *MockIBlockchain) PendingCallContract(ctx context.Context, call go_ethereum.CallMsg) ([]byte, error)
PendingCallContract mocks base method
func (*MockIBlockchain) PendingCodeAt ¶
func (m *MockIBlockchain) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
PendingCodeAt mocks base method
func (*MockIBlockchain) PendingNonceAt ¶
func (m *MockIBlockchain) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
PendingNonceAt mocks base method
func (*MockIBlockchain) SendTransaction ¶
func (m *MockIBlockchain) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction mocks base method
func (*MockIBlockchain) SubscribeFilterLogs ¶
func (m *MockIBlockchain) SubscribeFilterLogs(ctx context.Context, query go_ethereum.FilterQuery, ch chan<- types.Log) (go_ethereum.Subscription, error)
SubscribeFilterLogs mocks base method
func (*MockIBlockchain) SubscribeNewHead ¶
func (m *MockIBlockchain) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (go_ethereum.Subscription, error)
SubscribeNewHead mocks base method
func (*MockIBlockchain) SuggestGasPrice ¶
SuggestGasPrice mocks base method
func (*MockIBlockchain) SuggestGasTipCap ¶
SuggestGasTipCap mocks base method
func (*MockIBlockchain) TransactionByHash ¶
func (m *MockIBlockchain) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
TransactionByHash mocks base method
func (*MockIBlockchain) TransactionReceipt ¶
func (m *MockIBlockchain) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt mocks base method
type MockIBlockchainMockRecorder ¶
type MockIBlockchainMockRecorder struct {
// contains filtered or unexported fields
}
MockIBlockchainMockRecorder is the mock recorder for MockIBlockchain
func (*MockIBlockchainMockRecorder) CallContract ¶
func (mr *MockIBlockchainMockRecorder) CallContract(ctx, call, blockNumber interface{}) *gomock.Call
CallContract indicates an expected call of CallContract
func (*MockIBlockchainMockRecorder) ChainID ¶
func (mr *MockIBlockchainMockRecorder) ChainID(ctx interface{}) *gomock.Call
ChainID indicates an expected call of ChainID
func (*MockIBlockchainMockRecorder) CodeAt ¶
func (mr *MockIBlockchainMockRecorder) CodeAt(ctx, contract, blockNumber interface{}) *gomock.Call
CodeAt indicates an expected call of CodeAt
func (*MockIBlockchainMockRecorder) EstimateGas ¶
func (mr *MockIBlockchainMockRecorder) EstimateGas(ctx, call interface{}) *gomock.Call
EstimateGas indicates an expected call of EstimateGas
func (*MockIBlockchainMockRecorder) FilterLogs ¶
func (mr *MockIBlockchainMockRecorder) FilterLogs(ctx, query interface{}) *gomock.Call
FilterLogs indicates an expected call of FilterLogs
func (*MockIBlockchainMockRecorder) HeaderByNumber ¶
func (mr *MockIBlockchainMockRecorder) HeaderByNumber(ctx, number interface{}) *gomock.Call
HeaderByNumber indicates an expected call of HeaderByNumber
func (*MockIBlockchainMockRecorder) PendingCallContract ¶
func (mr *MockIBlockchainMockRecorder) PendingCallContract(ctx, call interface{}) *gomock.Call
PendingCallContract indicates an expected call of PendingCallContract
func (*MockIBlockchainMockRecorder) PendingCodeAt ¶
func (mr *MockIBlockchainMockRecorder) PendingCodeAt(ctx, contract interface{}) *gomock.Call
PendingCodeAt indicates an expected call of PendingCodeAt
func (*MockIBlockchainMockRecorder) PendingNonceAt ¶
func (mr *MockIBlockchainMockRecorder) PendingNonceAt(ctx, account interface{}) *gomock.Call
PendingNonceAt indicates an expected call of PendingNonceAt
func (*MockIBlockchainMockRecorder) SendTransaction ¶
func (mr *MockIBlockchainMockRecorder) SendTransaction(ctx, tx interface{}) *gomock.Call
SendTransaction indicates an expected call of SendTransaction
func (*MockIBlockchainMockRecorder) SubscribeFilterLogs ¶
func (mr *MockIBlockchainMockRecorder) SubscribeFilterLogs(ctx, query, ch interface{}) *gomock.Call
SubscribeFilterLogs indicates an expected call of SubscribeFilterLogs
func (*MockIBlockchainMockRecorder) SubscribeNewHead ¶
func (mr *MockIBlockchainMockRecorder) SubscribeNewHead(ctx, ch interface{}) *gomock.Call
SubscribeNewHead indicates an expected call of SubscribeNewHead
func (*MockIBlockchainMockRecorder) SuggestGasPrice ¶
func (mr *MockIBlockchainMockRecorder) SuggestGasPrice(ctx interface{}) *gomock.Call
SuggestGasPrice indicates an expected call of SuggestGasPrice
func (*MockIBlockchainMockRecorder) SuggestGasTipCap ¶
func (mr *MockIBlockchainMockRecorder) SuggestGasTipCap(ctx interface{}) *gomock.Call
SuggestGasTipCap indicates an expected call of SuggestGasTipCap
func (*MockIBlockchainMockRecorder) TransactionByHash ¶
func (mr *MockIBlockchainMockRecorder) TransactionByHash(ctx, txHash interface{}) *gomock.Call
TransactionByHash indicates an expected call of TransactionByHash
func (*MockIBlockchainMockRecorder) TransactionReceipt ¶
func (mr *MockIBlockchainMockRecorder) TransactionReceipt(ctx, txHash interface{}) *gomock.Call
TransactionReceipt indicates an expected call of TransactionReceipt
type MockIGoldcoin ¶
type MockIGoldcoin struct {
// contains filtered or unexported fields
}
MockIGoldcoin is a mock of IGoldcoin interface
func NewMockIGoldcoin ¶
func NewMockIGoldcoin(ctrl *gomock.Controller) *MockIGoldcoin
NewMockIGoldcoin creates a new mock instance
func (*MockIGoldcoin) EXPECT ¶
func (m *MockIGoldcoin) EXPECT() *MockIGoldcoinMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockIGoldcoin) Transfer ¶
func (m *MockIGoldcoin) Transfer(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error)
Transfer mocks base method
type MockIGoldcoinMockRecorder ¶
type MockIGoldcoinMockRecorder struct {
// contains filtered or unexported fields
}
MockIGoldcoinMockRecorder is the mock recorder for MockIGoldcoin
func (*MockIGoldcoinMockRecorder) BalanceOf ¶
func (mr *MockIGoldcoinMockRecorder) BalanceOf(opts, account interface{}) *gomock.Call
BalanceOf indicates an expected call of BalanceOf
func (*MockIGoldcoinMockRecorder) Transfer ¶
func (mr *MockIGoldcoinMockRecorder) Transfer(opts, to, amount interface{}) *gomock.Call
Transfer indicates an expected call of Transfer