Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from blockfrost/feature/openapi-v0.1.27
Update to openapi v0.1.27
- Loading branch information
Showing
24 changed files
with
270 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.blockfrost.sdk.api | ||
|
||
import io.blockfrost.sdk.ApiClient | ||
import io.blockfrost.sdk.api.ScriptsApi.{ScriptRedeemer, Script, ScriptHash} | ||
import io.blockfrost.sdk.common.{Config, SortedPageRequest, SttpSupport} | ||
import org.json4s.{Formats, Serialization} | ||
import sttp.client3.UriContext | ||
|
||
trait ScriptsApi[F[_], P] extends SttpSupport { | ||
this: ApiClient[F, P] => | ||
|
||
def getListOfScripts(pageRequest: SortedPageRequest = SortedPageRequest())(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Seq[ScriptHash]]] | ||
|
||
def getSpecificScript(scriptHash: String)(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Script]] | ||
|
||
def getSpecificScriptRedeemers(scriptHash: String, pageRequest: SortedPageRequest = SortedPageRequest())(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Seq[ScriptRedeemer]]] | ||
} | ||
|
||
trait ScriptsApiImpl[F[_], P] extends ScriptsApi[F, P] { | ||
this: ApiClient[F, P] => | ||
|
||
override def getListOfScripts(pageRequest: SortedPageRequest = SortedPageRequest())(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Seq[ScriptHash]]] = | ||
get(uri"$host/scripts", Some(pageRequest)) | ||
|
||
def getSpecificScript(scriptHash: String)(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Script]] = | ||
get(uri"$host/scripts/$scriptHash") | ||
|
||
override def getSpecificScriptRedeemers(scriptHash: String, pageRequest: SortedPageRequest = SortedPageRequest())(implicit formats: Formats, serialization: Serialization, config: Config): F[ApiResponse[Seq[ScriptRedeemer]]] = | ||
get(uri"$host/scripts/$scriptHash/redeemers", Some(pageRequest)) | ||
} | ||
|
||
object ScriptsApi { | ||
case class ScriptHash(script_hash: String) | ||
case class Script(script_hash: String, `type`: String, serialised_size: Option[Double]) | ||
case class ScriptRedeemer(tx_hash: String, tx_index: Int, purpose: String, unit_mem: String, unit_steps: String, fee: String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../sdk/effect/FuturePaginationSupport.scala → ...st/sdk/util/FuturePaginationSupport.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../sdk/effect/FutureResponseConverter.scala → ...st/sdk/util/FutureResponseConverter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.blockfrost.sdk | ||
|
||
import io.blockfrost.sdk.api.{ScriptsApi, ScriptsApiImpl} | ||
import io.blockfrost.sdk.common.SortedPageRequest | ||
import io.blockfrost.sdk.util.FutureResponseConverter.FutureResponseOps | ||
import org.scalatest.flatspec.AsyncFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import scala.concurrent.Future | ||
|
||
class ScriptApiSpec extends AsyncFlatSpec with Matchers with TestContextSupport { | ||
trait TestContext { | ||
val api: ScriptsApi[Future, Any] | ||
val env: String | ||
val scriptHash: String | ||
} | ||
|
||
val testnetTestContext: TestContext = new TestContext { | ||
val api: ScriptsApi[Future, Any] = new ScriptsApiImpl[Future, Any] with TestnetApiClient | ||
val env: String = TestnetEnv | ||
val scriptHash: String = "740b419cfe4fda7a90073fd4d4637cc81773e9108207254d7c9d3c75" | ||
} | ||
|
||
val mainnetTestContext: TestContext = new TestContext { | ||
val api: ScriptsApi[Future, Any] = new ScriptsApiImpl[Future, Any] with MainnetApiClient | ||
val env: String = MainnetEnv | ||
val scriptHash: String = "f55dfaa24ac08874405206588859ec2804b722a51eb71651433135ef" | ||
} | ||
|
||
Seq(testnetTestContext, mainnetTestContext).foreach { ctx => | ||
implicit val testCtx: TestContext = ctx | ||
|
||
s"getListOfScripts [${ctx.env}]" should "return sequence of ScriptHash" in genericTestContext[TestContext] { ctx => | ||
ctx.api | ||
.getListOfScripts(SortedPageRequest(1)) | ||
.extract | ||
.map(body => { | ||
body.size shouldBe 1 | ||
body.head.script_hash.nonEmpty shouldBe true | ||
succeed | ||
}) | ||
} | ||
|
||
s"getSpecificScript [${ctx.env}]" should "return Script" in genericTestContext[TestContext] { ctx => | ||
ctx.api | ||
.getSpecificScript(ctx.scriptHash) | ||
.extract | ||
.map(body => { | ||
body.script_hash shouldBe ctx.scriptHash | ||
succeed | ||
}) | ||
} | ||
|
||
s"getSpecificScriptRedeemers [${ctx.env}]" should "return sequence of ScriptRedeemer" in genericTestContext[TestContext] { ctx => | ||
ctx.api | ||
.getSpecificScriptRedeemers(ctx.scriptHash, SortedPageRequest(1)) | ||
.extract | ||
.map(_ => succeed) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.