1- package clientwrappers
1+ package dualbroadcast
22
33import (
44 "bytes"
@@ -17,28 +17,31 @@ import (
1717
1818 "github.com/smartcontractkit/chainlink-evm/pkg/client"
1919 "github.com/smartcontractkit/chainlink-evm/pkg/keys"
20+ "github.com/smartcontractkit/chainlink-evm/pkg/txm"
2021 "github.com/smartcontractkit/chainlink-evm/pkg/txm/types"
2122)
2223
23- type DualBroadcastClient struct {
24+ var _ txm.Client = & FlashbotsClient {}
25+
26+ type FlashbotsClient struct {
2427 c client.Client
2528 keystore keys.MessageSigner
2629 customURL * url.URL
2730}
2831
29- func NewDualBroadcastClient (c client.Client , keystore keys.MessageSigner , customURL * url.URL ) * DualBroadcastClient {
30- return & DualBroadcastClient {
32+ func NewFlashbotsClient (c client.Client , keystore keys.MessageSigner , customURL * url.URL ) * FlashbotsClient {
33+ return & FlashbotsClient {
3134 c : c ,
3235 keystore : keystore ,
3336 customURL : customURL ,
3437 }
3538}
3639
37- func (d * DualBroadcastClient ) NonceAt (ctx context.Context , address common.Address , blockNumber * big.Int ) (uint64 , error ) {
40+ func (d * FlashbotsClient ) NonceAt (ctx context.Context , address common.Address , blockNumber * big.Int ) (uint64 , error ) {
3841 return d .c .NonceAt (ctx , address , blockNumber )
3942}
4043
41- func (d * DualBroadcastClient ) PendingNonceAt (ctx context.Context , address common.Address ) (uint64 , error ) {
44+ func (d * FlashbotsClient ) PendingNonceAt (ctx context.Context , address common.Address ) (uint64 , error ) {
4245 body := []byte (fmt .Sprintf (`{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["%s","pending"], "id":1}` , address .String ()))
4346 response , err := d .signAndPostMessage (ctx , address , body , "" )
4447 if err != nil {
@@ -52,7 +55,7 @@ func (d *DualBroadcastClient) PendingNonceAt(ctx context.Context, address common
5255 return nonce , nil
5356}
5457
55- func (d * DualBroadcastClient ) SendTransaction (ctx context.Context , tx * types.Transaction , attempt * types.Attempt ) error {
58+ func (d * FlashbotsClient ) SendTransaction (ctx context.Context , tx * types.Transaction , attempt * types.Attempt ) error {
5659 meta , err := tx .GetMeta ()
5760 if err != nil {
5861 return err
@@ -75,7 +78,7 @@ func (d *DualBroadcastClient) SendTransaction(ctx context.Context, tx *types.Tra
7578 return d .c .SendTransaction (ctx , attempt .SignedTransaction )
7679}
7780
78- func (d * DualBroadcastClient ) signAndPostMessage (ctx context.Context , address common.Address , body []byte , urlParams string ) (result string , err error ) {
81+ func (d * FlashbotsClient ) signAndPostMessage (ctx context.Context , address common.Address , body []byte , urlParams string ) (result string , err error ) {
7982 bodyReader := bytes .NewReader (body )
8083 postReq , err := http .NewRequestWithContext (ctx , http .MethodPost , d .customURL .String ()+ "?" + urlParams , bodyReader )
8184 if err != nil {
0 commit comments