Skip to content

Commit

Permalink
fix:add example run command guide
Browse files Browse the repository at this point in the history
Signed-off-by: grapebaba <[email protected]>
  • Loading branch information
GrapeBaBa committed Sep 6, 2023
1 parent aae79fc commit ba5a20b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ CompletableFuture<String> res = mevShareClient.sendPrivateTransaction(signRawTx,
## Examples
For more examples, you can see [example](https://github.com/optimism-java/mev-share-java/tree/main/example)

Examples can be run with the following commands:
```shell
./gradlew execute -PmainClassName=bundle.RpcSendPrivateTx

./gradlew execute -PmainClassName=event.SseHistorical
```

> Examples require a `.env` file (or that you populate your environment directly with the appropriate variables).
```sh
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = 'me.grapebaba'
version = '0.1.0'
version = '0.1.1'

repositories {
mavenCentral()
Expand Down
21 changes: 18 additions & 3 deletions src/test/java/net/flashbots/MevShareClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.reactivex.disposables.Disposable;
import net.flashbots.models.bundle.*;
import net.flashbots.models.bundle.BundleItemType;
import net.flashbots.models.bundle.BundleParams;
import net.flashbots.models.bundle.BundlePrivacy;
import net.flashbots.models.bundle.HintPreferences;
import net.flashbots.models.bundle.Inclusion;
import net.flashbots.models.bundle.PrivateTxOptions;
import net.flashbots.models.bundle.SendBundleResponse;
import net.flashbots.models.bundle.SimBundleOptions;
import net.flashbots.models.common.Network;
import net.flashbots.models.event.EventHistoryEntry;
import net.flashbots.models.event.EventHistoryInfo;
import net.flashbots.models.event.EventHistoryParams;
import net.flashbots.models.event.MevShareEvent;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -48,7 +56,6 @@
* @author kaichen
* @since 0.1.0
*/
@Disabled
class MevShareClientTest {

private static Credentials AUTH_SIGNER;
Expand All @@ -64,8 +71,13 @@ static void beforeAll()
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException {
AUTH_SIGNER = Credentials.create(Keys.createEcKeyPair());
SIGNER = Credentials.create(System.getenv("SIGNER_PRIVATE_KEY"));
MEV_SHARE_CLIENT = new MevShareClient(Network.GOERLI, AUTH_SIGNER, WEB3J);
WEB3J = Web3j.build(new HttpService(System.getenv("GOERLI_RPC_URL")));
MEV_SHARE_CLIENT = new MevShareClient(Network.GOERLI, AUTH_SIGNER, WEB3J);
}

@AfterAll
static void afterAll() {
MEV_SHARE_CLIENT.close();
}

/**
Expand Down Expand Up @@ -100,6 +112,7 @@ void getEventHistory() throws ExecutionException, InterruptedException {

@Test
@DisplayName("Subscribe event")
@Disabled
void subscribeEvent() throws InterruptedException, ExecutionException {
final CountDownLatch latch = new CountDownLatch(3);
var ref = new AtomicReference<MevShareEvent>();
Expand All @@ -116,6 +129,7 @@ void subscribeEvent() throws InterruptedException, ExecutionException {

@Test
@DisplayName("Send bundle with hash")
@Disabled
void sendBundle()
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException,
ExecutionException, InterruptedException, IOException {
Expand Down Expand Up @@ -315,6 +329,7 @@ void sendPrivateTransaction()

@Test
@DisplayName("Subscribe tx event")
@Disabled
void subscribeTx() throws ExecutionException, InterruptedException {
CompletableFuture<MevShareEvent> future = new CompletableFuture<>();
Disposable disposable = MEV_SHARE_CLIENT.subscribeTx(mevShareEvent -> {
Expand Down

0 comments on commit ba5a20b

Please sign in to comment.