All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.terra.wasm.v1beta1.genesis.converter.jvm.kt Maven / Gradle / Ivy

There is a newer version: 3.1.6-4
Show newest version
// Transform from terra/wasm/v1beta1/genesis.proto
@file:GeneratorVersion(version = "0.5.2")

package terra.wasm.v1beta1

import com.google.protobuf.ByteString
import com.google.protobuf.Descriptors
import com.google.protobuf.Parser
import kr.jadekim.protobuf.`annotation`.GeneratorVersion
import kr.jadekim.protobuf.converter.mapper.ProtobufTypeMapper

public open class ModelJvmConverter : ProtobufTypeMapper {
  override val descriptor: Descriptors.Descriptor = Genesis.Model.getDescriptor()

  override val parser: Parser = Genesis.Model.parser()

  override val default: Genesis.Model = Genesis.Model.getDefaultInstance()

  override fun convert(obj: Genesis.Model): Model = Model(
  	key = obj.getKey().toByteArray(),
  	`value` = obj.getValue().toByteArray(),
  )

  override fun convert(obj: Model): Genesis.Model {
    val builder = Genesis.Model.newBuilder()
    builder.setKey(ByteString.copyFrom(obj.key))
    builder.setValue(ByteString.copyFrom(obj.`value`))
    return builder.build()
  }
}

public open class CodeJvmConverter : ProtobufTypeMapper {
  override val descriptor: Descriptors.Descriptor = Genesis.Code.getDescriptor()

  override val parser: Parser = Genesis.Code.parser()

  override val default: Genesis.Code = Genesis.Code.getDefaultInstance()

  override fun convert(obj: Genesis.Code): Code = Code(
  	codeInfo = LegacyCodeInfoConverter.convert(obj.getCodeInfo()),
  	codeBytes = obj.getCodeBytes().toByteArray(),
  )

  override fun convert(obj: Code): Genesis.Code {
    val builder = Genesis.Code.newBuilder()
    builder.setCodeInfo(LegacyCodeInfoConverter.convert(obj.codeInfo))
    builder.setCodeBytes(ByteString.copyFrom(obj.codeBytes))
    return builder.build()
  }
}

public open class ContractJvmConverter : ProtobufTypeMapper {
  override val descriptor: Descriptors.Descriptor = Genesis.Contract.getDescriptor()

  override val parser: Parser = Genesis.Contract.parser()

  override val default: Genesis.Contract = Genesis.Contract.getDefaultInstance()

  override fun convert(obj: Genesis.Contract): Contract = Contract(
  	contractInfo = LegacyContractInfoConverter.convert(obj.getContractInfo()),
  	contractStore = obj.getContractStoreList().map { ModelConverter.convert(it) },
  )

  override fun convert(obj: Contract): Genesis.Contract {
    val builder = Genesis.Contract.newBuilder()
    builder.setContractInfo(LegacyContractInfoConverter.convert(obj.contractInfo))
    builder.addAllContractStore(obj.contractStore.map { ModelConverter.convert(it) })
    return builder.build()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy