From d388cc618f13b9c2dab3133c45f129ccdf15a6fb Mon Sep 17 00:00:00 2001 From: Luca Spinazzola Date: Tue, 7 Mar 2023 19:16:02 -0500 Subject: [PATCH] add getLabelByContractAddr --- .../kotlin/io/eqoty/secretk/client/RestClient.kt | 6 ++++++ .../io/eqoty/secretk/types/response/LabelResponse.kt | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 client/src/commonMain/kotlin/io/eqoty/secretk/types/response/LabelResponse.kt diff --git a/client/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt b/client/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt index a37edd0..deb9e46 100644 --- a/client/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt +++ b/client/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt @@ -131,6 +131,12 @@ internal class RestClient( return responseData.result } + suspend fun getLabelByContractAddr(addr: String): String { + val path = "/compute/v1beta1/label/$addr" + val response: LabelResponse = get(path) + return response.label + } + suspend fun getCodeInfoByCodeId(codeId: String): CodeInfo { val path = "/compute/v1beta1/code/$codeId" val responseData: CodeInfoResponse = get(path) diff --git a/client/src/commonMain/kotlin/io/eqoty/secretk/types/response/LabelResponse.kt b/client/src/commonMain/kotlin/io/eqoty/secretk/types/response/LabelResponse.kt new file mode 100644 index 0000000..84aaf7d --- /dev/null +++ b/client/src/commonMain/kotlin/io/eqoty/secretk/types/response/LabelResponse.kt @@ -0,0 +1,8 @@ +package io.eqoty.secretk.types.response + +import kotlinx.serialization.Serializable + +@Serializable +data class LabelResponse( + val label: String, +) \ No newline at end of file