Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind.ContractTransactor/ethclient.SendTransactionConditional use a internal struct #2722

Closed
RelicOfTesla opened this issue Sep 25, 2024 · 3 comments
Assignees

Comments

@RelicOfTesla
Copy link

RelicOfTesla commented Sep 25, 2024

SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error

"github.com/ethereum/go-ethereum/internal/ethapi"

func (ec *Client) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error {

"github.com/ethereum/go-ethereum/internal/ethapi"

Can not call SendTransactionConditional , or derive ethclient class.

I need to make some modifications to this interface, such as log or frequency limiting and other, I will derive new classes, and then pass in erc20.NewErc20(..., WrapEthClient{}) // var _ bind.ContractBackend = WrapEthClient{}

@RelicOfTesla RelicOfTesla changed the title ethclient.SendTransactionConditional use a internal struct bind.ContractTransactor/ethclient.SendTransactionConditional use a internal struct Sep 25, 2024
@0xbundler
Copy link

Sorry, I cannot understand your issue, you can attach your compile error here.

It's suggested to wrap Go struct as a field and add more functions on it.

type WrapEthClient struct {
    inner *ethclient.Client
}
func (ec *WrapEthClient) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error {
	// do some costume logics
	return ec.inner.SendTransactionConditional(ctx, tx, opts)
}

Another suggestion is to fork the BSC repo, and costume by yourself.

@RelicOfTesla
Copy link
Author

RelicOfTesla commented Oct 9, 2024

import "github.com/ethereum/go-ethereum/internal/ethapi" // ethclient2\wrap.go:8:2: use of internal package github.com/ethereum/go-ethereum/internal/ethapi not allowed
import "github.com/ethereum/go-ethereum/accounts/abi/bind"
var _ bind.ContractBackend = &WrapEthClient{}

type WrapEthClient struct {
   *ethclient.Client
}
func (ec *WrapEthClient) SendTransactionConditional(ctx context.Context, tx *types.Transaction, opts ethapi.TransactionOpts) error {
	// do some costume logics
	return ec.Client.SendTransactionConditional(ctx, tx, opts)
}

Golang does not allow import "internal" packages in external project

@0xbundler
Copy link

Got it, may @galaio could fix it quickly, If you are in a hurry you can manually call eth_sendRawTransactionConditional using JSON-RPC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants