Skip to content

Commit

Permalink
feat: add getfrom
Browse files Browse the repository at this point in the history
  • Loading branch information
datluongductuan committed Apr 8, 2024
1 parent a6432b0 commit c24d773
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/mev/blxr_bundle_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"net/http"
"strconv"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/flashbots/mev-share-node/mevshare"
)

Expand All @@ -32,6 +34,10 @@ type BloxrouteClient struct {
enabledBuilders []BlxrBuilder
}

func (s *BloxrouteClient) EstimateBundleGas(ctx context.Context, messages []ethereum.CallMsg, overrides *map[common.Address]gethclient.OverrideAccount) ([]uint64, error) {

Check failure on line 37 in pkg/mev/blxr_bundle_sender.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

line is 171 characters (lll)
return nil, nil
}

func (s *BloxrouteClient) MevSimulateBundle(
_ uint64,
_ common.Hash,
Expand Down
3 changes: 2 additions & 1 deletion pkg/mev/bundle_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (s *Client) flashbotBackrunSendBundle(
}

func (s *Client) EstimateBundleGas(
_ context.Context,
messages []ethereum.CallMsg,
overrides *map[common.Address]gethclient.OverrideAccount,
) ([]uint64, error) {
Expand All @@ -146,7 +147,7 @@ func (s *Client) EstimateBundleGas(
var gasEstimateCost []hexutil.Uint64

err := s.ethClient.Client().Call(
&gasEstimateCost, "eth_estimateGasBundle",
&gasEstimateCost, ETHEstimateGasBundleMethod,
map[string]interface{}{
"transactions": bundles,
}, "latest", overrides,
Expand Down
12 changes: 12 additions & 0 deletions pkg/mev/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient/gethclient"
"github.com/flashbots/mev-share-node/mevshare"
)

Expand All @@ -35,6 +36,7 @@ const (
ETHSendBundleMethod = "eth_sendBundle"
EthCallBundleMethod = "eth_callBundle"
ETHCancelBundleMethod = "eth_cancelBundle"
ETHEstimateGasBundleMethod = "eth_estimateGasBundle"
MevSendBundleMethod = "mev_sendBundle"
MaxBlockFromTarget = 3
)
Expand All @@ -57,6 +59,11 @@ type IBundleSender interface {
ctx context.Context, bundleUUID string,
) error
SimulateBundle(ctx context.Context, blockNumber uint64, txs ...*types.Transaction) (SendBundleResponse, error)
EstimateBundleGas(
ctx context.Context,
messages []ethereum.CallMsg,
overrides *map[common.Address]gethclient.OverrideAccount,
) ([]uint64, error)
MevSimulateBundle(
blockNumber uint64,
pendingTxHash common.Hash,
Expand Down Expand Up @@ -196,3 +203,8 @@ func ToCallArg(msg ethereum.CallMsg) interface{} {
}
return arg
}

func GetFrom(tx *types.Transaction) (common.Address, error) {
from, err := types.Sender(types.LatestSignerForChainID(tx.ChainId()), tx)
return from, err
}

0 comments on commit c24d773

Please sign in to comment.