diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt index 99b128d..3de33bc 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/client/RestClient.kt @@ -205,7 +205,7 @@ internal class RestClient( suspend fun decryptDataField(msg: MsgProto, nonce: UByteArray?): UByteArray { val dataField = when (msg) { is MsgExecuteContractResponseProto -> { - msg.data.toUByteArray() + msg.data?.toUByteArray() ?: UByteArray(0) { 0u } } is MsgInstantiateContractResponseProto -> { diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgDataProto.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgDataProto.kt index df91a34..0d6edb6 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgDataProto.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgDataProto.kt @@ -11,19 +11,19 @@ import kotlinx.serialization.protobuf.ProtoNumber @kotlinx.serialization.Serializable class MsgDataProto( @ProtoNumber(1) val msgType: String = "", - @ProtoNumber(2) val data: ByteArray, + @ProtoNumber(2) val data: ByteArray? = null, ) : MsgProto() { fun toMsgResponseType(): MsgProto = when (msgType) { "/secret.compute.v1beta1.MsgInstantiateContract" -> { - ProtoBuf.decodeFromByteArray(data) as MsgInstantiateContractResponseProto + ProtoBuf.decodeFromByteArray(data ?: byteArrayOf()) as MsgInstantiateContractResponseProto } "/secret.compute.v1beta1.MsgExecuteContract" -> { - ProtoBuf.decodeFromByteArray(data) as MsgExecuteContractResponseProto + ProtoBuf.decodeFromByteArray(data ?: byteArrayOf()) as MsgExecuteContractResponseProto } "/secret.compute.v1beta1.MsgStoreCode" -> { - ProtoBuf.decodeFromByteArray(data) as MsgStoreCodeResponseProto + ProtoBuf.decodeFromByteArray(data ?: byteArrayOf()) as MsgStoreCodeResponseProto } else -> throw UnsupportedOperationException("calling toMsg() on an Any proto with typeUrl:${msgType} is not supported") diff --git a/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgExecuteContractResponseProto.kt b/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgExecuteContractResponseProto.kt index 9c70d13..4a4920c 100644 --- a/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgExecuteContractResponseProto.kt +++ b/secretk/src/commonMain/kotlin/io/eqoty/secretk/types/proto/MsgExecuteContractResponseProto.kt @@ -8,5 +8,5 @@ import kotlinx.serialization.protobuf.ProtoNumber */ @kotlinx.serialization.Serializable class MsgExecuteContractResponseProto( - @ProtoNumber(1) val data: ByteArray + @ProtoNumber(1) val data: ByteArray? = null ) : MsgProto() \ No newline at end of file