Rename createevent rpc to createenumevent (#2604)

This commit is contained in:
benthecarman 2021-02-01 12:06:08 -06:00 committed by GitHub
parent f217296522
commit 779eefb6a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View file

@ -1062,17 +1062,17 @@ object ConsoleCli {
cmd("listevents")
.action((_, conf) => conf.copy(command = ListEvents))
.text(s"Lists all event announcements"),
cmd("createevent")
cmd("createenumevent")
.action((_, conf) =>
conf.copy(command = CreateEvent("", Instant.MIN, Seq.empty)))
.text("Registers an oracle event")
conf.copy(command = CreateEnumEvent("", Instant.MIN, Seq.empty)))
.text("Registers an oracle enum event")
.children(
arg[String]("label")
.text("Label for this event")
.required()
.action((label, conf) =>
conf.copy(command = conf.command match {
case createEvent: CreateEvent =>
case createEvent: CreateEnumEvent =>
createEvent.copy(label = label)
case other => other
})),
@ -1081,7 +1081,7 @@ object ConsoleCli {
.required()
.action((time, conf) =>
conf.copy(command = conf.command match {
case createEvent: CreateEvent =>
case createEvent: CreateEnumEvent =>
createEvent.copy(maturationTime = time)
case other => other
})),
@ -1090,7 +1090,7 @@ object ConsoleCli {
.required()
.action((outcomes, conf) =>
conf.copy(command = conf.command match {
case createEvent: CreateEvent =>
case createEvent: CreateEnumEvent =>
createEvent.copy(outcomes = outcomes)
case other => other
}))
@ -1514,9 +1514,9 @@ object ConsoleCli {
RequestParam("listevents")
case GetEvent(announcementTLV) =>
RequestParam("getevent", Seq(up.writeJs(announcementTLV)))
case CreateEvent(label, time, outcomes) =>
case CreateEnumEvent(label, time, outcomes) =>
RequestParam(
"createevent",
"createenumevent",
Seq(up.writeJs(label), up.writeJs(time), up.writeJs(outcomes)))
case CreateDigitDecompEvent(eventName,
time,
@ -1837,7 +1837,7 @@ object CliCommand {
case class GetEvent(announcementTLV: OracleAnnouncementTLV) extends CliCommand
case class CreateEvent(
case class CreateEnumEvent(
label: String,
maturationTime: Instant,
outcomes: Seq[String])

View file

@ -43,7 +43,7 @@ case class OracleRoutes(oracle: DLCOracle)(implicit
}
}
case ServerCommand("createevent", arr) =>
case ServerCommand("createenumevent", arr) =>
CreateEvent.fromJsArr(arr) match {
case Failure(exception) =>
reject(ValidationRejection("failure", Some(exception)))

View file

@ -15,7 +15,7 @@ checkout [this page](build-oracle-server.md).
- `getpublickey` - Get oracle's public key
- `getstakingaddress` - Get oracle's staking address
- `listevents` - Lists all oracle announcement TLVs
- `createevent` `label` `maturationtime` `outcomes` - Registers an oracle event
- `createenumevent` `label` `maturationtime` `outcomes` - Registers an oracle enum event
- `label` - Label for this event
- `maturationtime` - The earliest expected time an outcome will be signed, given in epoch second
- `outcomes` - Possible outcomes for this event
@ -42,7 +42,7 @@ checkout [this page](build-oracle-server.md).
Bitcoin-S CLI:
```bash
$ bitcoin-s-cli createevent test 1701917137 "outcome1,outcome2,outcome3"
$ bitcoin-s-cli createenumevent test 1701917137 "outcome1,outcome2,outcome3"
fdd824b0ba0f08e9becbf77019e246ca8a80c027585634dc1aed4b7f67442ada394b40dcb242d8a8c84893a752b93f30ff07525b0604382255ec7392fcc6f230140feb905f6f49e116de8cb57856bacdd9997d8dfb73877f64a4ec8d45fc0e73a0e52115fdd8224c000180e550759cb6275f6db3fad2b616ed51bdcccc204d0d978cd921cafae9fc1d6f657131d1fdd8061d0003086f7574636f6d6531086f7574636f6d6532086f7574636f6d65330474657374
$ bitcoin-s-cli getevent fdd824b0ba0f08e9becbf77019e246ca8a80c027585634dc1aed4b7f67442ada394b40dcb242d8a8c84893a752b93f30ff07525b0604382255ec7392fcc6f230140feb905f6f49e116de8cb57856bacdd9997d8dfb73877f64a4ec8d45fc0e73a0e52115fdd8224c000180e550759cb6275f6db3fad2b616ed51bdcccc204d0d978cd921cafae9fc1d6f657131d1fdd8061d0003086f7574636f6d6531086f7574636f6d6532086f7574636f6d65330474657374
@ -76,7 +76,7 @@ fdd8687004746573745f6f49e116de8cb57856bacdd9997d8dfb73877f64a4ec8d45fc0e73a0e521
CURL:
```bash
$ curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createevent", "params": ["testEvent", 1701917137, ["outcome1", "outcome2", "outcome3"]]}' -H "Content-Type: application/json" http://127.0.0.1:9999/
$ curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createenumevent", "params": ["testEvent", 1701917137, ["outcome1", "outcome2", "outcome3"]]}' -H "Content-Type: application/json" http://127.0.0.1:9999/
{"result":"fdd824b0ba0f08e9becbf77019e246ca8a80c027585634dc1aed4b7f67442ada394b40dcb242d8a8c84893a752b93f30ff07525b0604382255ec7392fcc6f230140feb905f6f49e116de8cb57856bacdd9997d8dfb73877f64a4ec8d45fc0e73a0e52115fdd8224c000180e550759cb6275f6db3fad2b616ed51bdcccc204d0d978cd921cafae9fc1d6f657131d1fdd8061d0003086f7574636f6d6531086f7574636f6d6532086f7574636f6d65330474657374","error":null}
$ curl --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getevent", "params": ["fdd824b0ba0f08e9becbf77019e246ca8a80c027585634dc1aed4b7f67442ada394b40dcb242d8a8c84893a752b93f30ff07525b0604382255ec7392fcc6f230140feb905f6f49e116de8cb57856bacdd9997d8dfb73877f64a4ec8d45fc0e73a0e52115fdd8224c000180e550759cb6275f6db3fad2b616ed51bdcccc204d0d978cd921cafae9fc1d6f657131d1fdd8061d0003086f7574636f6d6531086f7574636f6d6532086f7574636f6d65330474657374"]}' -H "Content-Type: application/json" http://127.0.0.1:9999/