diff --git a/README.md b/README.md index f9cd8c1..5a8b1be 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,10 @@ ## Building -`docker build .` +- Place private key in `main/resources` +- Set `application.endpoint` (RPC) & `application.privateKey` (file name) in application.properties + +- `docker build .` ## Running `docker run CONTAINER_NAME` diff --git a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java index b2e47dc..e3c4ec6 100644 --- a/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java +++ b/src/main/java/markets/arcana/obcranker/ObCrankerApplication.java @@ -7,6 +7,7 @@ import org.p2p.solanaj.core.Account; import org.p2p.solanaj.core.PublicKey; import org.p2p.solanaj.rpc.RpcClient; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -23,6 +24,12 @@ @Slf4j public class ObCrankerApplication { + @Value("${application.endpoint}") + private String endpoint; + + @Value("${application.privateKey}") + private String privateKeyFileName; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2); public static void main(String[] args) { @@ -30,16 +37,15 @@ public static void main(String[] args) { } @EventListener(ApplicationReadyEvent.class) - public void crankEventHeapLoop() throws InterruptedException, IOException { - OpenBookManager manager = new OpenBookManager(new RpcClient("https://mainnet.helius-rpc" + - ".com/?api-key=a778b653-bdd6-41bc-8cda-0c7377faf1dd")); + public void crankEventHeapLoop() { + OpenBookManager manager = new OpenBookManager(new RpcClient(endpoint)); Account tradingAccount = null; try { tradingAccount = Account.fromJson( - Resources.toString(Resources.getResource("mikeDBaJgkicqhZcoYDBB4dRwZFFJCThtWCYD7A9FAH.json"), Charset.defaultCharset())); + Resources.toString(Resources.getResource(privateKeyFileName), Charset.defaultCharset())); } catch (IOException e) { - e.printStackTrace(); + log.error("Error reading private key: {}", e.getMessage()); } Account finalTradingAccount = tradingAccount; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8b13789..d5a41eb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,2 @@ - +application.endpoint=https://mainnet.helius-rpc.com/?api-key=a778b653-bdd6-41bc-8cda-0c7377faf1dd +application.privateKey=mikeDBaJgkicqhZcoYDBB4dRwZFFJCThtWCYD7A9FAH.json \ No newline at end of file