Skip to content

Commit

Permalink
Fix send to explorer, and config parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Apr 26, 2021
1 parent 121f3d9 commit f664459
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
16 changes: 8 additions & 8 deletions project/Deps.scala
Expand Up @@ -10,28 +10,28 @@ object Deps {
}

object V {
val akkav = "10.2.4"
val akkaStreamv = "2.6.13"
val akkaActorV: String = akkaStreamv
val akkaV = "10.2.4"
val akkaStreamV = "2.6.14"
val akkaActorV: String = akkaStreamV

val scalaFxV = "15.0.1-R21"
val javaFxV = "17-ea+5"
val bitcoinsV = "0.5.0-129-68034600-SNAPSHOT"
val bitcoinsV = "0.5.0-183-80f0ecd2-SNAPSHOT"
}

object Compile {

val akkaHttp =
"com.typesafe.akka" %% "akka-http" % V.akkav withSources () withJavadoc ()
"com.typesafe.akka" %% "akka-http" % V.akkaV withSources () withJavadoc ()

val akkaStream =
"com.typesafe.akka" %% "akka-stream" % V.akkaStreamv withSources () withJavadoc ()
"com.typesafe.akka" %% "akka-stream" % V.akkaStreamV withSources () withJavadoc ()

val akkaActor =
"com.typesafe.akka" %% "akka-actor" % V.akkaStreamv withSources () withJavadoc ()
"com.typesafe.akka" %% "akka-actor" % V.akkaStreamV withSources () withJavadoc ()

val akkaSlf4j =
"com.typesafe.akka" %% "akka-slf4j" % V.akkaStreamv withSources () withJavadoc ()
"com.typesafe.akka" %% "akka-slf4j" % V.akkaStreamV withSources () withJavadoc ()

val bitcoinsOracle =
"org.bitcoin-s" %% "bitcoin-s-dlc-oracle" % V.bitcoinsV withSources () withJavadoc ()
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/com/krystal/bull/gui/GlobalData.scala
Expand Up @@ -71,6 +71,5 @@ object GlobalData {

var oracleNameOpt: Option[String] = None

val oracleExplorerClient: SbExplorerClient = SbExplorerClient(
config.explorerEnv)
def oracleExplorerClient: SbExplorerClient = SbExplorerClient(explorerEnv)
}
15 changes: 9 additions & 6 deletions src/main/scala/com/krystal/bull/gui/dialog/ViewEventDialog.scala
Expand Up @@ -42,7 +42,7 @@ object ViewEventDialog {
styleClass += "delete-button"
onAction = _ => {
val f = oracleExplorerClient
.getEvent(event.announcementTLV)
.getAnnouncement(event.announcementTLV)
.map(_.attestations)

val res = Try(Await.result(f, 5.seconds)).getOrElse(None)
Expand Down Expand Up @@ -353,7 +353,7 @@ object ViewEventDialog {
oracleNameOpt match {
case Some(oracleName) =>
row += 1
val addToExplorerButton = new Button("Add to Oracle Explorer") {
val sendToExplorerButton = new Button("Send to Oracle Explorer") {
alignmentInParent = Pos.Center
private val createAnnouncement: CreateAnnouncementExplorer =
event.announcementTLV match {
Expand All @@ -373,13 +373,16 @@ object ViewEventDialog {
completed.oracleAttestmentV0TLV))
}
onAction = _ => {
oracleExplorerClient.createAnnouncement(createAnnouncement)
createAttestationsOpt.foreach(
oracleExplorerClient.createAttestations)
val createAnnouncements =
oracleExplorerClient.createAnnouncement(createAnnouncement)
createAnnouncements.onComplete { _ =>
createAttestationsOpt.foreach(
oracleExplorerClient.createAttestations)
}
}
}

add(addToExplorerButton, 1, row)
add(sendToExplorerButton, 1, row)
case None => ()
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/scala/com/krystal/bull/gui/home/HomePane.scala
Expand Up @@ -172,6 +172,10 @@ class HomePane(glassPane: VBox) {
}

private def oracleNameNode: Node = {
lazy val fromExplorerOpt = Await.result(
oracleExplorerClient.getOracleName(oracle.publicKey),
10.seconds)

if (oracleNameFile.toFile.isFile) {
val str = new String(Files.readAllBytes(oracleNameFile))
oracleNameOpt = Some(str)
Expand All @@ -180,9 +184,17 @@ class HomePane(glassPane: VBox) {
editable = true
minWidth = 500
}
} else if (fromExplorerOpt.isDefined) {
Files.write(GlobalData.oracleNameFile, fromExplorerOpt.get.getBytes)
oracleNameOpt = fromExplorerOpt
new TextField() {
text = fromExplorerOpt.get
editable = true
minWidth = 500
}
} else {
val tf = new TextField() {
minWidth = 250
minWidth = 366
promptText = "Warning: Cannot be changed"
}
val button = new Button("Set oracle name") {
Expand Down

0 comments on commit f664459

Please sign in to comment.