Skip to content

Commit 2b73fbf

Browse files
committed
Use mevshare library for types
1 parent a70ba14 commit 2b73fbf

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

public/samples/DataFeeds/SVR/broadcaster.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
1-
type MevBundle struct {
2-
Hash common.Hash
3-
Tx []byte
4-
CanRevert bool
5-
}
6-
7-
type Inclusion struct {
8-
Block *big.Int
9-
MaxBlock *big.Int
10-
}
11-
12-
type BundleParams struct {
13-
Body []MevBundle
14-
inclusion Inclusion
15-
}
1+
import "github.com/flashbots/mev-share-node/mevshare"
162

173
// ... create and sign your transaction
184
tx := types.NewTransaction(...)
195
signedTx, err := types.SignTx(tx, ...)
206
txBytes := signedTx.MarshalBinary()
217

22-
bundle := []MevBundle {
8+
bundle := []mevshare.MevBundleBody {
239
{
24-
Hash: event.EventHash,
10+
Hash: &event.EventHash,
2511
},
2612
{
2713
Tx: &txBytes,
2814
CanRevert: false,
2915
},
3016
}
3117

32-
params := BundleParams {
18+
params := mevshare.SendMevBundleArgs {
3319
Body: bundle,
34-
Inclusion: Inclusion{blockNumber, blockNumber+1},
20+
Inclusion: mevshare.MevBundleInclusion{blockNumber, blockNumber+1},
3521
}
3622

3723
byteParams, err := json.Marshal(params)

public/samples/DataFeeds/SVR/decoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
decoded, err := hex.DecodeString(strings.TrimPrefix(strings.ToLower(tx.CallData), "0x"))
1+
decoded, err := hex.DecodeString(strings.TrimPrefix(strings.ToLower(tx.CallData.String()), "0x"))
22
contractAddress := "0x" + strings.ToLower(strings.TrimLeft(hex.EncodeToString(decoded[4:36]), "0"))
33

44
ff := strings.ToLower(strings.TrimLeft(hex.EncodeToString(decoded[100:104]), "0"))

public/samples/DataFeeds/SVR/listener.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
type MevShareEvent struct {
2-
Hash common.Hash `json:"hash"`
3-
Txs []PendingTransaction `json:"txs"`
4-
}
5-
6-
type PendingTransaction struct {
7-
To common.Address `json:"to"`
8-
FunctionSelector string `json:"functionSelector"`
9-
CallData string `json:"callData"`
10-
}
1+
import "github.com/flashbots/mev-share-node/mevshare"
112

123
req, err := http.NewRequestWithContext(
134
ctx,
@@ -18,12 +9,12 @@ req, err := http.NewRequestWithContext(
189

1910
// ... read the event data from the response
2011

21-
var event MevShareEvent
12+
var event mevshare.Hint
2213
err := json.Unmarshal(responseData, &event)
2314

2415
// ... check if tx is calling the forward method
2516
if strings.Compare(
26-
strings.ToLower(tx.FunctionSelector),
17+
strings.ToLower(tx.FunctionSelector.String()),
2718
"0x6fadcf72",
2819
) != 0 {
2920
continue

0 commit comments

Comments
 (0)