mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-26 21:42:48 +01:00
Add ExplorerEnv.fromBitcoinNetwork() and use for View on Oracle Explorer siteUrl (#3332)
This commit is contained in:
parent
88b99b03b5
commit
1f43a1910f
2 changed files with 19 additions and 4 deletions
|
@ -1,5 +1,12 @@
|
|||
package org.bitcoins.commons.jsonmodels
|
||||
|
||||
import org.bitcoins.core.config.{
|
||||
BitcoinNetwork,
|
||||
MainNet,
|
||||
RegTest,
|
||||
SigNet,
|
||||
TestNet3
|
||||
}
|
||||
import org.bitcoins.crypto.StringFactory
|
||||
|
||||
sealed trait ExplorerEnv {
|
||||
|
@ -35,4 +42,11 @@ object ExplorerEnv extends StringFactory[ExplorerEnv] {
|
|||
sys.error(s"Failed to parse explorer env from str=$string")
|
||||
}
|
||||
}
|
||||
|
||||
def fromBitcoinNetwork(network: BitcoinNetwork): ExplorerEnv = {
|
||||
network match {
|
||||
case MainNet => Production
|
||||
case TestNet3 | RegTest | SigNet => Test
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bitcoins.commons.jsonmodels.ExplorerEnv
|
|||
import org.bitcoins.core.dlc.accounting.RateOfReturnUtil
|
||||
import org.bitcoins.core.protocol.dlc.models.DLCStatus._
|
||||
import org.bitcoins.core.protocol.dlc.models._
|
||||
import org.bitcoins.gui.GUI
|
||||
import org.bitcoins.gui.{GUI, GlobalData}
|
||||
import org.bitcoins.gui.util.GUIUtil
|
||||
import scalafx.beans.property.StringProperty
|
||||
import scalafx.geometry.Insets
|
||||
|
@ -137,10 +137,11 @@ class DLCTableView(model: DLCPaneModel) {
|
|||
|
||||
val viewOnExplorer: MenuItem = new MenuItem("View on Oracle Explorer") {
|
||||
onAction = _ => {
|
||||
val status = selectionModel.value.getSelectedItem
|
||||
val dlc = selectionModel.value.getSelectedItem
|
||||
val primaryOracle =
|
||||
status.oracleInfo.singleOracleInfos.head.announcement
|
||||
val baseUrl = ExplorerEnv.Production.siteUrl
|
||||
dlc.oracleInfo.singleOracleInfos.head.announcement
|
||||
val baseUrl =
|
||||
ExplorerEnv.fromBitcoinNetwork(GlobalData.network).siteUrl
|
||||
val url =
|
||||
s"${baseUrl}announcement/${primaryOracle.sha256.hex}"
|
||||
GUI.hostServices.showDocument(url)
|
||||
|
|
Loading…
Add table
Reference in a new issue