diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index d12d433c7..be3258324 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.8" services: iroha: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.19 + image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 environment: TORII_P2P_ADDR: iroha:1337 TORII_API_URL: iroha:8080 @@ -24,7 +24,7 @@ services: command: iroha --submit-genesis iroha1: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.19 + image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 environment: TORII_P2P_ADDR: iroha1:1338 TORII_API_URL: iroha1:8081 @@ -46,7 +46,7 @@ services: command: iroha iroha2: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.19 + image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 environment: TORII_P2P_ADDR: iroha2:1339 TORII_API_URL: iroha2:8082 @@ -68,7 +68,7 @@ services: command: iroha iroha3: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.19 + image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 environment: TORII_P2P_ADDR: iroha3:1340 TORII_API_URL: iroha3:8083 diff --git a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt index 9ca1d3c54..20e24d511 100644 --- a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt @@ -9,7 +9,7 @@ import java.net.URL fun main(args: Array): Unit = runBlocking { val peerUrl = "http://127.0.0.1:8080" val telemetryUrl = "http://127.0.0.1:8180" - val admin = AccountId("bob".asName(), "wonderland".asDomainId()) + val admin = AccountId("wonderland".asDomainId(), "bob".asName()) val adminKeyPair = keyPairFromHex( "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", diff --git a/modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt b/modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt index bfe4b8e9d..0f146d6f9 100644 --- a/modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt +++ b/modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt @@ -51,7 +51,7 @@ open class AdminIroha2Client( /** * Send metrics request */ - suspend fun metrics(): String = client.get("${getTelemetryUrl()}$METRICS_ENDPOINT").body() + suspend fun metrics(): String = client.get("${getApiUrl()}$METRICS_ENDPOINT").body() /** * Send health check request @@ -66,7 +66,7 @@ open class AdminIroha2Client( /** * Send status check request */ - suspend fun status(): PeerStatus = client.get("${getTelemetryUrl()}$STATUS_ENDPOINT").body() + suspend fun status(): PeerStatus = client.get("${getApiUrl()}$STATUS_ENDPOINT").body() /** * Send schema request diff --git a/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Genesis.kt b/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Genesis.kt index 4bd04f634..2370c1f50 100644 --- a/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Genesis.kt +++ b/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Genesis.kt @@ -1,16 +1,16 @@ package jp.co.soramitsu.iroha2 +import jp.co.soramitsu.iroha2.generated.ExecutorMode import jp.co.soramitsu.iroha2.generated.Expression import jp.co.soramitsu.iroha2.generated.IdentifiableBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.NewAccount import jp.co.soramitsu.iroha2.generated.NewAssetDefinition import jp.co.soramitsu.iroha2.generated.NewDomain import jp.co.soramitsu.iroha2.generated.RawGenesisBlock -import jp.co.soramitsu.iroha2.generated.RegisterBox +import jp.co.soramitsu.iroha2.generated.RegisterExpr import jp.co.soramitsu.iroha2.generated.RegistrableBox -import jp.co.soramitsu.iroha2.generated.ValidatorMode import jp.co.soramitsu.iroha2.generated.Value import java.nio.file.Files import java.nio.file.Path @@ -37,31 +37,31 @@ open class Genesis(open val block: RawGenesisBlock) { companion object { - val validatorMode = this::class.java.classLoader.getResource("validator.wasm") - ?.let { ValidatorMode.Path("validator.wasm") } - ?: throw IrohaSdkException("validator.wasm not found") + val executorMode = this::class.java.classLoader.getResource("executor.wasm") + ?.let { ExecutorMode.Path("executor.wasm") } + ?: throw IrohaSdkException("executor.wasm not found") /** * Return empty genesis */ - fun getEmpty() = Genesis(RawGenesisBlock(listOf(listOf()), validatorMode)) + fun getEmpty() = Genesis(RawGenesisBlock(listOf(listOf()), executorMode)) /** * List of genesis blocks to single block with unique instructions */ fun List.toSingle(): Genesis { - val uniqueIsi: MutableSet = mutableSetOf() + val uniqueIsi: MutableSet = mutableSetOf() this.forEach { genesis -> uniqueIsi.addAll(genesis.block.transactions.flatten()) } - return Genesis(RawGenesisBlock(listOf(uniqueIsi.mergeMetadata()), validatorMode)) + return Genesis(RawGenesisBlock(listOf(uniqueIsi.mergeMetadata()), executorMode)) } - private fun MutableSet.mergeMetadata(): List { + private fun MutableSet.mergeMetadata(): List { val metadataMap = mutableMapOf() - // only for InstructionBox.Register + // only for InstructionExpr.Register this.extractIdentifiableBoxes().forEach { idBox -> metadataMap.putMergedMetadata(idBox) } @@ -71,16 +71,16 @@ open class Genesis(open val block: RawGenesisBlock) { val idBox = toReplace.first().extractIdentifiableBox() val registrableBox = idBox?.toRegisterBox(metadata) ?: throw RuntimeException("IdentifiableBox shouldn't be null") - this.add(InstructionBox.Register(RegisterBox(registrableBox.evaluatesTo()))) + this.add(InstructionExpr.Register(RegisterExpr(registrableBox.evaluatesTo()))) } return this.sorted() } - private fun MutableSet.sorted() = this.sortedWith( + private fun MutableSet.sorted() = this.sortedWith( compareByDescending { instruction -> when (instruction) { - is InstructionBox.Register -> when (instruction.extractIdentifiableBox()) { + is InstructionExpr.Register -> when (instruction.extractIdentifiableBox()) { is IdentifiableBox.NewDomain -> 5 is IdentifiableBox.NewAccount -> 4 is IdentifiableBox.NewAssetDefinition -> 3 @@ -142,15 +142,15 @@ open class Genesis(open val block: RawGenesisBlock) { } } - private fun MutableSet.findIsiToReplace( + private fun MutableSet.findIsiToReplace( metadata: Map, - ): MutableMap> { - val isiToReplace = mutableMapOf>() + ): MutableMap> { + val isiToReplace = mutableMapOf>() this.forEach { instruction -> runCatching { - instruction.cast() - .registerBox.`object`.expression + instruction.cast() + .registerExpr.`object`.expression .cast().value .cast().identifiableBox }.onSuccess { idBox -> diff --git a/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Serde.kt b/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Serde.kt index f69737de1..587756ba3 100644 --- a/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Serde.kt +++ b/modules/block/src/main/kotlin/jp/co/soramitsu/iroha2/Serde.kt @@ -12,10 +12,12 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.node.IntNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.KotlinFeature import com.fasterxml.jackson.module.kotlin.KotlinModule import io.ipfs.multihash.Multihash +import io.ktor.util.toUpperCasePreservingASCIIRules import jp.co.soramitsu.iroha2.DigestFunction.Ed25519 import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.Algorithm @@ -25,28 +27,29 @@ import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValue import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.BlockHeader -import jp.co.soramitsu.iroha2.generated.BurnBox +import jp.co.soramitsu.iroha2.generated.BurnExpr import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.EvaluatesTo +import jp.co.soramitsu.iroha2.generated.ExecutorMode import jp.co.soramitsu.iroha2.generated.Expression -import jp.co.soramitsu.iroha2.generated.GrantBox +import jp.co.soramitsu.iroha2.generated.GrantExpr import jp.co.soramitsu.iroha2.generated.Hash import jp.co.soramitsu.iroha2.generated.HashValue import jp.co.soramitsu.iroha2.generated.IdBox import jp.co.soramitsu.iroha2.generated.IdentifiableBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Ipv4Addr import jp.co.soramitsu.iroha2.generated.Ipv6Addr import jp.co.soramitsu.iroha2.generated.LengthLimits import jp.co.soramitsu.iroha2.generated.Limits import jp.co.soramitsu.iroha2.generated.Metadata -import jp.co.soramitsu.iroha2.generated.MintBox +import jp.co.soramitsu.iroha2.generated.MintExpr import jp.co.soramitsu.iroha2.generated.Mintable import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.NewAccount import jp.co.soramitsu.iroha2.generated.NewAssetDefinition import jp.co.soramitsu.iroha2.generated.NewDomain -import jp.co.soramitsu.iroha2.generated.NewParameterBox +import jp.co.soramitsu.iroha2.generated.NewParameterExpr import jp.co.soramitsu.iroha2.generated.NewRole import jp.co.soramitsu.iroha2.generated.NumericValue import jp.co.soramitsu.iroha2.generated.Parameter @@ -54,23 +57,22 @@ import jp.co.soramitsu.iroha2.generated.Peer import jp.co.soramitsu.iroha2.generated.PermissionToken import jp.co.soramitsu.iroha2.generated.PublicKey import jp.co.soramitsu.iroha2.generated.RawGenesisBlock -import jp.co.soramitsu.iroha2.generated.RegisterBox +import jp.co.soramitsu.iroha2.generated.RegisterExpr import jp.co.soramitsu.iroha2.generated.RegistrableBox import jp.co.soramitsu.iroha2.generated.Role import jp.co.soramitsu.iroha2.generated.RoleId -import jp.co.soramitsu.iroha2.generated.SequenceBox -import jp.co.soramitsu.iroha2.generated.SetKeyValueBox +import jp.co.soramitsu.iroha2.generated.SequenceExpr +import jp.co.soramitsu.iroha2.generated.SetKeyValueExpr import jp.co.soramitsu.iroha2.generated.SignatureCheckCondition +import jp.co.soramitsu.iroha2.generated.SignedBlock import jp.co.soramitsu.iroha2.generated.SocketAddr import jp.co.soramitsu.iroha2.generated.StringWithJson import jp.co.soramitsu.iroha2.generated.TransactionLimits import jp.co.soramitsu.iroha2.generated.TransactionQueryOutput import jp.co.soramitsu.iroha2.generated.TransactionValue -import jp.co.soramitsu.iroha2.generated.TriggerBox import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.ValidatorMode +import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock import java.io.ByteArrayOutputStream import kotlin.reflect.KClass import kotlin.reflect.full.createInstance @@ -85,10 +87,10 @@ val JSON_SERDE by lazy { val module = SimpleModule() // deserializers - module.addDeserializer(SequenceBox::class.java, SequenceBoxDeserializer) - module.addDeserializer(InstructionBox::class.java, InstructionDeserializer) - module.addDeserializer(ValidatorMode::class.java, ValidatorDeserializer) - module.addDeserializer(GrantBox::class.java, GrantBoxDeserializer) + module.addDeserializer(SequenceExpr::class.java, SequenceExprDeserializer) + module.addDeserializer(InstructionExpr::class.java, InstructionDeserializer) + module.addDeserializer(ExecutorMode::class.java, ExecutorDeserializer) + module.addDeserializer(GrantExpr::class.java, GrantExprDeserializer) module.addDeserializer(Value::class.java, ValueDeserializer) module.addDeserializer(AssetValue::class.java, AssetValueDeserializer) module.addDeserializer(PublicKey::class.java, PublicKeyDeserializer) @@ -101,12 +103,12 @@ val JSON_SERDE by lazy { module.addDeserializer(RoleId::class.java, RoleIdDeserializer) module.addDeserializer(AssetDefinitionId::class.java, AssetDefinitionIdDeserializer) module.addDeserializer(AssetId::class.java, AssetIdDeserializer) - module.addDeserializer(RegisterBox::class.java, RegisterBoxDeserializer) - module.addDeserializer(MintBox::class.java, MintBoxDeserializer) - module.addDeserializer(SetKeyValueBox::class.java, SetKeyValueBoxDeserializer) + module.addDeserializer(RegisterExpr::class.java, RegisterExprDeserializer) + module.addDeserializer(MintExpr::class.java, MintExprDeserializer) + module.addDeserializer(SetKeyValueExpr::class.java, SetKeyValueExprDeserializer) module.addDeserializer(Metadata::class.java, MetadataDeserializer) module.addDeserializer(NewRole::class.java, NewRoleDeserializer) - module.addDeserializer(NewParameterBox::class.java, NewParameterBoxDeserializer) + module.addDeserializer(NewParameterExpr::class.java, NewParameterExprDeserializer) module.addDeserializer(PermissionToken::class.java, PermissionTokenDeserializer) module.addDeserializer(StringWithJson::class.java, StringWithJsonDeserializer) module.addKeyDeserializer(AssetDefinitionId::class.java, AssetDefinitionIdKeyDeserializer) @@ -133,9 +135,9 @@ val JSON_SERDE by lazy { module.addSerializer(Metadata::class.java, MetadataSerializer) module.addSerializer(IdentifiableBox.NewRole::class.java, IdentifiableBoxNewRoleSerializer) module.addSerializer(Parameter::class.java, ParameterSerializer) - module.addSerializer(ValidatorMode::class.java, ValidatorModeSerializer) - module.addSerializer(SequenceBox::class.java, SequenceBoxSerializer) - module.addSerializer(NewParameterBox::class.java, NewParameterBoxSerializer) + module.addSerializer(ExecutorMode::class.java, ExecutorModeSerializer) + module.addSerializer(SequenceExpr::class.java, SequenceExprSerializer) + module.addSerializer(NewParameterExpr::class.java, NewParameterExprSerializer) module.addSerializer(StringWithJson::class.java, StringWithJsonSerializer) mapper.registerModule(module) @@ -151,19 +153,19 @@ val JSON_SERDE by lazy { } } -private fun sealedDeserializeSequenceBox(p: JsonParser, mapper: ObjectMapper): SequenceBox { +private fun sealedDeserializeSequenceExpr(p: JsonParser, mapper: ObjectMapper): SequenceExpr { val jsonNodes = p.readValueAsTree() val instructions = jsonNodes.map { - mapper.convertValue(it, InstructionBox::class.java) as InstructionBox + mapper.convertValue(it, InstructionExpr::class.java) as InstructionExpr } - return SequenceBox(instructions) + return SequenceExpr(instructions) } -private fun sealedDeserializeInstruction(p: JsonParser, mapper: ObjectMapper): InstructionBox { +private fun sealedDeserializeInstruction(p: JsonParser, mapper: ObjectMapper): InstructionExpr { val node = p.readValueAsTree().fields().next() val param = node.key - val subtype = InstructionBox::class.nestedClasses.find { clazz -> + val subtype = InstructionExpr::class.nestedClasses.find { clazz -> !clazz.isCompanion && clazz.simpleName == param } ?: throw DeserializationException("Class with constructor($param) not found") @@ -174,14 +176,14 @@ private fun sealedDeserializeInstruction(p: JsonParser, mapper: ObjectMapper): I val toConvert: JsonNode = node.value val arg = mapper.convertValue(toConvert, argTypeName.asClass()) - return subtype.primaryConstructor?.call(arg) as InstructionBox + return subtype.primaryConstructor?.call(arg) as InstructionExpr } -private fun sealedDeserializeValidator(p: JsonParser, mapper: ObjectMapper): ValidatorMode { - return ValidatorMode.Path(p.readValueAsTree().asText()) +private fun sealedDeserializeValidator(p: JsonParser, mapper: ObjectMapper): ExecutorMode { + return ExecutorMode.Path(p.readValueAsTree().asText()) } -private fun sealedDeserializeGrantBox(p: JsonParser, mapper: ObjectMapper): GrantBox { +private fun sealedDeserializeGrantExpr(p: JsonParser, mapper: ObjectMapper): GrantExpr { val jsonNode = p.readValueAsTree() val iter = jsonNode.iterator() @@ -191,7 +193,7 @@ private fun sealedDeserializeGrantBox(p: JsonParser, mapper: ObjectMapper): Gran nodes.add(node) } - val node = jsonNode.fields().next() + val node = jsonNode.fields().next().value.fields().next() val destination = nodes[1] val paramAndValueToConvert = if (RoleId::class.java.simpleName == node.key) { Pair( @@ -215,7 +217,7 @@ private fun sealedDeserializeGrantBox(p: JsonParser, mapper: ObjectMapper): Gran val grantObject = mapper.convertValue(paramAndValueToConvert.second, argTypeName.asClass()) val destinationId = mapper.convertValue(destination, IdBox::class.java) - return GrantBox( + return GrantExpr( `object` = grantObject.evaluatesTo().cast(), destinationId = destinationId.evaluatesTo().cast(), ) @@ -264,7 +266,7 @@ private fun getValueByClazz(clazz: KClass, subtype: KClass<*>, arg: Any SignatureCheckCondition::class -> Value.SignatureCheckCondition(subtype.primaryConstructor?.call(arg) as SignatureCheckCondition) PermissionToken::class -> Value.PermissionToken(subtype.primaryConstructor?.call(arg) as PermissionToken) HashValue::class -> Value.Hash(subtype.primaryConstructor?.call(arg) as HashValue) - VersionedCommittedBlock::class -> Value.Block(subtype.primaryConstructor?.call(arg) as VersionedCommittedBlock) + SignedBlock::class -> Value.Block(subtype.primaryConstructor?.call(arg) as SignedBlock) BlockHeader::class -> Value.BlockHeader(subtype.primaryConstructor?.call(arg) as BlockHeader) Ipv4Addr::class -> Value.Ipv4Addr(subtype.primaryConstructor?.call(arg) as Ipv4Addr) Ipv6Addr::class -> Value.Ipv6Addr(subtype.primaryConstructor?.call(arg) as Ipv6Addr) @@ -300,7 +302,7 @@ private fun getClazzByParam(param: String): KClass { "TransactionQueryOutput" -> TransactionQueryOutput::class "PermissionToken" -> PermissionToken::class "Hash" -> Hash::class - "Block" -> VersionedCommittedBlock::class + "Block" -> SignedBlock::class "BlockHeader" -> BlockHeader::class "Ipv4Addr" -> Ipv4Addr::class "Ipv6Addr" -> Ipv6Addr::class @@ -328,7 +330,7 @@ private fun sealedDeserializeIdBox(p: JsonParser, mapper: ObjectMapper): IdBox { return subtype.primaryConstructor?.call(arg) as IdBox } -private fun sealedDeserializeRegisterBox(p: JsonParser, mapper: ObjectMapper): RegisterBox { +private fun sealedDeserializeRegisterExpr(p: JsonParser, mapper: ObjectMapper): RegisterExpr { val node = p.readValueAsTree().fields().next() val param = node.key.removePrefix("New") @@ -340,29 +342,23 @@ private fun sealedDeserializeRegisterBox(p: JsonParser, mapper: ObjectMapper): R ?: throw DeserializationException("Subtype parameter not found by $param") val arg = mapper.convertValue(node.value, argTypeName.asClass()) - return getRegisterBox(arg) + return getRegisterExpr(arg) } -private fun getRegisterBox(arg: Any): RegisterBox { +private fun getRegisterExpr(arg: Any): RegisterExpr { return when (arg) { - is NewDomain -> RegisterBox(RegistrableBox.Domain(arg).evaluatesTo()) - is NewAccount -> RegisterBox(RegistrableBox.Account(arg).evaluatesTo()) - is Peer -> RegisterBox(RegistrableBox.Peer(arg).evaluatesTo()) - is NewAssetDefinition -> RegisterBox(RegistrableBox.AssetDefinition(arg).evaluatesTo()) - is Asset -> RegisterBox(RegistrableBox.Asset(arg).evaluatesTo()) - is NewRole -> RegisterBox(RegistrableBox.Role(arg).evaluatesTo()) - is TriggerBox -> when (arg) { - is TriggerBox.Raw -> RegistrableBox.Trigger(arg.triggerOfTriggeringFilterBoxAndExecutable) - else -> throw IrohaSdkException("Unsupported trigger type") - }.let { - RegisterBox(it.evaluatesTo()) - } - + is NewDomain -> RegisterExpr(RegistrableBox.Domain(arg).evaluatesTo()) + is NewAccount -> RegisterExpr(RegistrableBox.Account(arg).evaluatesTo()) + is Peer -> RegisterExpr(RegistrableBox.Peer(arg).evaluatesTo()) + is NewAssetDefinition -> RegisterExpr(RegistrableBox.AssetDefinition(arg).evaluatesTo()) + is Asset -> RegisterExpr(RegistrableBox.Asset(arg).evaluatesTo()) + is NewRole -> RegisterExpr(RegistrableBox.Role(arg).evaluatesTo()) + is TriggerOfTriggeringFilterBox -> RegisterExpr(RegistrableBox.Trigger(arg).evaluatesTo()) else -> throw DeserializationException("Register box `$arg` not found") } } -private fun sealedDeserializeMintBox(p: JsonParser, mapper: ObjectMapper): MintBox { +private fun sealedDeserializeMintExpr(p: JsonParser, mapper: ObjectMapper): MintExpr { val jsonNode = p.readValueAsTree() val iter = jsonNode.iterator() val nodes = mutableListOf() @@ -370,10 +366,10 @@ private fun sealedDeserializeMintBox(p: JsonParser, mapper: ObjectMapper): MintB val node = iter.next() nodes.add(node) } - + val numericTypeAndValue = jsonNode.fields().next().value.asText().split("_") val newNode = mapper.createObjectNode().set( - jsonNode.fields().next().key, - jsonNode.fields().next().value, + numericTypeAndValue[1].toUpperCasePreservingASCIIRules(), + IntNode(numericTypeAndValue[0].toInt()), ) val objectId = mapper.convertValue( newNode, @@ -383,22 +379,22 @@ private fun sealedDeserializeMintBox(p: JsonParser, mapper: ObjectMapper): MintB nodes[1], IdBox::class.java, ) as IdBox - return MintBox( + return MintExpr( `object` = objectId.evaluatesTo().cast(), destinationId = destination.evaluatesTo().cast(), ) } -private fun sealedDeserializeNewParameterBox(p: JsonParser, mapper: ObjectMapper): NewParameterBox { +private fun sealedDeserializeNewParameterExpr(p: JsonParser, mapper: ObjectMapper): NewParameterExpr { val jsonNode = p.readValueAsTree().fields().next() val parameter = jsonNode.value.asText().asParameter() - return NewParameterBox( + return NewParameterExpr( parameter = parameter.evaluatesTo().cast(), ) } -private fun sealedDeserializeSetKeyValueBox(p: JsonParser, mapper: ObjectMapper): SetKeyValueBox { +private fun sealedDeserializeSetKeyValueExpr(p: JsonParser, mapper: ObjectMapper): SetKeyValueExpr { val jsonNode = p.readValueAsTree() val iter = jsonNode.iterator() val nodes = mutableListOf() @@ -419,7 +415,7 @@ private fun sealedDeserializeSetKeyValueBox(p: JsonParser, mapper: ObjectMapper) val objectIdArg = mapper.convertValue(objectId.value, argTypeName.asClass()) val keyArg = mapper.convertValue(key.value, Name::class.java) val valueArg = mapper.convertValue(nodes[2], Value::class.java) - return SetKeyValueBox( + return SetKeyValueExpr( objectId = objectIdArg.evaluatesTo().cast(), key = keyArg.evaluatesTo().cast(), value = valueArg.evaluatesTo().cast(), @@ -454,35 +450,35 @@ private fun sealedDeserializeMetadata(p: JsonParser, mapper: ObjectMapper): Meta } /** - * Deserializer for sequence box [SequenceBox] + * Deserializer for sequence expr [SequenceExpr] */ -object SequenceBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SequenceBox { - return sealedDeserializeSequenceBox(p, JSON_SERDE) +object SequenceExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SequenceExpr { + return sealedDeserializeSequenceExpr(p, JSON_SERDE) } } /** - * Deserializer for [Iroha Special Instructions][InstructionBox] + * Deserializer for [Iroha Special Instructions][InstructionExpr] */ -object InstructionDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): InstructionBox { +object InstructionDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): InstructionExpr { return sealedDeserializeInstruction(p, JSON_SERDE) } } /** - * Deserializer for [ValidatorMode] + * Deserializer for [ExecutorMode] */ -object ValidatorDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ValidatorMode { +object ExecutorDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ExecutorMode { return sealedDeserializeValidator(p, JSON_SERDE) } } -object GrantBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): GrantBox { - return sealedDeserializeGrantBox(p, JSON_SERDE) +object GrantExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): GrantExpr { + return sealedDeserializeGrantExpr(p, JSON_SERDE) } } @@ -514,21 +510,21 @@ object IdBoxDeserializer : JsonDeserializer() { } } -object RegisterBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): RegisterBox { - return sealedDeserializeRegisterBox(p, JSON_SERDE) +object RegisterExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): RegisterExpr { + return sealedDeserializeRegisterExpr(p, JSON_SERDE) } } -object MintBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): MintBox { - return sealedDeserializeMintBox(p, JSON_SERDE) +object MintExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): MintExpr { + return sealedDeserializeMintExpr(p, JSON_SERDE) } } -object NewParameterBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewParameterBox { - return sealedDeserializeNewParameterBox(p, JSON_SERDE) +object NewParameterExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewParameterExpr { + return sealedDeserializeNewParameterExpr(p, JSON_SERDE) } } @@ -565,9 +561,9 @@ object PermissionTokenDeserializer : JsonDeserializer() { } } -object SetKeyValueBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SetKeyValueBox { - return sealedDeserializeSetKeyValueBox(p, JSON_SERDE) +object SetKeyValueExprDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SetKeyValueExpr { + return sealedDeserializeSetKeyValueExpr(p, JSON_SERDE) } } @@ -720,10 +716,10 @@ object RawGenesisBlockSerializer : JsonSerializer() { override fun serialize(block: RawGenesisBlock, gen: JsonGenerator, serializers: SerializerProvider) { gen.writeStartObject() when (block.transactions[0].isEmpty()) { - true -> gen.writeObjectField("transactions", listOf()) + true -> gen.writeObjectField("transactions", listOf()) false -> gen.writeObjectField("transactions", block.transactions) } - gen.writeObjectField("validator", block.validator) + gen.writeObjectField("executor", block.executor) gen.writeEndObject() } } @@ -806,10 +802,10 @@ object TriggerIdSerializer : JsonSerializer() { } /** - * Serializer for [SequenceBox] + * Serializer for [SequenceExpr] */ -object SequenceBoxSerializer : JsonSerializer() { - override fun serialize(value: SequenceBox, gen: JsonGenerator, serializers: SerializerProvider) { +object SequenceExprSerializer : JsonSerializer() { + override fun serialize(value: SequenceExpr, gen: JsonGenerator, serializers: SerializerProvider) { gen.writeStartArray() value.instructions.forEach { parameter -> serializeSingleMember(gen, parameter) @@ -819,10 +815,10 @@ object SequenceBoxSerializer : JsonSerializer() { } /** - * Serializer for [NewParameterBox] + * Serializer for [NewParameterExpr] */ -object NewParameterBoxSerializer : JsonSerializer() { - override fun serialize(value: NewParameterBox, gen: JsonGenerator, serializers: SerializerProvider) { +object NewParameterExprSerializer : JsonSerializer() { + override fun serialize(value: NewParameterExpr, gen: JsonGenerator, serializers: SerializerProvider) { val parameter = value.parameter.expression.cast() .value.cast().identifiableBox.cast().parameter gen.writeStartObject() @@ -863,12 +859,12 @@ object NameSerializer : JsonSerializer() { } /** - * Serializer for [Name] + * Serializer for [ExecutorMode] */ -object ValidatorModeSerializer : JsonSerializer() { - override fun serialize(value: ValidatorMode, gen: JsonGenerator, serializers: SerializerProvider) { +object ExecutorModeSerializer : JsonSerializer() { + override fun serialize(value: ExecutorMode, gen: JsonGenerator, serializers: SerializerProvider) { when (value) { - is ValidatorMode.Path -> gen.writeString(value.string) + is ExecutorMode.Path -> gen.writeString(value.string) else -> throw IrohaSdkException("Unsupported type ${this::class}") } } @@ -938,11 +934,11 @@ object ParameterSerializer : JsonSerializer() { object EnumerationSerializer : JsonSerializer() { override fun serialize(value: ModelEnum, gen: JsonGenerator, serializers: SerializerProvider) { when (value) { - is InstructionBox.Grant -> value.serialize(gen) - is InstructionBox.Burn -> value.serialize(gen) - is InstructionBox.Mint -> value.serialize(gen) - is InstructionBox.SetKeyValue -> value.serialize(gen) - is InstructionBox.Register -> value.serialize(gen) + is InstructionExpr.Grant -> value.serialize(gen) + is InstructionExpr.Burn -> value.serialize(gen) + is InstructionExpr.Mint -> value.serialize(gen) + is InstructionExpr.SetKeyValue -> value.serialize(gen) + is InstructionExpr.Register -> value.serialize(gen) is Expression.Raw -> value.serialize(gen) is Value.Identifiable -> value.serialize(gen) is Value.Id -> value.serialize(gen) @@ -959,17 +955,17 @@ private fun Expression.Raw.serialize(gen: JsonGenerator) = this.serializeEnum(ge private fun EvaluatesTo<*>.serialize(gen: JsonGenerator) = this.serializeEnum(gen) -private fun InstructionBox.SetKeyValue.serialize(gen: JsonGenerator) = this.serializeBox(gen) +private fun InstructionExpr.SetKeyValue.serialize(gen: JsonGenerator) = this.serializeExpr(gen) -private fun InstructionBox.Grant.serialize(gen: JsonGenerator) { - return this.serializeBox(gen) +private fun InstructionExpr.Grant.serialize(gen: JsonGenerator) { + return this.serializeExpr(gen) } -private fun InstructionBox.Burn.serialize(gen: JsonGenerator) = this.serializeBox(gen) +private fun InstructionExpr.Burn.serialize(gen: JsonGenerator) = this.serializeExpr(gen) -private fun InstructionBox.Mint.serialize(gen: JsonGenerator) = this.serializeBox(gen) +private fun InstructionExpr.Mint.serialize(gen: JsonGenerator) = this.serializeExpr(gen) -private fun InstructionBox.Register.serialize(gen: JsonGenerator) { +private fun InstructionExpr.Register.serialize(gen: JsonGenerator) { val clazz = this::class val memberProperties = clazz.memberProperties when (memberProperties.size) { @@ -979,7 +975,7 @@ private fun InstructionBox.Register.serialize(gen: JsonGenerator) { gen.writeObjectField( clazz.simpleName, memberProperties.first().call(this) - ?.cast() + ?.cast() ?.`object`?.expression, ) gen.writeEndObject() @@ -990,9 +986,9 @@ private fun InstructionBox.Register.serialize(gen: JsonGenerator) { } /** - * Serializes BurnBox, MintBox, GrantBox etc... + * Serializes BurnExpr, MintExpr, GrantExpr etc... */ -private inline fun InstructionBox.serializeBox(gen: JsonGenerator) { +private inline fun InstructionExpr.serializeExpr(gen: JsonGenerator) { val clazz = this::class val memberProperties = clazz.memberProperties when (memberProperties.size) { @@ -1000,7 +996,7 @@ private inline fun InstructionBox.serializeBox(gen: JsonGenerator) { 1 -> { gen.writeStartObject() gen.writeObjectFieldStart(clazz.simpleName) - memberProperties.first().call(this)?.cast()?.serializeBox(gen) + memberProperties.first().call(this)?.cast()?.serializeExpr(gen) gen.writeEndObject() gen.writeEndObject() } @@ -1009,35 +1005,37 @@ private inline fun InstructionBox.serializeBox(gen: JsonGenerator) { } } -private inline fun B.serializeBox( +private inline fun B.serializeExpr( gen: JsonGenerator, ) = when (B::class) { - BurnBox::class -> this?.cast()?.serializeBox(gen) - MintBox::class -> this?.cast()?.serializeBox(gen) - GrantBox::class -> this?.cast()?.serializeBox(gen) - SetKeyValueBox::class -> this?.cast()?.serializeBox(gen) + BurnExpr::class -> this?.cast()?.serializeExpr(gen) + MintExpr::class -> this?.cast()?.serializeExpr(gen) + GrantExpr::class -> this?.cast()?.serializeExpr(gen) + SetKeyValueExpr::class -> this?.cast()?.serializeExpr(gen) else -> throw IrohaSdkException("Unexpected type ${B::class}") } -private fun BurnBox.serializeBox( +private fun BurnExpr.serializeExpr( gen: JsonGenerator, ) = mintBurnSerialize(gen, this.`object`.expression, this.destinationId) -private fun MintBox.serializeBox( +private fun MintExpr.serializeExpr( gen: JsonGenerator, ) = mintBurnSerialize(gen, this.`object`.expression, this.destinationId) -private fun GrantBox.serializeBox(gen: JsonGenerator) { +private fun GrantExpr.serializeExpr(gen: JsonGenerator) { val fieldData = when (val rawValue = this.`object`.expression.cast().value) { is Value.PermissionToken -> Value.PermissionToken::class.simpleName to rawValue.permissionToken is Value.Id -> RoleId::class.simpleName to rawValue.idBox.cast().roleId - else -> throw IrohaSdkException("Grant InstructionBox serialization error") + else -> throw IrohaSdkException("Grant InstructionExpr serialization error") } + gen.writeObjectFieldStart("object") gen.writeObjectField(fieldData.first, fieldData.second) + gen.writeEndObject() gen.writeObjectField("destination_id", this.destinationId) } -private fun SetKeyValueBox.serializeBox(gen: JsonGenerator) { +private fun SetKeyValueExpr.serializeExpr(gen: JsonGenerator) { val id = this.objectId.expression .cast().value .cast().idBox @@ -1056,13 +1054,13 @@ private fun mintBurnSerialize( .cast().value .cast().numericValue val fieldData = when (rawValue) { - is NumericValue.U32 -> NumericValue.U32::class.simpleName to rawValue.u32 - is NumericValue.U64 -> NumericValue.U64::class.simpleName to rawValue.u64 - is NumericValue.U128 -> NumericValue.U128::class.simpleName to rawValue.u128 - is NumericValue.Fixed -> NumericValue.Fixed::class.simpleName to rawValue.fixed.fixedPointOfI64 - else -> throw IrohaSdkException("Grant InstructionBox serialization error") + is NumericValue.U32 -> NumericValue.U32::class.simpleName to "${rawValue.u32}_${NumericValue.U32::class.simpleName?.lowercase()}" + is NumericValue.U64 -> NumericValue.U64::class.simpleName to "${rawValue.u64}_${NumericValue.U64::class.simpleName?.lowercase()}" + is NumericValue.U128 -> NumericValue.U128::class.simpleName to "${rawValue.u128}_${NumericValue.U128::class.simpleName?.lowercase()}" + is NumericValue.Fixed -> NumericValue.Fixed::class.simpleName to rawValue.fixed.fixedPointOfI64.toString() + else -> throw IrohaSdkException("Grant InstructionExpr serialization error") } - gen.writeObjectField(fieldData.first, fieldData.second) + gen.writeObjectField("object", fieldData.second) gen.writeObjectField("destination_id", destinationId) } diff --git a/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/SerializerTest.kt b/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/SerializerTest.kt new file mode 100644 index 000000000..1fdfd0ddb --- /dev/null +++ b/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/SerializerTest.kt @@ -0,0 +1,85 @@ +package jp.co.soramitsu.iroha2 + +import jp.co.soramitsu.iroha2.generated.AssetDefinitionId +import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.RawGenesisBlock +import jp.co.soramitsu.iroha2.transaction.Instructions +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class SerializerTest { + @Test + fun `should serialize grant permission token genesis block`() { + val genesis = Genesis( + RawGenesisBlock( + listOf( + Instructions.grantPermissionToken( + Permissions.CanUnregisterAccount, + "bob${ACCOUNT_ID_DELIMITER}wonderland".asAccountId().asJsonString(), + "alice${ACCOUNT_ID_DELIMITER}wonderland".asAccountId(), + ), + ).let { listOf(it) }, + Genesis.executorMode, + ), + ) + val expectedJson = """ + { + "block" : { + "transactions" : [ [ { + "Grant" : { + "object" : { + "PermissionToken" : { + "definition_id" : "CanUnregisterAccount", + "payload" : { + "account_id" : "bob@wonderland" + } + } + }, + "destination_id" : { + "AccountId" : "alice@wonderland" + } + } + } ] ], + "executor" : "executor.wasm" + } + } + """.trimIndent() + val json = JSON_SERDE.writeValueAsString(genesis).trimIndent() + assertEquals(expectedJson, json) + } + + @Test + fun `should serialize mint asset genesis block`() { + val genesis = Genesis( + RawGenesisBlock( + listOf( + Instructions.mintAsset( + AssetId( + AssetDefinitionId("xor".asName(), "wonderland".asDomainId()), + "alice${ACCOUNT_ID_DELIMITER}wonderland".asAccountId(), + ), + 100, + ), + ).let { listOf(it) }, + Genesis.executorMode, + ), + ) + val expectedJson = """ + { + "block" : { + "transactions" : [ [ { + "Mint" : { + "object" : "100_u32", + "destination_id" : { + "AssetId" : "xor#wonderland#alice@wonderland" + } + } + } ] ], + "executor" : "executor.wasm" + } + } + """.trimIndent() + val json = JSON_SERDE.writeValueAsString(genesis).trimIndent() + assertEquals(expectedJson, json) + } +} diff --git a/modules/block/src/test/resources/executor.wasm b/modules/block/src/test/resources/executor.wasm new file mode 100755 index 000000000..d0f406bf4 Binary files /dev/null and b/modules/block/src/test/resources/executor.wasm differ diff --git a/modules/block/src/test/resources/validator.wasm b/modules/block/src/test/resources/validator.wasm deleted file mode 100644 index 581371842..000000000 Binary files a/modules/block/src/test/resources/validator.wasm and /dev/null differ diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Enums.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Enums.kt index 626e10171..810fadc38 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Enums.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Enums.kt @@ -37,7 +37,7 @@ enum class Permissions(val type: Name) { CanExecuteUserTrigger("CanExecuteUserTrigger".asName()), CanUnregisterUserTrigger("CanUnregisterUserTrigger".asName()), CanMintUserTrigger("CanMintUserTrigger".asName()), - CanUpgradeValidator("CanUpgradeValidator".asName()), + CanUpgradeExecutor("CanUpgradeExecutor".asName()), } enum class IdKey(val type: String) { diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extensions.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extensions.kt index 644bc8ebd..cef877d96 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extensions.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extensions.kt @@ -7,8 +7,9 @@ import jp.co.soramitsu.iroha2.generated.Asset import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValue +import jp.co.soramitsu.iroha2.generated.BlockMessage +import jp.co.soramitsu.iroha2.generated.BlockPayload import jp.co.soramitsu.iroha2.generated.BlockSubscriptionRequest -import jp.co.soramitsu.iroha2.generated.CommittedBlock import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.EvaluatesTo import jp.co.soramitsu.iroha2.generated.Executable @@ -22,7 +23,7 @@ import jp.co.soramitsu.iroha2.generated.HashOf import jp.co.soramitsu.iroha2.generated.HashValue import jp.co.soramitsu.iroha2.generated.IdBox import jp.co.soramitsu.iroha2.generated.IdentifiableBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 @@ -35,23 +36,18 @@ import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.Signature import jp.co.soramitsu.iroha2.generated.SignatureOf import jp.co.soramitsu.iroha2.generated.SignaturesOfOfTransactionPayload +import jp.co.soramitsu.iroha2.generated.SignedBlock +import jp.co.soramitsu.iroha2.generated.SignedBlockV1 import jp.co.soramitsu.iroha2.generated.SignedTransaction +import jp.co.soramitsu.iroha2.generated.SignedTransactionV1 import jp.co.soramitsu.iroha2.generated.SocketAddr import jp.co.soramitsu.iroha2.generated.SocketAddrHost import jp.co.soramitsu.iroha2.generated.StringWithJson import jp.co.soramitsu.iroha2.generated.TransactionPayload -import jp.co.soramitsu.iroha2.generated.TriggerBox import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggerOfFilterBoxAndExecutable -import jp.co.soramitsu.iroha2.generated.TriggerOfFilterBoxAndOptimizedExecutable -import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBoxAndExecutable -import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBoxAndOptimizedExecutable +import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedBlockMessage -import jp.co.soramitsu.iroha2.generated.VersionedBlockSubscriptionRequest -import jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.transaction.TransactionBuilder import net.i2p.crypto.eddsa.EdDSAEngine import org.bouncycastle.jcajce.provider.digest.Blake2b @@ -67,16 +63,14 @@ import java.util.StringTokenizer import kotlin.experimental.or import jp.co.soramitsu.iroha2.generated.PublicKey as IrohaPublicKey -fun VersionedBlockSubscriptionRequest.V1.Companion.of(from: Long) = VersionedBlockSubscriptionRequest.V1( - BlockSubscriptionRequest(NonZeroOfu64(BigInteger.valueOf(from))), -) +fun BlockSubscriptionRequest.Companion.of(from: Long) = BlockSubscriptionRequest(NonZeroOfu64(BigInteger.valueOf(from))) fun Signature.asSignatureOf() = SignatureOf(this) fun String.asAccountId() = this.split(ACCOUNT_ID_DELIMITER).takeIf { it.size == 2 }?.let { parts -> - AccountId(parts[0].asName(), parts[1].asDomainId()) + AccountId(parts[1].asDomainId(), parts[0].asName()) } ?: throw IllegalArgumentException("Incorrect account ID: $this") fun String.asAssetDefinitionId() = this.split(ASSET_ID_DELIMITER).takeIf { @@ -202,8 +196,8 @@ fun ByteArray.hash(): ByteArray { /** * Hash the given versioned transaction (`VersionedTransaction.V1`) */ -fun VersionedSignedTransaction.V1.hash(): ByteArray { - return this.signedTransaction +fun SignedTransaction.V1.hash(): ByteArray { + return this.signedTransactionV1 .payload .let { TransactionPayload.encode(it) } .hash() @@ -212,17 +206,17 @@ fun VersionedSignedTransaction.V1.hash(): ByteArray { /** * Hash the given versioned transaction. Maintains only `VersionedTransaction.V1` */ -fun VersionedSignedTransaction.hash() = when (this) { - is VersionedSignedTransaction.V1 -> this.hash() +fun SignedTransaction.hash() = when (this) { + is SignedTransaction.V1 -> this.hash() } /** * Append signatures to a transaction. Maintains only `VersionedTransaction.V1` */ -fun VersionedSignedTransaction.appendSignatures(vararg keypairs: KeyPair): VersionedSignedTransaction { +fun SignedTransaction.appendSignatures(vararg keypairs: KeyPair): SignedTransaction { return when (this) { - is VersionedSignedTransaction.V1 -> { - val encodedPayload = signedTransaction + is SignedTransaction.V1 -> { + val encodedPayload = signedTransactionV1 .payload .let { TransactionPayload.encode(it) } val signatures = keypairs.map { @@ -232,10 +226,10 @@ fun VersionedSignedTransaction.appendSignatures(vararg keypairs: KeyPair): Versi ).asSignatureOf() }.toSet() - VersionedSignedTransaction.V1( - SignedTransaction( - signedTransaction.signatures.plus(signatures), - signedTransaction.payload, + SignedTransaction.V1( + SignedTransactionV1( + signedTransactionV1.signatures.plus(signatures), + signedTransactionV1.payload, ), ) } @@ -295,7 +289,7 @@ fun RegistrableBox.toIdentifiableBox() = when (this) { is RegistrableBox.AssetDefinition -> IdentifiableBox.NewAssetDefinition(this.newAssetDefinition) is RegistrableBox.Role -> IdentifiableBox.NewRole(this.newRole) is RegistrableBox.Domain -> IdentifiableBox.NewDomain(this.newDomain) - is RegistrableBox.Trigger -> IdentifiableBox.Trigger(TriggerBox.Raw(this.triggerOfTriggeringFilterBoxAndExecutable)) + is RegistrableBox.Trigger -> IdentifiableBox.Trigger(this.triggerOfTriggeringFilterBox) } inline fun T.asValue() = when (this) { @@ -352,15 +346,15 @@ fun Metadata.merge(extra: Metadata) = Metadata( this.map.toMutableMap().also { it.putAll(extra.map) }, ) -fun InstructionBox.Register.extractIdentifiableBox() = runCatching { - this.registerBox.`object`.expression +fun InstructionExpr.Register.extractIdentifiableBox() = runCatching { + this.registerExpr.`object`.expression .cast().value .cast().identifiableBox }.getOrNull() -fun Iterable.extractIdentifiableBoxes() = this.asSequence() - .filterIsInstance() - .map { it.registerBox.`object`.expression } +fun Iterable.extractIdentifiableBoxes() = this.asSequence() + .filterIsInstance() + .map { it.registerExpr.`object`.expression } .filterIsInstance() .map { it.value } .filterIsInstance() @@ -378,42 +372,42 @@ fun IdBox.extractId(): Any = when (this) { is IdBox.ParameterId -> this.parameterId } -fun InstructionBox.extractAccount() = this - .cast() - .registerBox.`object`.expression +fun InstructionExpr.extractAccount() = this + .cast() + .registerExpr.`object`.expression .cast().value .cast().identifiableBox .cast().newAccount -fun InstructionBox.Register.extractAccount() = this - .registerBox.`object`.expression +fun InstructionExpr.Register.extractAccount() = this + .registerExpr.`object`.expression .cast().value .cast().identifiableBox .cast().newAccount -fun InstructionBox.Register.extractDomain() = this - .registerBox.`object`.expression +fun InstructionExpr.Register.extractDomain() = this + .registerExpr.`object`.expression .cast().value .cast().identifiableBox .cast().newDomain -fun InstructionBox.Register.extractAssetDefinition() = this - .registerBox.`object`.expression +fun InstructionExpr.Register.extractAssetDefinition() = this + .registerExpr.`object`.expression .cast().value .cast().identifiableBox .cast().newAssetDefinition -fun InstructionBox.SetKeyValue.extractKey() = this - .setKeyValueBox.key.expression +fun InstructionExpr.SetKeyValue.extractKey() = this + .setKeyValueExpr.key.expression .cast().value .cast().name .string -fun InstructionBox.SetKeyValue.extractAccountId() = this.setKeyValueBox.objectId.extractAccountId() +fun InstructionExpr.SetKeyValue.extractAccountId() = this.setKeyValueExpr.objectId.extractAccountId() -fun InstructionBox.Unregister.extractAccountId() = this.unregisterBox.objectId.extractAccountId() +fun InstructionExpr.Unregister.extractAccountId() = this.unregisterExpr.objectId.extractAccountId() -fun InstructionBox.Unregister.extractDomainId() = this.unregisterBox.objectId.extractDomainId() +fun InstructionExpr.Unregister.extractDomainId() = this.unregisterExpr.objectId.extractDomainId() fun EvaluatesTo.extractAssetId() = this .expression @@ -433,8 +427,8 @@ fun EvaluatesTo.extractDomainId() = this .cast().idBox .cast().domainId -fun InstructionBox.Mint.extractPublicKey() = this - .mintBox.`object`.expression +fun InstructionExpr.Mint.extractPublicKey() = this + .mintExpr.`object`.expression .cast().value .cast().publicKey .payload.toHex() @@ -445,64 +439,64 @@ fun EvaluatesTo.extractNewAssetDefinition() = this .cast().identifiableBox .cast().newAssetDefinition -inline fun VersionedSignedTransaction.extractInstruction() = this - .cast() +inline fun SignedTransaction.extractInstruction() = this + .cast() .extractInstruction() -inline fun VersionedSignedTransaction.V1.extractInstruction() = this +inline fun SignedTransaction.V1.extractInstruction() = this .extractInstructionVec() .first().cast() -inline fun VersionedSignedTransaction.V1.extractInstructions() = this +inline fun SignedTransaction.V1.extractInstructions() = this .extractInstructionVec() .cast>() -inline fun VersionedSignedTransaction.V1.extractInstructionVec() = this - .signedTransaction.payload.instructions +inline fun SignedTransaction.V1.extractInstructionVec() = this + .signedTransactionV1.payload.instructions .cast() .vec.filterIsInstance() -fun InstructionBox.Register.extractNewDomainMetadata() = this - .registerBox.`object`.expression +fun InstructionExpr.Register.extractNewDomainMetadata() = this + .registerExpr.`object`.expression .cast().value .cast().identifiableBox .cast().newDomain.metadata -fun InstructionBox.SetKeyValue.extractDomainId() = this - .setKeyValueBox.objectId.expression +fun InstructionExpr.SetKeyValue.extractDomainId() = this + .setKeyValueExpr.objectId.expression .cast().value .cast().idBox .cast().domainId -fun InstructionBox.SetKeyValue.key() = this - .setKeyValueBox.key.expression +fun InstructionExpr.SetKeyValue.key() = this + .setKeyValueExpr.key.expression .cast().value .cast().name.string -fun InstructionBox.SetKeyValue.extractValueString() = this - .setKeyValueBox.value.expression +fun InstructionExpr.SetKeyValue.extractValueString() = this + .setKeyValueExpr.value.expression .cast().value .cast().string -fun InstructionBox.SetKeyValue.extractValueU32() = this.setKeyValueBox.value.extractValueU32() +fun InstructionExpr.SetKeyValue.extractValueU32() = this.setKeyValueExpr.value.extractValueU32() -fun InstructionBox.SetKeyValue.extractValueU128() = this - .setKeyValueBox.value.expression +fun InstructionExpr.SetKeyValue.extractValueU128() = this + .setKeyValueExpr.value.expression .cast().value .getValue().numericValue .getValue() -fun InstructionBox.SetKeyValue.extractValueBoolean() = this - .setKeyValueBox.value.expression +fun InstructionExpr.SetKeyValue.extractValueBoolean() = this + .setKeyValueExpr.value.expression .cast().value .cast().bool -fun InstructionBox.Grant.extractValuePermissionToken() = this - .grantBox.`object`.expression +fun InstructionExpr.Grant.extractValuePermissionToken() = this + .grantExpr.`object`.expression .cast().value .cast().permissionToken -fun InstructionBox.Burn.extractValueU32() = this.burnBox.`object`.extractValueU32() +fun InstructionExpr.Burn.extractValueU32() = this.burnExpr.`object`.extractValueU32() fun EvaluatesTo.extractValueU32() = this .expression @@ -510,17 +504,7 @@ fun EvaluatesTo.extractValueU32() = this .getValue().numericValue .getValue() -fun TriggerOfFilterBoxAndOptimizedExecutable.extractIsi() = this.action.executable.cast().vec - -fun TriggerOfFilterBoxAndExecutable.extractIsi() = this.action.executable.cast().vec - -fun TriggerOfTriggeringFilterBoxAndExecutable.extractSchedule() = this.action.filter.extractSchedule() - -fun TriggerOfTriggeringFilterBoxAndOptimizedExecutable.extractSchedule() = this.action.filter.extractSchedule() - -fun TriggerOfFilterBoxAndOptimizedExecutable.extractSchedule() = this.action.filter.extractSchedule() - -fun TriggerOfFilterBoxAndExecutable.extractSchedule() = this.action.filter.extractSchedule() +fun TriggerOfTriggeringFilterBox.extractSchedule() = this.action.filter.extractSchedule() fun TriggeringFilterBox.extractSchedule() = this .cast() @@ -532,18 +516,13 @@ fun FilterBox.extractSchedule() = this .timeEventFilter.executionTime .cast().schedule -fun TriggerBox.extractSchedule() = when (this) { - is TriggerBox.Raw -> this.triggerOfTriggeringFilterBoxAndExecutable.extractSchedule() - is TriggerBox.Optimized -> this.triggerOfTriggeringFilterBoxAndOptimizedExecutable.extractSchedule() -} - -fun VersionedBlockMessage.extractBlock() = this - .cast().blockMessage.versionedCommittedBlock +fun BlockMessage.extractBlock() = this + .cast().signedBlock.cast().signedBlockV1 .extractBlock() -fun VersionedCommittedBlock.extractBlock() = this.cast().committedBlock +fun SignedBlockV1.extractBlock() = this.cast().payload -fun CommittedBlock.height() = this.header.height +fun BlockPayload.height() = this.header.height fun Metadata.getStringValue(key: String) = this.map.getStringValue(key) @@ -605,11 +584,6 @@ fun Asset.metadata() = this.value.cast().metadata.map fun TransactionBuilder.merge(other: TransactionBuilder) = this.instructions.value.addAll(other.instructions.value) -fun TriggerBox.id() = when (this) { - is TriggerBox.Raw -> this.triggerOfTriggeringFilterBoxAndExecutable.id - is TriggerBox.Optimized -> this.triggerOfTriggeringFilterBoxAndOptimizedExecutable.id -} - fun String.toSocketAddr() = this.split(":").let { parts -> if (parts.size != 2) throw IrohaSdkException("Incorrect address") diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extractors.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extractors.kt index f95f2cb7b..82dd2a0b4 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extractors.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Extractors.kt @@ -14,25 +14,17 @@ import jp.co.soramitsu.iroha2.generated.PermissionToken import jp.co.soramitsu.iroha2.generated.PermissionTokenSchema import jp.co.soramitsu.iroha2.generated.Role import jp.co.soramitsu.iroha2.generated.RoleId +import jp.co.soramitsu.iroha2.generated.SignedBlock import jp.co.soramitsu.iroha2.generated.TransactionQueryOutput -import jp.co.soramitsu.iroha2.generated.TriggerBox import jp.co.soramitsu.iroha2.generated.TriggerId +import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedBatchedResponseOfValue -import jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock import java.math.BigInteger /** * Extractors are used by [QueryBuilder] to extract data from query results */ interface ResultExtractor { - fun extract(result: VersionedBatchedResponseOfValue): T { - return when (result) { - is VersionedBatchedResponseOfValue.V1 -> extract(result.batchedResponseOfValue) - else -> throw IrohaSdkException("Unexpected type ${result::class}") - } - } - fun extract(result: BatchedResponseOfValue): T } @@ -48,7 +40,7 @@ object AsIs : ResultExtractor { */ object AssetExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Asset { - return extractIdentifiable(result.batch, IdentifiableBox.Asset::asset) + return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Asset::asset) } } @@ -57,7 +49,7 @@ object AssetExtractor : ResultExtractor { */ object AssetDefinitionExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): AssetDefinition { - return extractIdentifiable(result.batch, IdentifiableBox.AssetDefinition::assetDefinition) + return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.AssetDefinition::assetDefinition) } } @@ -66,7 +58,7 @@ object AssetDefinitionExtractor : ResultExtractor { */ object AccountExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Account { - return extractIdentifiable(result.batch, IdentifiableBox.Account::account) + return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Account::account) } } @@ -75,7 +67,7 @@ object AccountExtractor : ResultExtractor { */ object AccountsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.Account::account) } } @@ -86,7 +78,7 @@ object AccountsExtractor : ResultExtractor> { */ object AssetsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.Asset::asset) } } @@ -97,7 +89,7 @@ object AssetsExtractor : ResultExtractor> { */ object AssetDefinitionsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.AssetDefinition::assetDefinition) } } @@ -108,7 +100,7 @@ object AssetDefinitionsExtractor : ResultExtractor> { */ object DomainExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Domain { - return extractIdentifiable(result.batch, IdentifiableBox.Domain::domain) + return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Domain::domain) } } @@ -117,7 +109,7 @@ object DomainExtractor : ResultExtractor { */ object DomainsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.Domain::domain) } } @@ -128,7 +120,7 @@ object DomainsExtractor : ResultExtractor> { */ object PeersExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.Peer::peer) } } @@ -137,19 +129,22 @@ object PeersExtractor : ResultExtractor> { /** * Extract a trigger from a query [result] */ -object TriggerBoxExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): TriggerBox { - return extractIdentifiable(result.batch, IdentifiableBox.Trigger::triggerBox) +object TriggerBoxExtractor : ResultExtractor { + override fun extract(result: BatchedResponseOfValue): TriggerOfTriggeringFilterBox { + return extractIdentifiable( + result.cast().batchedResponseV1OfValue.batch, + IdentifiableBox.Trigger::triggerOfTriggeringFilterBox, + ) } } /** * Extract a list of triggers from a query [result] */ -object TriggerBoxesExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { - extractIdentifiable(it, IdentifiableBox.Trigger::triggerBox) +object TriggerBoxesExtractor : ResultExtractor> { + override fun extract(result: BatchedResponseOfValue): List { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { + extractIdentifiable(it, IdentifiableBox.Trigger::triggerOfTriggeringFilterBox) } } } @@ -159,7 +154,7 @@ object TriggerBoxesExtractor : ResultExtractor> { */ object TriggerIdsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractValue(it, Value.Id::idBox).cast().triggerId } } @@ -170,7 +165,7 @@ object TriggerIdsExtractor : ResultExtractor> { */ object PermissionTokensExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractValue(it, Value.PermissionToken::permissionToken) } } @@ -181,7 +176,7 @@ object PermissionTokensExtractor : ResultExtractor> { */ object PermissionTokenSchemaExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): PermissionTokenSchema { - return extractValue(result.batch, Value.PermissionTokenSchema::permissionTokenSchema) + return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.PermissionTokenSchema::permissionTokenSchema) } } @@ -190,7 +185,7 @@ object PermissionTokenSchemaExtractor : ResultExtractor { */ object TransactionValuesExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractValue(it, Value.TransactionQueryOutput::transactionQueryOutput) } } @@ -201,21 +196,21 @@ object TransactionValuesExtractor : ResultExtractor */ object TransactionValueExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): TransactionQueryOutput { - return extractValue(result.batch, Value.TransactionQueryOutput::transactionQueryOutput) + return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.TransactionQueryOutput::transactionQueryOutput) } } -object BlocksValueExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { - extractValue(it, Value.Block::versionedCommittedBlock) +object BlocksValueExtractor : ResultExtractor> { + override fun extract(result: BatchedResponseOfValue): List { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { + extractValue(it, Value.Block::signedBlock) } } } object BlockHeadersExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractValue(it, Value.BlockHeader::blockHeader) } } @@ -223,7 +218,7 @@ object BlockHeadersExtractor : ResultExtractor> { object BlockHeaderExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): BlockHeader { - return extractValue(result.batch, Value.BlockHeader::blockHeader) + return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.BlockHeader::blockHeader) } } @@ -232,7 +227,7 @@ object BlockHeaderExtractor : ResultExtractor { */ object U32Extractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Long { - return extractValue(result.batch) { v: Value -> + return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> v.cast().numericValue.cast().u32 } } @@ -243,7 +238,7 @@ object U32Extractor : ResultExtractor { */ object U64Extractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): BigInteger { - return extractValue(result.batch) { v: Value -> + return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> v.cast().numericValue.cast().u64 } } @@ -254,7 +249,7 @@ object U64Extractor : ResultExtractor { */ object U128Extractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): BigInteger { - return extractValue(result.batch) { v: Value -> + return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> v.cast().numericValue.cast().u128 } } @@ -265,7 +260,7 @@ object U128Extractor : ResultExtractor { */ object ValueExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Value { - return result.batch + return result.cast().batchedResponseV1OfValue.batch } } @@ -274,7 +269,7 @@ object ValueExtractor : ResultExtractor { */ object RolesExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractIdentifiable(it, IdentifiableBox.Role::role) } } @@ -285,7 +280,7 @@ object RolesExtractor : ResultExtractor> { */ object RoleExtractor : ResultExtractor { override fun extract(result: BatchedResponseOfValue): Role { - return extractIdentifiable(result.batch, IdentifiableBox.Role::role) + return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Role::role) } } @@ -294,7 +289,7 @@ object RoleExtractor : ResultExtractor { */ object RoleIdsExtractor : ResultExtractor> { override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.batch) { + return extractVec(result.cast().batchedResponseV1OfValue.batch) { extractValue(it, Value.Id::idBox).cast().roleId } } diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2AsyncClient.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2AsyncClient.kt index 9b8c72389..9016c0fd3 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2AsyncClient.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2AsyncClient.kt @@ -1,6 +1,6 @@ package jp.co.soramitsu.iroha2.client -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.model.IrohaUrls import jp.co.soramitsu.iroha2.query.QueryAndExtractor import kotlinx.coroutines.future.asCompletableFuture @@ -34,7 +34,7 @@ class Iroha2AsyncClient @JvmOverloads constructor( * Send a transaction to an Iroha peer and wait until it is committed or rejected. */ fun sendTransactionAsync( - transaction: VersionedSignedTransaction, + transaction: SignedTransaction, ): CompletableFuture = runBlocking { sendTransaction { transaction }.asCompletableFuture() } @@ -46,7 +46,7 @@ class Iroha2AsyncClient @JvmOverloads constructor( * which means that the peer accepted the transaction and the transaction passed the stateless validation. */ fun fireAndForgetAsync( - transaction: VersionedSignedTransaction, + transaction: SignedTransaction, ): CompletableFuture = future { fireAndForget { transaction } } diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2Client.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2Client.kt index 3e9d69a62..f6b7dd0dc 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2Client.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/Iroha2Client.kt @@ -38,6 +38,8 @@ import jp.co.soramitsu.iroha2.client.blockstream.BlockStreamSubscription import jp.co.soramitsu.iroha2.extract import jp.co.soramitsu.iroha2.extractBlock import jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue +import jp.co.soramitsu.iroha2.generated.BatchedResponseV1OfValue +import jp.co.soramitsu.iroha2.generated.BlockMessage import jp.co.soramitsu.iroha2.generated.BlockRejectionReason import jp.co.soramitsu.iroha2.generated.Event import jp.co.soramitsu.iroha2.generated.EventMessage @@ -46,14 +48,10 @@ import jp.co.soramitsu.iroha2.generated.ForwardCursor import jp.co.soramitsu.iroha2.generated.PipelineEntityKind import jp.co.soramitsu.iroha2.generated.PipelineRejectionReason import jp.co.soramitsu.iroha2.generated.PipelineStatus +import jp.co.soramitsu.iroha2.generated.SignedQuery +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.TransactionRejectionReason import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedBatchedResponseOfValue -import jp.co.soramitsu.iroha2.generated.VersionedBlockMessage -import jp.co.soramitsu.iroha2.generated.VersionedEventMessage -import jp.co.soramitsu.iroha2.generated.VersionedEventSubscriptionRequest -import jp.co.soramitsu.iroha2.generated.VersionedSignedQuery -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.hash import jp.co.soramitsu.iroha2.height import jp.co.soramitsu.iroha2.model.IrohaUrls @@ -196,17 +194,20 @@ open class Iroha2Client( ): T { logger.debug("Sending query") val responseDecoded = sendQueryRequest(queryAndExtractor, start, limit, sorting) - val cursor = responseDecoded.cast().batchedResponseOfValue.cursor + val cursor = responseDecoded.cast().batchedResponseV1OfValue.cursor val finalResult = when (cursor.cursor) { null -> responseDecoded.let { queryAndExtractor.resultExtractor.extract(it) } else -> { val resultList = getQueryResultWithCursor(queryAndExtractor, start, limit, sorting, cursor) resultList.addAll( - responseDecoded.cast() - .batchedResponseOfValue.batch.cast().vec, + responseDecoded.cast() + .batchedResponseV1OfValue.batch.cast().vec, ) - VersionedBatchedResponseOfValue.V1( - BatchedResponseOfValue(Value.Vec(resultList), ForwardCursor()), + BatchedResponseOfValue.V1( + BatchedResponseV1OfValue( + Value.Vec(resultList), + ForwardCursor(), + ), ).let { queryAndExtractor.resultExtractor.extract(it) } } } @@ -219,9 +220,9 @@ open class Iroha2Client( limit: Long? = null, sorting: String? = null, queryCursor: ForwardCursor? = null, - ): VersionedBatchedResponseOfValue { + ): BatchedResponseOfValue { val response: HttpResponse = client.post("${getApiUrl()}$QUERY_ENDPOINT") { - setBody(VersionedSignedQuery.encode(queryAndExtractor.query)) + setBody(SignedQuery.encode(queryAndExtractor.query)) start?.also { parameter("start", it) } limit?.also { parameter("limit", it) } sorting?.also { parameter("sort_by_metadata_key", it) } @@ -229,7 +230,7 @@ open class Iroha2Client( queryCursor?.cursor?.u64?.also { parameter("cursor", it) } } return response.body() - .let { VersionedBatchedResponseOfValue.decode(it) } + .let { BatchedResponseOfValue.decode(it) } } private suspend fun getQueryResultWithCursor( @@ -241,8 +242,8 @@ open class Iroha2Client( ): MutableList { val resultList = mutableListOf() val responseDecoded = sendQueryRequest(queryAndExtractor, start, limit, sorting, queryCursor) - resultList.addAll(responseDecoded.cast().batchedResponseOfValue.batch.cast().vec) - val cursor = responseDecoded.cast().batchedResponseOfValue.cursor + resultList.addAll(responseDecoded.cast().batchedResponseV1OfValue.batch.cast().vec) + val cursor = responseDecoded.cast().batchedResponseV1OfValue.cursor return when (cursor.cursor) { null -> resultList else -> { @@ -258,12 +259,12 @@ open class Iroha2Client( * With this method, the state of the transaction is not tracked after the peer responses with 2xx status code, * which means that the peer accepted the transaction and the transaction passed the stateless validation. */ - suspend fun fireAndForget(transaction: TransactionBuilder.() -> VersionedSignedTransaction): ByteArray { + suspend fun fireAndForget(transaction: TransactionBuilder.() -> SignedTransaction): ByteArray { val signedTransaction = transaction(TransactionBuilder.builder()) val hash = signedTransaction.hash() logger.debug("Sending transaction with hash {}", hash.toHex()) val response: HttpResponse = client.post("${getApiUrl()}$TRANSACTION_ENDPOINT") { - setBody(VersionedSignedTransaction.encode(signedTransaction)) + setBody(SignedTransaction.encode(signedTransaction)) } response.body() return hash @@ -273,7 +274,7 @@ open class Iroha2Client( * Send a transaction to an Iroha peer and wait until it is committed or rejected. */ suspend fun sendTransaction( - transaction: TransactionBuilder.() -> VersionedSignedTransaction, + transaction: TransactionBuilder.() -> SignedTransaction, ): CompletableDeferred = coroutineScope { val signedTransaction = transaction(TransactionBuilder()) @@ -313,11 +314,11 @@ open class Iroha2Client( @JvmOverloads fun subscribeToBlockStream( from: Long = 1, - onBlock: (block: VersionedBlockMessage) -> Any, + onBlock: (block: BlockMessage) -> Any, onFailure: suspend (t: Throwable) -> Unit = { throwable -> logger.error("Block stream was closed with an exception: {}", throwable.message) }, - cancelIf: suspend (block: VersionedBlockMessage) -> Boolean = { false }, + cancelIf: suspend (block: BlockMessage) -> Boolean = { false }, onClose: () -> Unit = { logger.info("Block stream subscription execution was finished") }, autoStart: Boolean = true, ): Pair, BlockStreamSubscription> = subscribeToBlockStream( @@ -378,7 +379,7 @@ open class Iroha2Client( logger.debug("Creating subscription to transaction status: {}", hexHash) val subscriptionRequest = eventSubscriberMessageOf(hash) - val payload = VersionedEventSubscriptionRequest.encode(subscriptionRequest) + val payload = EventSubscriptionRequest.encode(subscriptionRequest) val result: CompletableDeferred = CompletableDeferred() val apiUrl = getApiUrl() @@ -459,10 +460,6 @@ open class Iroha2Client( val details = reason.instructionExecutionFail "Failed: `${details.reason}` during execution of instruction: ${details.instruction::class.qualifiedName}" } - - is TransactionRejectionReason.UnexpectedGenesisAccountSignature -> - "Genesis account can sign only transactions in the genesis block" - is TransactionRejectionReason.WasmExecution -> reason.wasmExecutionFail.reason is TransactionRejectionReason.LimitCheck -> reason.transactionLimitError.reason is TransactionRejectionReason.Expired -> reason.toString() @@ -476,12 +473,7 @@ open class Iroha2Client( */ private fun readMessage(frame: Frame): EventMessage = when (frame) { is Frame.Binary -> { - when (val versionedMessage = frame.readBytes().let { VersionedEventMessage.decode(it) }) { - is VersionedEventMessage.V1 -> versionedMessage.eventMessage - else -> throw WebSocketProtocolException( - "Expected `${VersionedEventSubscriptionRequest.V1::class.qualifiedName}`, but was `${versionedMessage::class.qualifiedName}`", - ) - } + frame.readBytes().let { EventMessage.decode(it) } } else -> throw WebSocketProtocolException( @@ -492,10 +484,8 @@ open class Iroha2Client( private fun eventSubscriberMessageOf( hash: ByteArray, entityKind: PipelineEntityKind = PipelineEntityKind.Transaction(), - ) = VersionedEventSubscriptionRequest.V1( - EventSubscriptionRequest( - Filters.pipeline(entityKind, null, hash), - ), + ) = EventSubscriptionRequest( + Filters.pipeline(entityKind, null, hash), ) object DurationDeserializer : JsonDeserializer() { diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamStorage.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamStorage.kt index 886771979..cdf9abf9c 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamStorage.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamStorage.kt @@ -1,12 +1,12 @@ package jp.co.soramitsu.iroha2.client.blockstream -import jp.co.soramitsu.iroha2.generated.VersionedBlockMessage +import jp.co.soramitsu.iroha2.generated.BlockMessage import kotlinx.coroutines.channels.Channel import java.util.UUID data class BlockStreamStorage( - val onBlock: (block: VersionedBlockMessage) -> Any, - val cancelIf: (suspend (block: VersionedBlockMessage) -> Boolean)? = null, + val onBlock: (block: BlockMessage) -> Any, + val cancelIf: (suspend (block: BlockMessage) -> Boolean)? = null, val onFailure: (suspend (t: Throwable) -> Unit)? = null, ) { val channel = lazy { Channel() } diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamSubscription.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamSubscription.kt index 1e19f769f..31054f26d 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamSubscription.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/blockstream/BlockStreamSubscription.kt @@ -7,10 +7,9 @@ import jp.co.soramitsu.iroha2.IrohaSdkException import jp.co.soramitsu.iroha2.SingletonHolder import jp.co.soramitsu.iroha2.cast import jp.co.soramitsu.iroha2.client.Iroha2Client +import jp.co.soramitsu.iroha2.generated.BlockMessage import jp.co.soramitsu.iroha2.generated.BlockSubscriptionRequest import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 -import jp.co.soramitsu.iroha2.generated.VersionedBlockMessage -import jp.co.soramitsu.iroha2.generated.VersionedBlockSubscriptionRequest import jp.co.soramitsu.iroha2.toFrame import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope @@ -101,11 +100,9 @@ open class BlockStreamSubscription private constructor( @OptIn(DelicateCoroutinesApi::class) private fun run() = launch { - val request = VersionedBlockSubscriptionRequest.V1( - BlockSubscriptionRequest( - NonZeroOfu64( - BigInteger.valueOf(context.from), - ), + val request = BlockSubscriptionRequest( + NonZeroOfu64( + BigInteger.valueOf(context.from), ), ) @@ -116,13 +113,13 @@ open class BlockStreamSubscription private constructor( ) { try { logger.debug("WebSocket opened") - send(VersionedBlockSubscriptionRequest.encode(request).toFrame()) + send(BlockSubscriptionRequest.encode(request).toFrame()) val idsToRemove = mutableListOf() for (frame in incoming) { logger.debug("Received frame: {}", frame) - val block = VersionedBlockMessage.decode(frame.readBytes()) + val block = BlockMessage.decode(frame.readBytes()) source.forEach { (id, storage) -> logger.debug("Executing {} action", id) val result = storage.onBlock(block) diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/Queries.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/Queries.kt index 44c806e27..0e2122bea 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/Queries.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/Queries.kt @@ -50,9 +50,9 @@ import jp.co.soramitsu.iroha2.generated.HashOf import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.QueryBox import jp.co.soramitsu.iroha2.generated.RoleId +import jp.co.soramitsu.iroha2.generated.SignedBlock +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction /** * Queries are sent to an Iroha peer and prompt a response with details from the current world state view. @@ -233,7 +233,7 @@ object Queries { * Return the transaction by [Hash] */ fun findTransactionByHash(hash: Hash) = QueryBox.FindTransactionByHash( - FindTransactionByHash(HashOf(hash).evaluatesTo()), + FindTransactionByHash(HashOf(hash).evaluatesTo()), ) /** @@ -301,7 +301,7 @@ object Queries { * Return the block header corresponding to the given [Hash] */ fun findBlockHeaderByHash(hash: Hash) = QueryBox.FindBlockHeaderByHash( - FindBlockHeaderByHash(HashOf(hash).evaluatesTo()), + FindBlockHeaderByHash(HashOf(hash).evaluatesTo()), ) /** diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/QueryBuilder.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/QueryBuilder.kt index 4aa8ac1e6..49c6d9915 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/QueryBuilder.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/query/QueryBuilder.kt @@ -40,9 +40,9 @@ import jp.co.soramitsu.iroha2.generated.QueryPayload import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.Signature import jp.co.soramitsu.iroha2.generated.SignedQuery +import jp.co.soramitsu.iroha2.generated.SignedQueryV1 import jp.co.soramitsu.iroha2.generated.TriggerId import jp.co.soramitsu.iroha2.generated.ValuePredicate -import jp.co.soramitsu.iroha2.generated.VersionedSignedQuery import jp.co.soramitsu.iroha2.hash import jp.co.soramitsu.iroha2.sign import jp.co.soramitsu.iroha2.toIrohaHash @@ -62,7 +62,7 @@ class QueryBuilder( fun account(accountId: AccountId) = this.apply { this.accountId = accountId } - fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(accountName, domainId)) + fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(domainId, accountName)) fun creationTime(creationTimeMillis: BigInteger) = this.apply { this.creationTimeMillis = creationTimeMillis } @@ -77,7 +77,7 @@ class QueryBuilder( val encodedPayload = QueryPayload.encode(payload) val signature = Signature(keyPair.public.toIrohaPublicKey(), keyPair.private.sign(encodedPayload)) - val query = VersionedSignedQuery.V1(SignedQuery(signature.asSignatureOf(), payload)) + val query = SignedQuery.V1(SignedQueryV1(signature.asSignatureOf(), payload)) return QueryAndExtractor(query, resultExtractor) } @@ -431,4 +431,4 @@ class QueryBuilder( * * [R] is a type of extracted value as a result of query execution */ -class QueryAndExtractor(val query: VersionedSignedQuery, val resultExtractor: ResultExtractor) +class QueryAndExtractor(val query: SignedQuery, val resultExtractor: ResultExtractor) diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Instructions.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Instructions.kt index 91d270f6c..37b4f0f8f 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Instructions.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Instructions.kt @@ -8,51 +8,51 @@ import jp.co.soramitsu.iroha2.asValue import jp.co.soramitsu.iroha2.cast import jp.co.soramitsu.iroha2.evaluatesTo import jp.co.soramitsu.iroha2.generated.AccountId -import jp.co.soramitsu.iroha2.generated.ActionOfTriggeringFilterBoxAndExecutable +import jp.co.soramitsu.iroha2.generated.ActionOfTriggeringFilterBox import jp.co.soramitsu.iroha2.generated.Algorithm import jp.co.soramitsu.iroha2.generated.Asset import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValue import jp.co.soramitsu.iroha2.generated.AssetValueType -import jp.co.soramitsu.iroha2.generated.BurnBox -import jp.co.soramitsu.iroha2.generated.Conditional +import jp.co.soramitsu.iroha2.generated.BurnExpr +import jp.co.soramitsu.iroha2.generated.ConditionalExpr import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.Executable -import jp.co.soramitsu.iroha2.generated.ExecuteTriggerBox -import jp.co.soramitsu.iroha2.generated.FailBox -import jp.co.soramitsu.iroha2.generated.GrantBox +import jp.co.soramitsu.iroha2.generated.ExecuteTriggerExpr +import jp.co.soramitsu.iroha2.generated.Fail +import jp.co.soramitsu.iroha2.generated.GrantExpr import jp.co.soramitsu.iroha2.generated.IdBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.IpfsPath import jp.co.soramitsu.iroha2.generated.Metadata -import jp.co.soramitsu.iroha2.generated.MintBox +import jp.co.soramitsu.iroha2.generated.MintExpr import jp.co.soramitsu.iroha2.generated.Mintable import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.NewAccount import jp.co.soramitsu.iroha2.generated.NewAssetDefinition import jp.co.soramitsu.iroha2.generated.NewDomain import jp.co.soramitsu.iroha2.generated.NewRole -import jp.co.soramitsu.iroha2.generated.Pair +import jp.co.soramitsu.iroha2.generated.PairExpr import jp.co.soramitsu.iroha2.generated.Peer import jp.co.soramitsu.iroha2.generated.PeerId import jp.co.soramitsu.iroha2.generated.PermissionToken import jp.co.soramitsu.iroha2.generated.PublicKey -import jp.co.soramitsu.iroha2.generated.RegisterBox +import jp.co.soramitsu.iroha2.generated.RegisterExpr import jp.co.soramitsu.iroha2.generated.RegistrableBox -import jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox +import jp.co.soramitsu.iroha2.generated.RemoveKeyValueExpr import jp.co.soramitsu.iroha2.generated.Repeats -import jp.co.soramitsu.iroha2.generated.RevokeBox +import jp.co.soramitsu.iroha2.generated.RevokeExpr import jp.co.soramitsu.iroha2.generated.Role import jp.co.soramitsu.iroha2.generated.RoleId -import jp.co.soramitsu.iroha2.generated.SequenceBox -import jp.co.soramitsu.iroha2.generated.SetKeyValueBox +import jp.co.soramitsu.iroha2.generated.SequenceExpr +import jp.co.soramitsu.iroha2.generated.SetKeyValueExpr import jp.co.soramitsu.iroha2.generated.TimeEventFilter -import jp.co.soramitsu.iroha2.generated.TransferBox +import jp.co.soramitsu.iroha2.generated.TransferExpr import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBoxAndExecutable +import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox -import jp.co.soramitsu.iroha2.generated.UnregisterBox +import jp.co.soramitsu.iroha2.generated.UnregisterExpr import jp.co.soramitsu.iroha2.generated.Value import jp.co.soramitsu.iroha2.generated.WasmSmartContract import jp.co.soramitsu.iroha2.toSocketAddr @@ -91,16 +91,16 @@ object Instructions { */ fun registerTimeTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, filter: TimeEventFilter, metadata: Metadata, ) = registerSome { RegistrableBox.Trigger( - TriggerOfTriggeringFilterBoxAndExecutable( + TriggerOfTriggeringFilterBox( triggerId, - ActionOfTriggeringFilterBoxAndExecutable( + ActionOfTriggeringFilterBox( Executable.Instructions(isi), repeats, accountId, @@ -116,15 +116,15 @@ object Instructions { */ fun registerExecutableTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata, ) = registerSome { RegistrableBox.Trigger( - TriggerOfTriggeringFilterBoxAndExecutable( + TriggerOfTriggeringFilterBox( triggerId, - ActionOfTriggeringFilterBoxAndExecutable( + ActionOfTriggeringFilterBox( Executable.Instructions(isi), repeats, accountId, @@ -140,16 +140,16 @@ object Instructions { */ fun registerEventTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata, filter: TriggeringFilterBox, ) = registerSome { RegistrableBox.Trigger( - TriggerOfTriggeringFilterBoxAndExecutable( + TriggerOfTriggeringFilterBox( triggerId, - ActionOfTriggeringFilterBoxAndExecutable( + ActionOfTriggeringFilterBox( Executable.Instructions(isi), repeats, accountId, @@ -172,9 +172,9 @@ object Instructions { filter: TriggeringFilterBox, ) = registerSome { RegistrableBox.Trigger( - TriggerOfTriggeringFilterBoxAndExecutable( + TriggerOfTriggeringFilterBox( triggerId, - ActionOfTriggeringFilterBoxAndExecutable( + ActionOfTriggeringFilterBox( Executable.Wasm(WasmSmartContract(wasm)), repeats, accountId, @@ -190,15 +190,15 @@ object Instructions { */ fun registerPreCommitTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata, ) = registerSome { RegistrableBox.Trigger( - TriggerOfTriggeringFilterBoxAndExecutable( + TriggerOfTriggeringFilterBox( triggerId, - ActionOfTriggeringFilterBoxAndExecutable( + ActionOfTriggeringFilterBox( Executable.Instructions(isi), repeats, accountId, @@ -221,7 +221,7 @@ object Instructions { triggerName: String, domainId: DomainId? = null, ) = unregisterSome { - IdBox.TriggerId(TriggerId(triggerName.asName(), domainId)) + IdBox.TriggerId(TriggerId(domainId, triggerName.asName())) } /** @@ -308,8 +308,8 @@ object Instructions { assetId: AssetId, key: Name, value: Value, - ) = InstructionBox.SetKeyValue( - SetKeyValueBox( + ) = InstructionExpr.SetKeyValue( + SetKeyValueExpr( objectId = IdBox.AssetId(assetId).evaluatesTo(), key = key.evaluatesTo(), value = value.evaluatesTo(), @@ -323,8 +323,8 @@ object Instructions { definitionId: AssetDefinitionId, key: Name, value: Value, - ) = InstructionBox.SetKeyValue( - SetKeyValueBox( + ) = InstructionExpr.SetKeyValue( + SetKeyValueExpr( objectId = IdBox.AssetDefinitionId(definitionId).evaluatesTo(), key = key.evaluatesTo(), value = value.evaluatesTo(), @@ -338,8 +338,8 @@ object Instructions { accountId: AccountId, key: Name, value: Value, - ) = InstructionBox.SetKeyValue( - SetKeyValueBox( + ) = InstructionExpr.SetKeyValue( + SetKeyValueExpr( objectId = IdBox.AccountId(accountId).evaluatesTo(), key = key.evaluatesTo(), value = value.evaluatesTo(), @@ -349,8 +349,8 @@ object Instructions { /** * Remove key/value from a given asset */ - fun removeKeyValue(assetId: AssetId, key: Name) = InstructionBox.RemoveKeyValue( - RemoveKeyValueBox( + fun removeKeyValue(assetId: AssetId, key: Name) = InstructionExpr.RemoveKeyValue( + RemoveKeyValueExpr( objectId = IdBox.AssetId(assetId).evaluatesTo(), key = key.evaluatesTo(), ), @@ -363,8 +363,8 @@ object Instructions { domainId: DomainId, key: Name, value: Value, - ) = InstructionBox.SetKeyValue( - SetKeyValueBox( + ) = InstructionExpr.SetKeyValue( + SetKeyValueExpr( objectId = IdBox.DomainId(domainId).evaluatesTo(), key = key.evaluatesTo(), value = value.evaluatesTo(), @@ -374,7 +374,7 @@ object Instructions { /** * Execute a trigger */ - fun executeTrigger(triggerId: TriggerId) = InstructionBox.ExecuteTrigger(ExecuteTriggerBox(triggerId.evaluatesTo())) + fun executeTrigger(triggerId: TriggerId) = InstructionExpr.ExecuteTrigger(ExecuteTriggerExpr(triggerId.evaluatesTo())) /** * Mint an asset of the [AssetValueType.Quantity] asset value type @@ -421,13 +421,13 @@ object Instructions { permission: Permissions, payload: String, target: AccountId, - ) = grantSome(IdBox.AccountId(target), PermissionToken(permission.type, payload.asStringWithJson()).asValue()) + ) = grantSome(target, PermissionToken(permission.type, payload.asStringWithJson()).asValue()) /** * Grant an account a given role. */ - fun grantRole(roleId: RoleId, accountId: AccountId) = InstructionBox.Grant( - GrantBox( + fun grantRole(roleId: RoleId, accountId: AccountId) = InstructionExpr.Grant( + GrantExpr( destinationId = accountId.evaluatesTo().cast(), `object` = IdBox.RoleId(roleId).evaluatesTo().cast(), ), @@ -436,8 +436,8 @@ object Instructions { /** * Transfer an asset from the identifiable source. */ - fun transferAsset(sourceId: AssetId, value: Int, destinationId: AccountId) = InstructionBox.Transfer( - TransferBox( + fun transferAsset(sourceId: AssetId, value: Int, destinationId: AccountId) = InstructionExpr.Transfer( + TransferExpr( sourceId = IdBox.AssetId(sourceId).evaluatesTo(), `object` = value.asValue().evaluatesTo(), destinationId = IdBox.AccountId(destinationId).evaluatesTo(), @@ -448,8 +448,8 @@ object Instructions { * Transfer domain ownership. */ fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = - InstructionBox.Transfer( - TransferBox( + InstructionExpr.Transfer( + TransferExpr( sourceId = IdBox.AccountId(sourceId).evaluatesTo(), `object` = Value.Id(value).evaluatesTo(), destinationId = IdBox.AccountId(destinationId).evaluatesTo(), @@ -461,30 +461,30 @@ object Instructions { */ fun `if`( condition: Boolean, - then: InstructionBox, - otherwise: InstructionBox, - ) = InstructionBox.If(Conditional(condition.evaluatesTo(), then, otherwise)) + then: InstructionExpr, + otherwise: InstructionExpr, + ) = InstructionExpr.If(ConditionalExpr(condition.evaluatesTo(), then, otherwise)) /** - * Pair two instructions together. + * PairExpr two instructions together. */ - fun pair(left: InstructionBox, right: InstructionBox) = InstructionBox.Pair(Pair(left, right)) + fun pair(left: InstructionExpr, right: InstructionExpr) = InstructionExpr.Pair(PairExpr(left, right)) /** * Combine multiple [instructions] into a sequence. */ - fun sequence(instructions: List) = InstructionBox.Sequence(SequenceBox(instructions)) + fun sequence(instructions: List) = InstructionExpr.Sequence(SequenceExpr(instructions)) /** * Fail a transaction with a given [message]. */ - fun fail(message: String) = InstructionBox.Fail(FailBox(message)) + fun fail(message: String) = InstructionExpr.Fail(Fail(message)) /** * Revoke an account the [Permissions.CanSetKeyValueUserAssetsToken] permission */ - fun revokeSetKeyValueAsset(assetId: AssetId, target: AccountId): InstructionBox { - return revokeSome(IdBox.AccountId(target)) { + fun revokeSetKeyValueAsset(assetId: AssetId, target: AccountId): InstructionExpr { + return revokeSome(target) { PermissionToken( definitionId = Permissions.CanSetKeyValueUserAssetsToken.type, payload = assetId.asJsonString().asStringWithJson(), @@ -495,8 +495,8 @@ object Instructions { /** * Revoke an account the [Permissions.CanSetKeyValueInUserAccount] permission */ - fun revokeSetKeyValueAccount(accountId: AccountId, target: AccountId): InstructionBox { - return revokeSome(IdBox.AccountId(target)) { + fun revokeSetKeyValueAccount(accountId: AccountId, target: AccountId): InstructionExpr { + return revokeSome(target) { PermissionToken( definitionId = Permissions.CanSetKeyValueInUserAccount.type, payload = accountId.asJsonString().asStringWithJson(), @@ -507,8 +507,8 @@ object Instructions { /** * Revoke an account the [Permissions.CanSetKeyValueInDomain] permission */ - fun revokeSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionBox { - return revokeSome(IdBox.AccountId(target)) { + fun revokeSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionExpr { + return revokeSome(target) { PermissionToken( definitionId = Permissions.CanSetKeyValueInDomain.type, payload = domainId.asJsonString().asStringWithJson(), @@ -519,55 +519,55 @@ object Instructions { /** * Revoke an account a given role. */ - fun revokeRole(roleId: RoleId, accountId: AccountId): InstructionBox { - return InstructionBox.Revoke( - RevokeBox( + fun revokeRole(roleId: RoleId, accountId: AccountId): InstructionExpr { + return InstructionExpr.Revoke( + RevokeExpr( destinationId = accountId.evaluatesTo().cast(), `object` = IdBox.RoleId(roleId).evaluatesTo().cast(), ), ) } - private inline fun unregisterSome(idBox: () -> IdBox) = InstructionBox.Unregister( - UnregisterBox(idBox().evaluatesTo()), + private inline fun unregisterSome(idBox: () -> IdBox) = InstructionExpr.Unregister( + UnregisterExpr(idBox().evaluatesTo()), ) private inline fun registerSome( regBox: () -> RegistrableBox, - ) = InstructionBox.Register(RegisterBox(regBox().evaluatesTo())) + ) = InstructionExpr.Register(RegisterExpr(regBox().evaluatesTo())) - private fun grantSome(idBox: IdBox, value: Value) = InstructionBox.Grant( - GrantBox( + private fun grantSome(accountId: AccountId, value: Value) = InstructionExpr.Grant( + GrantExpr( `object` = value.evaluatesTo(), - destinationId = idBox.evaluatesTo(), + destinationId = accountId.evaluatesTo(), ), ) - private inline fun revokeSome(idBox: IdBox, permissionToken: () -> PermissionToken): InstructionBox.Revoke { - return InstructionBox.Revoke( - RevokeBox( - destinationId = idBox.evaluatesTo(), + private inline fun revokeSome(accountId: AccountId, permissionToken: () -> PermissionToken): InstructionExpr.Revoke { + return InstructionExpr.Revoke( + RevokeExpr( + destinationId = accountId.evaluatesTo(), `object` = Value.PermissionToken(permissionToken()).evaluatesTo(), ), ) } - private fun burnSome(value: Value, idBox: IdBox) = InstructionBox.Burn( - BurnBox( + private fun burnSome(value: Value, idBox: IdBox) = InstructionExpr.Burn( + BurnExpr( `object` = value.evaluatesTo(), destinationId = idBox.evaluatesTo(), ), ) - private fun mintSome(value: Value, idBox: IdBox) = InstructionBox.Mint( - MintBox( + private fun mintSome(value: Value, idBox: IdBox) = InstructionExpr.Mint( + MintExpr( `object` = value.evaluatesTo(), destinationId = idBox.evaluatesTo(), ), ) - private fun mintSome(value: Value, assetId: AssetId) = InstructionBox.Mint( - MintBox( + private fun mintSome(value: Value, assetId: AssetId) = InstructionExpr.Mint( + MintExpr( `object` = value.evaluatesTo(), destinationId = IdBox.AssetId(assetId).evaluatesTo(), ), diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/TransactionBuilder.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/TransactionBuilder.kt index 0de9d58cf..b3890cc34 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/TransactionBuilder.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/TransactionBuilder.kt @@ -14,7 +14,7 @@ import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.Executable import jp.co.soramitsu.iroha2.generated.IdBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.IpfsPath import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Mintable @@ -28,12 +28,12 @@ import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.Signature import jp.co.soramitsu.iroha2.generated.SignaturesOfOfTransactionPayload import jp.co.soramitsu.iroha2.generated.SignedTransaction +import jp.co.soramitsu.iroha2.generated.SignedTransactionV1 import jp.co.soramitsu.iroha2.generated.TimeEventFilter import jp.co.soramitsu.iroha2.generated.TransactionPayload import jp.co.soramitsu.iroha2.generated.TriggerId import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.sign import jp.co.soramitsu.iroha2.toIrohaPublicKey import java.math.BigDecimal @@ -47,7 +47,7 @@ import kotlin.random.nextLong class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { var accountId: AccountId? - val instructions: Lazy> + val instructions: Lazy> var creationTimeMillis: BigInteger? var timeToLiveMillis: BigInteger? var nonce: Long? @@ -65,14 +65,14 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun account(accountId: AccountId) = this.apply { this.accountId = accountId } - fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(accountName, domainId)) + fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(domainId, accountName)) - fun instructions(vararg instructions: InstructionBox) = this.apply { this.instructions.value.addAll(instructions) } + fun instructions(vararg instructions: InstructionExpr) = this.apply { this.instructions.value.addAll(instructions) } - fun instructions(instructions: Iterable) = + fun instructions(instructions: Iterable) = this.apply { this.instructions.value.addAll(instructions) } - fun instruction(instruction: InstructionBox) = this.apply { this.instructions.value.add(instruction) } + fun instruction(instruction: InstructionExpr) = this.apply { this.instructions.value.add(instruction) } fun creationTime(creationTimeMillis: BigInteger) = this.apply { this.creationTimeMillis = creationTimeMillis } @@ -86,7 +86,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun timeToLive(ttlMillis: Long) = this.apply { this.timeToLive(ttlMillis.toBigInteger()) } - fun buildSigned(vararg keyPairs: KeyPair): VersionedSignedTransaction { + fun buildSigned(vararg keyPairs: KeyPair): SignedTransaction { val payload = TransactionPayload( creationTimeMillis ?: fallbackCreationTime(), checkNotNull(accountId) { "Account Id of the sender is mandatory" }, @@ -104,15 +104,15 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { ).asSignatureOf() }.toList() - return VersionedSignedTransaction.V1( - SignedTransaction(SignaturesOfOfTransactionPayload(signatures), payload), + return SignedTransaction.V1( + SignedTransactionV1(SignaturesOfOfTransactionPayload(signatures), payload), ) } @JvmOverloads fun registerTimeTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, filter: TimeEventFilter, @@ -133,7 +133,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerExecutableTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), @@ -152,7 +152,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerEventTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), @@ -194,7 +194,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerPreCommitTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), @@ -394,19 +394,19 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { instructions.value.add(Instructions.transferAsset(sourceId, value, destinationId)) } - fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = this.apply { - instructions.value.add(Instructions.transferDomainOwnership(sourceId, value, destinationId)) + fun `if`(condition: Boolean, then: InstructionExpr, otherwise: InstructionExpr) = this.apply { + instructions.value.add(Instructions.`if`(condition, then, otherwise)) } - fun `if`(condition: Boolean, then: InstructionBox, otherwise: InstructionBox) = this.apply { - instructions.value.add(Instructions.`if`(condition, then, otherwise)) + fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = this.apply { + instructions.value.add(Instructions.transferDomainOwnership(sourceId, value, destinationId)) } - fun pair(left: InstructionBox, right: InstructionBox) = this.apply { + fun pair(left: InstructionExpr, right: InstructionExpr) = this.apply { instructions.value.add(Instructions.pair(left, right)) } - fun sequence(vararg instructions: InstructionBox) = this.apply { + fun sequence(vararg instructions: InstructionExpr) = this.apply { this.instructions.value.add(Instructions.sequence(instructions.toList())) } diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml b/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml index 4c0421da9..64f8753c9 100644 --- a/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml +++ b/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml @@ -22,5 +22,7 @@ opt-level = "z" # Optimize for size vs speed with "s"/"z"(removes vectorizat codegen-units = 1 # Further reduces binary size but increases compilation time [dependencies] -iroha_wasm = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } +iroha_trigger = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } + +lol_alloc = "0.4.0" panic-halt = "0.2.0" diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs b/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs index 778e19c99..e330ad776 100644 --- a/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs +++ b/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs @@ -2,21 +2,22 @@ //! //! This module isn't included in the build-tree, //! but instead it is being built by a `client/build.rs` - #![no_std] -#![no_main] -#![allow(clippy::all)] + extern crate alloc; #[cfg(not(test))] extern crate panic_halt; use alloc::{format, string::ToString, vec::Vec}; -use core::str::FromStr; +use lol_alloc::{FreeListAllocator, LockedAllocator}; + +#[global_allocator] +static ALLOC: LockedAllocator = LockedAllocator::new(FreeListAllocator::new()); -use iroha_wasm::{data_model::prelude::*, debug::DebugUnwrapExt, QueryHost}; +use iroha_trigger::{data_model::prelude::*, debug::DebugUnwrapExt, smart_contract::QueryHost}; -#[iroha_wasm::main] -fn smartcontract_entry_point() { +#[iroha_trigger::main] +fn smartcontract_entry_point(_owner: AccountId, _event: Event) { let account_id: AccountId = "alice@wonderland".parse().unwrap(); let limits = MetadataLimits::new(256, 256); let mut metadata = Metadata::new(); @@ -37,10 +38,10 @@ fn smartcontract_entry_point() { .mintable_once() .with_metadata(metadata); - RegisterBox::new(nft_definition).execute().dbg_unwrap(); - SetKeyValueBox::new( + RegisterExpr::new(nft_definition).execute().dbg_unwrap(); + SetKeyValueExpr::new( AssetId::new(nft_id, account_id), - Name::from_str("has_this_nft").dbg_unwrap(), + "has_this_nft".parse::().dbg_unwrap(), Value::Bool(true), ) .execute() diff --git a/modules/client/src/test/java/jp/co/soramitsu/iroha2/JavaTest.java b/modules/client/src/test/java/jp/co/soramitsu/iroha2/JavaTest.java index b6f97beaf..b86f057b9 100644 --- a/modules/client/src/test/java/jp/co/soramitsu/iroha2/JavaTest.java +++ b/modules/client/src/test/java/jp/co/soramitsu/iroha2/JavaTest.java @@ -37,7 +37,7 @@ public class JavaTest extends IrohaTest { @Test @WithIroha(sources = DefaultGenesis.class) public void instructionFailed() { - final VersionedSignedTransaction transaction = TransactionBuilder.Companion.builder() + final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .fail("FAIL MESSAGE") .buildSigned(ALICE_KEYPAIR); @@ -49,7 +49,7 @@ public void instructionFailed() { @WithIroha(sources = DefaultGenesis.class) public void registerDomain() throws ExecutionException, InterruptedException, TimeoutException { final DomainId domainId = new DomainId(new Name("new_domain_name")); - final VersionedSignedTransaction transaction = TransactionBuilder.Companion.builder() + final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .registerDomain(domainId) .buildSigned(ALICE_KEYPAIR); @@ -66,8 +66,8 @@ public void registerDomain() throws ExecutionException, InterruptedException, Ti @Test @WithIroha(sources = DefaultGenesis.class) public void registerAccount() throws Exception { - final AccountId accountId = new AccountId(new Name("new_account"), DEFAULT_DOMAIN_ID); - final VersionedSignedTransaction transaction = TransactionBuilder.Companion.builder() + final AccountId accountId = new AccountId(DEFAULT_DOMAIN_ID, new Name("new_account")); + final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .registerAccount(accountId, new ArrayList<>()) .buildSigned(ALICE_KEYPAIR); @@ -84,13 +84,13 @@ public void registerAccount() throws Exception { @Test @WithIroha(sources = DefaultGenesis.class) public void mintAsset() throws Exception { - final VersionedSignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() + final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Quantity()) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); - final VersionedSignedTransaction mintAssetTx = TransactionBuilder.Companion.builder() + final SignedTransaction mintAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .mintAsset(DEFAULT_ASSET_ID, 5) .buildSigned(ALICE_KEYPAIR); @@ -115,14 +115,14 @@ public void updateKeyValue() throws Exception { put(assetMetadataKey, assetMetadataValue); }}); - final VersionedSignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() + final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Store(), metadata) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); final AssetId assetId = new AssetId(DEFAULT_ASSET_DEFINITION_ID, ALICE_ACCOUNT_ID); - final VersionedSignedTransaction keyValueTx = TransactionBuilder.Companion.builder() + final SignedTransaction keyValueTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .setKeyValue(assetId, assetMetadataKey, assetMetadataValue2) .buildSigned(ALICE_KEYPAIR); @@ -144,13 +144,13 @@ public void setKeyValue() throws Exception { final Value.String assetValue = new Value.String("some string value"); final Name assetKey = new Name("asset_metadata_key"); - final VersionedSignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() + final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Store()) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); - final VersionedSignedTransaction keyValueTx = TransactionBuilder.Companion.builder() + final SignedTransaction keyValueTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .setKeyValue(DEFAULT_ASSET_DEFINITION_ID, assetKey, assetValue) .buildSigned(ALICE_KEYPAIR); @@ -176,18 +176,18 @@ public void blockStreaming() throws ExecutionException, InterruptedException { UUID actionId = idToSubscription.component1().iterator().next().getId(); BlockStreamSubscription subscription = idToSubscription.component2(); - List blocks = new ArrayList<>(); + List blocks = new ArrayList<>(); subscription.receive(actionId, new BlockMessageCollector(blocks)); for (int i = 0; i <= count + 1; i++) { - final VersionedSignedTransaction transaction = TransactionBuilder.Companion.builder() + final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .setKeyValue(ALICE_ACCOUNT_ID, new Name(randomAlphabetic(10)), new Value.String(randomAlphabetic(10))) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(transaction); } - QueryAndExtractor> query = QueryBuilder.findAllBlocks() + QueryAndExtractor> query = QueryBuilder.findAllBlocks() .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR); Integer blocksSize = client.sendQueryAsync(query).get().size(); @@ -197,21 +197,21 @@ public void blockStreaming() throws ExecutionException, InterruptedException { subscription.close(); } - static class BlockMessageCollector implements FlowCollector { + static class BlockMessageCollector implements FlowCollector { - List blocks; + List blocks; - public BlockMessageCollector(List blocks) { + public BlockMessageCollector(List blocks) { this.blocks = blocks; } @Nullable @Override public Object emit( - VersionedBlockMessage versionedBlockMessage, + BlockMessage blockMessage, @NotNull Continuation continuation ) { - blocks.add(versionedBlockMessage); + blocks.add(blockMessage); return null; } } diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/BlockStreamTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/BlockStreamTest.kt index 4a31588de..818618e2b 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/BlockStreamTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/BlockStreamTest.kt @@ -9,12 +9,12 @@ import jp.co.soramitsu.iroha2.annotations.SdkTestId import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.client.blockstream.BlockStreamStorage import jp.co.soramitsu.iroha2.generated.AssetValueType -import jp.co.soramitsu.iroha2.generated.CommittedBlock +import jp.co.soramitsu.iroha2.generated.BlockMessage +import jp.co.soramitsu.iroha2.generated.BlockPayload import jp.co.soramitsu.iroha2.generated.Executable -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.TransactionPayload -import jp.co.soramitsu.iroha2.generated.VersionedBlockMessage -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT_ID @@ -55,12 +55,12 @@ class BlockStreamTest : IrohaTest() { client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { registerAssetDefinition(newAssetName.asName(), DEFAULT_DOMAIN_ID, AssetValueType.Store()) } - var blocks = mutableListOf() - subscription.receive(actionId).collect { block -> blocks.add(block) } + var blocks = mutableListOf() + subscription.receive(actionId).collect { block -> blocks.add(block) } val expectedSize = NewAccountWithMetadata().block.transactions.sumOf { it.size } + 1 // plus wasm var isi = blocks[0].validate(1, GENESIS, GENESIS, expectedSize) - val registerDomain = isi[0].cast().extractDomain().id.name.string + val registerDomain = isi[0].cast().extractDomain().id.name.string assertEquals(DEFAULT_DOMAIN_ID.asString(), registerDomain) assertEquals(ALICE_ACCOUNT_ID.asString(), isi[1].extractAccount().id.asString()) @@ -71,20 +71,11 @@ class BlockStreamTest : IrohaTest() { ) isi = blocks[1].validate(2, DEFAULT_DOMAIN, BOB_ACCOUNT, 1) - var newAssetDefinition = isi[0].cast().extractAssetDefinition() + var newAssetDefinition = isi[0].cast().extractAssetDefinition() assertNotNull(newAssetDefinition) assertEquals(newAssetName, newAssetDefinition.id.name.string) assertEquals(DEFAULT_DOMAIN, newAssetDefinition.id.domainId.asString()) -// blocks = mutableListOf() -// subscription.receiveBlocking(actionId).collect { block -> blocks.add(block) } -// isi = checkBlockStructure(blocks[0], 2, DEFAULT_DOMAIN, BOB_ACCOUNT, 1) -// -// newAssetDefinition = isi[0].cast().extractAssetDefinition() -// assertNotNull(newAssetDefinition) -// assertEquals(newAssetName, newAssetDefinition.id.name.string) -// assertEquals(DEFAULT_DOMAIN, newAssetDefinition.id.domainId.asString()) - subscription.stop() } @@ -111,8 +102,8 @@ class BlockStreamTest : IrohaTest() { } assertEquals((1..repeatTimes.toLong()).sum(), heightSum.toLong()) - val isi = mutableListOf() - subscription.subscribeAndReceive( + val isi = mutableListOf() + subscription.subscribeAndReceive( BlockStreamStorage( onBlock = { it.extractBlock().transactions.first().value.extractInstruction() }, ), @@ -124,24 +115,25 @@ class BlockStreamTest : IrohaTest() { lastValue = randomAlphabetic(16) client.tx { setKeyValue(ALICE_ACCOUNT_ID, randomAlphabetic(16).asName(), lastValue.asValue()) } } - assertEquals(lastValue, isi.last().cast().extractValueString()) + Thread.sleep(5000) + assertEquals(lastValue, isi.last().cast().extractValueString()) subscription.stop() } - private fun CommittedBlock.payloads(): List = this.transactions.map { tx -> + private fun BlockPayload.payloads(): List = this.transactions.map { tx -> tx.value - .cast() - .signedTransaction + .cast() + .signedTransactionV1 .payload } - private fun VersionedBlockMessage.validate( + private fun BlockMessage.validate( expectedHeight: Long, expectedDomain: String, expectedAccount: String, expectedIsiSize: Int, - ): List { + ): List { val committedBlock = this.extractBlock() assertEquals(expectedHeight, committedBlock.header.height.toLong()) diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/InstructionsTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/InstructionsTest.kt index 3e078af81..9b68da67a 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/InstructionsTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/InstructionsTest.kt @@ -18,8 +18,8 @@ import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.PermissionToken import jp.co.soramitsu.iroha2.generated.PublicKey import jp.co.soramitsu.iroha2.generated.RoleId +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.Value -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.query.QueryBuilder import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID_VALUE @@ -162,7 +162,7 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_account") fun `register account`(): Unit = runBlocking { - val newAccountId = AccountId("foo".asName(), DEFAULT_DOMAIN_ID) + val newAccountId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) client.sendTransaction { account(super.account) registerAccount(newAccountId, listOf()) @@ -188,7 +188,7 @@ class InstructionsTest : IrohaTest() { @SdkTestId("register_account") @SdkTestId("unregister_account") fun `register and unregister account`(): Unit = runBlocking { - val joeId = AccountId("foo".asName(), DEFAULT_DOMAIN_ID) + val joeId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) val joeKeyPair = generateKeyPair() client.tx { registerAccount(joeId, listOf(joeKeyPair.public.toIrohaPublicKey())) } @@ -274,7 +274,7 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_account_with_metadata") fun `register account with metadata`(): Unit = runBlocking { - val newAccountId = AccountId("foo".asName(), DEFAULT_DOMAIN_ID) + val newAccountId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) val addressKey = "address".asName() val phoneKey = "phone".asName() val emailKey = "email".asName() @@ -294,9 +294,9 @@ class InstructionsTest : IrohaTest() { val encodedTx = TransactionBuilder { account(super.account) registerAccount(newAccountId, listOf(), metadata) - }.buildSigned().let { VersionedSignedTransaction.encode(it) } + }.buildSigned().let { SignedTransaction.encode(it) } - val decodedTx = encodedTx.let { VersionedSignedTransaction.decode(it) } + val decodedTx = encodedTx.let { SignedTransaction.decode(it) } val signedTx = decodedTx.appendSignatures(ALICE_KEYPAIR) client.sendTransaction { signedTx }.also { d -> @@ -663,7 +663,7 @@ class InstructionsTest : IrohaTest() { val joeDomain = "joe_domain".asDomainId() client.tx { registerDomain(joeDomain) } - val joeId = AccountId("joe".asName(), joeDomain) + val joeId = AccountId(joeDomain, "joe".asName()) val joeKeyPair = generateKeyPair() registerAccount(joeId, joeKeyPair.public.toIrohaPublicKey()) @@ -1028,7 +1028,7 @@ class InstructionsTest : IrohaTest() { @Story("Account transfers domain ownership") @SdkTestId("transfer_domain_ownership") fun `transfer domain ownership`(): Unit = runBlocking { - val genesisAccountId = AccountId(GENESIS.asName(), GENESIS.asDomainId()) + val genesisAccountId = AccountId(GENESIS.asDomainId(), GENESIS.asName()) var domain = QueryBuilder.findDomainById(DEFAULT_DOMAIN_ID) .account(super.account) .buildSigned(super.keyPair) diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/QueriesTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/QueriesTest.kt index f2a17c50c..250553208 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/QueriesTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/QueriesTest.kt @@ -13,15 +13,15 @@ import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.Container import jp.co.soramitsu.iroha2.generated.GenericPredicateBox -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name +import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.StringPredicate import jp.co.soramitsu.iroha2.generated.TransactionValue import jp.co.soramitsu.iroha2.generated.Value import jp.co.soramitsu.iroha2.generated.ValueOfKey import jp.co.soramitsu.iroha2.generated.ValuePredicate -import jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction import jp.co.soramitsu.iroha2.query.QueryBuilder import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_NAME @@ -485,8 +485,8 @@ class QueriesTest : IrohaTest() { txValues.all { value -> value.cast() .value - .cast() - .signedTransaction + .cast() + .signedTransactionV1 .payload .authority == ALICE_ACCOUNT_ID } @@ -537,7 +537,7 @@ class QueriesTest : IrohaTest() { .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } - val hash = VersionedSignedTransaction.encode(transactions[2].transaction.value).hash() + val hash = SignedTransaction.encode(transactions[2].transaction.value).hash() val txByHash = QueryBuilder.findTransactionByHash(hash) .account(ALICE_ACCOUNT_ID) @@ -546,11 +546,11 @@ class QueriesTest : IrohaTest() { assertEquals( DEFAULT_ASSET_DEFINITION_ID, txByHash.transaction.value - .extractInstruction() - .registerBox.`object`.extractNewAssetDefinition().id, + .extractInstruction() + .registerExpr.`object`.extractNewAssetDefinition().id, ) txByHash.transaction.value - .let { VersionedSignedTransaction.encode(it).hash() } + .let { SignedTransaction.encode(it).hash() } .also { assertContentEquals(hash, it) } } @@ -583,7 +583,7 @@ class QueriesTest : IrohaTest() { .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { client.sendQuery(it) } - .also { trigger -> assertTrue { trigger.id() == triggerId } } + .also { trigger -> assertTrue { trigger.id == triggerId } } } @Test @@ -598,7 +598,7 @@ class QueriesTest : IrohaTest() { .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { client.sendQuery(it) } - .also { triggers -> assert(triggers.all { it.id().domainId == domainId }) } + .also { triggers -> assert(triggers.all { it.id.domainId == domainId }) } } @Test @@ -914,7 +914,7 @@ class QueriesTest : IrohaTest() { name: String, metadata: Map = mapOf(), ) { - val newAccountId = AccountId(name.asName(), DEFAULT_DOMAIN_ID) + val newAccountId = AccountId(DEFAULT_DOMAIN_ID, name.asName()) client.sendTransaction { accountId = ALICE_ACCOUNT_ID registerAccount(newAccountId, listOf(), Metadata(metadata)) diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/TriggersTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/TriggersTest.kt index ab483d75a..267777857 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/TriggersTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/TriggersTest.kt @@ -13,7 +13,7 @@ import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValue import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.Duration -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name import jp.co.soramitsu.iroha2.generated.Repeats @@ -56,7 +56,7 @@ class TriggersTest : IrohaTest() { @Story("Data created trigger mints asset upon asset definition creation") @SdkTestId("data_created_trigger") fun `data created trigger`(): Unit = runBlocking { - val triggerId = TriggerId("data_trigger".asName()) + val triggerId = TriggerId(name = "data_trigger".asName()) val newAssetName = "token1" // check account assets before trigger @@ -106,7 +106,7 @@ class TriggersTest : IrohaTest() { @Story("Pre commit trigger mints asset to account for every transaction") @SdkTestId("pre_commit_trigger_should_mint_asset_to_account_for_every_transaction") fun `pre commit trigger should mint asset to account for every transaction`(): Unit = runBlocking { - val triggerId = TriggerId("pre_commit_trigger".asName()) + val triggerId = TriggerId(name = "pre_commit_trigger".asName()) val newAssetName = "token1" // check account assets before trigger @@ -165,7 +165,7 @@ class TriggersTest : IrohaTest() { @Story("Executable trigger mints asset") @SdkTestId("executable_trigger") fun `executable trigger`(): Unit = runBlocking { - val triggerId = TriggerId("executable_trigger".asName()) + val triggerId = TriggerId(name = "executable_trigger".asName()) client.sendTransaction { accountId = ALICE_ACCOUNT_ID @@ -189,7 +189,7 @@ class TriggersTest : IrohaTest() { @Story("Endless time trigger decreases asset quantity continuously") @SdkTestId("endless_time_trigger") fun `endless time trigger`(): Unit = runBlocking { - val triggerId = TriggerId(Name("endless_time_trigger")) + val triggerId = TriggerId(name = Name("endless_time_trigger")) sendAndAwaitTimeTrigger( triggerId, @@ -207,7 +207,7 @@ class TriggersTest : IrohaTest() { @Story("Time trigger executes a limited number of times") @SdkTestId("time_trigger_execution_repeats_few_times") fun `time trigger execution repeats few times`(): Unit = runBlocking { - val triggerId = TriggerId(Name("time_trigger")) + val triggerId = TriggerId(name = Name("time_trigger")) sendAndAwaitTimeTrigger( triggerId, @@ -225,7 +225,7 @@ class TriggersTest : IrohaTest() { @Story("Wasm trigger mints NFT for every user") @SdkTestId("wasm_trigger_to_mint_nft_for_every_user") fun `wasm trigger to mint nft for every user`(): Unit = runBlocking { - val triggerId = TriggerId("wasm_trigger".asName()) + val triggerId = TriggerId(name = "wasm_trigger".asName()) val currentTime = Date().time / 1000 val filter = TriggeringFilterBox.Time( @@ -288,7 +288,7 @@ class TriggersTest : IrohaTest() { @SdkTestId("unregister_executable_trigger") fun `unregister executable trigger`(): Unit = runBlocking { val triggerName = "executable_trigger" - val triggerId = TriggerId(triggerName.asName()) + val triggerId = TriggerId(name = triggerName.asName()) client.sendTransaction { accountId = ALICE_ACCOUNT_ID @@ -349,7 +349,7 @@ class TriggersTest : IrohaTest() { private suspend fun sendAndAwaitTimeTrigger( triggerId: TriggerId, repeats: Repeats, - instruction: InstructionBox, + instruction: InstructionExpr, accountId: AccountId = ALICE_ACCOUNT_ID, ) { client.sendTransaction { diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/testengine/Genesis.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/testengine/Genesis.kt index e2008f2c1..43e1ce0a5 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/testengine/Genesis.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/testengine/Genesis.kt @@ -13,7 +13,7 @@ import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.DomainId -import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.InstructionExpr import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.PermissionToken import jp.co.soramitsu.iroha2.generated.RawGenesisBlock @@ -29,10 +29,10 @@ import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils */ open class DefaultGenesis : Genesis(rawGenesisBlock()) -open class AliceCanUpgradeValidator : Genesis( +open class AliceCanUpgradeExecutor : Genesis( rawGenesisBlock( Instructions.grantPermissionToken( - Permissions.CanUpgradeValidator, + Permissions.CanUpgradeExecutor, "", ALICE_ACCOUNT_ID, ), @@ -85,8 +85,8 @@ open class WithManyDomains : Genesis( ), ) -fun registerDomains(count: Int): Array { - val instructions = mutableListOf() +fun registerDomains(count: Int): Array { + val instructions = mutableListOf() for (i in 1..count) { instructions.add(Instructions.registerDomain(DomainId("NEW_DOMAIN$i".asName()))) } @@ -162,7 +162,7 @@ open class WithExecutableTrigger : Genesis( ), ) { companion object { - val TRIGGER_ID = TriggerId("some_trigger".asName(), DEFAULT_DOMAIN_ID) + val TRIGGER_ID = TriggerId(DEFAULT_DOMAIN_ID, "some_trigger".asName()) } } @@ -257,7 +257,7 @@ open class NewAccountWithMetadata : Genesis( val KEY = "key".asName() val VALUE = "value".asValue() - val ACCOUNT_ID = AccountId(ACCOUNT_NAME, DEFAULT_DOMAIN_ID) + val ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, ACCOUNT_NAME) val KEYPAIR = generateKeyPair() } } @@ -321,7 +321,7 @@ open class RubbishToTestMultipleGenesis : Genesis( /** * Return [RawGenesisBlock] with instructions to init genesis block */ -fun rawGenesisBlock(vararg isi: InstructionBox) = RawGenesisBlock( +fun rawGenesisBlock(vararg isi: InstructionExpr) = RawGenesisBlock( listOf( Instructions.registerDomain(DEFAULT_DOMAIN_ID), Instructions.registerAccount( @@ -334,5 +334,5 @@ fun rawGenesisBlock(vararg isi: InstructionBox) = RawGenesisBlock( ), *isi, ).let { listOf(it) }, - Genesis.validatorMode, + Genesis.executorMode, ) diff --git a/modules/client/src/test/resources/create_nft_for_alice_smartcontract.wasm b/modules/client/src/test/resources/create_nft_for_alice_smartcontract.wasm index 9cd95bc67..30cc71007 100755 Binary files a/modules/client/src/test/resources/create_nft_for_alice_smartcontract.wasm and b/modules/client/src/test/resources/create_nft_for_alice_smartcontract.wasm differ diff --git a/modules/client/src/test/resources/executor.wasm b/modules/client/src/test/resources/executor.wasm new file mode 100755 index 000000000..d0f406bf4 Binary files /dev/null and b/modules/client/src/test/resources/executor.wasm differ diff --git a/modules/client/src/test/resources/genesis.json b/modules/client/src/test/resources/genesis.json index d741c070f..657cb63b7 100644 --- a/modules/client/src/test/resources/genesis.json +++ b/modules/client/src/test/resources/genesis.json @@ -33,10 +33,12 @@ }, { "Grant": { - "PermissionToken": { - "definition_id": "CanSetKeyValueInUserAccount", - "payload": { - "account_id": "alice@wonderland" + "object": { + "PermissionToken": { + "definition_id": "CanSetKeyValueInUserAccount", + "payload": { + "account_id": "alice@wonderland" + } } }, "destination_id": { @@ -46,5 +48,5 @@ } ] ], - "validator": "./validator.wasm" + "executor": "./executor.wasm" } diff --git a/modules/client/src/test/resources/validator.wasm b/modules/client/src/test/resources/validator.wasm deleted file mode 100644 index 581371842..000000000 Binary files a/modules/client/src/test/resources/validator.wasm and /dev/null differ diff --git a/modules/client/src/test/validator/Cargo.toml b/modules/client/src/test/validator/Cargo.toml index 87364e1d8..c3339dfb3 100644 --- a/modules/client/src/test/validator/Cargo.toml +++ b/modules/client/src/test/validator/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iroha_java_validator" +name = "iroha_java_executor" edition = "2021" version = "2.0.0-pre-rc.19" # TODO: teams are being deprecated update the authors URL @@ -19,12 +19,8 @@ codegen-units = 1 # Further reduces binary size but increases compilation time crate-type = ['cdylib'] [dependencies] -iroha_wasm = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } -iroha_validator = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable" } -iroha_schema = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable" } +iroha_executor = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } -parity-scale-codec = { version = "3.2.1", default-features = false } -serde_json = { version = "1.0.91", default-features = false } -serde = { version = "1.0.151", default-features = false } +lol_alloc = "0.4.0" panic-halt = "0.2.0" diff --git a/modules/client/src/test/validator/build.sh b/modules/client/src/test/validator/build.sh index ca32c0a68..9a6e9d9c2 100755 --- a/modules/client/src/test/validator/build.sh +++ b/modules/client/src/test/validator/build.sh @@ -1,4 +1,4 @@ #!/bin/bash cargo +nightly-2023-06-25 build --release -Zbuild-std -Zbuild-std-features=panic_immediate_abort -cp ./target/wasm32-unknown-unknown/release/iroha_java_validator.wasm ../resources/validator.wasm +cp ./target/wasm32-unknown-unknown/release/iroha_java_executor.wasm ../resources/executor.wasm diff --git a/modules/client/src/test/validator/src/lib.rs b/modules/client/src/test/validator/src/lib.rs index 2725387ad..48f69a9a8 100644 --- a/modules/client/src/test/validator/src/lib.rs +++ b/modules/client/src/test/validator/src/lib.rs @@ -1,6 +1,5 @@ -//! Runtime Validator for client tests +//! Runtime Executor for client tests #![no_std] -#![allow(missing_docs, clippy::missing_errors_doc)] extern crate alloc; #[cfg(not(test))] @@ -8,57 +7,56 @@ extern crate panic_halt; use alloc::borrow::ToOwned as _; -use iroha_validator::{ +use iroha_executor::{ data_model::evaluate::ExpressionEvaluator, default::default_permission_token_schema, - iroha_wasm, prelude::*, + prelude::*, smart_contract, }; +use lol_alloc::{FreeListAllocator, LockedAllocator}; +#[global_allocator] +static ALLOC: LockedAllocator = LockedAllocator::new(FreeListAllocator::new()); + +/// Executor that replaces some of [`Validate`]'s methods with sensible defaults +/// +/// # Warning +/// +/// The defaults are not guaranteed to be stable. #[derive(Debug, Clone)] -pub struct Validator { +pub struct Executor { verdict: Result, block_height: u64, - host: iroha_wasm::Host, + host: smart_contract::Host, } -impl Validator { +impl Executor { /// Construct [`Self`] pub fn new(block_height: u64) -> Self { Self { verdict: Ok(()), block_height, - host: iroha_wasm::Host, + host: smart_contract::Host, } } - - fn ensure_genesis(block_height: u64) -> MigrationResult { - if block_height != 0 { - return Err("Default Validator is intended to be used only in genesis. \ - Write your own validator if you need to upgrade validator on existing chain." - .to_owned()); - } - - Ok(()) - } } macro_rules! defaults { - ( $($validator:ident $(<$param:ident $(: $bound:path)?>)?($operation:ty)),+ $(,)? ) => { $( - fn $validator $(<$param $(: $bound)?>)?(&mut self, authority: &AccountId, operation: $operation) { - iroha_validator::default::$validator(self, authority, operation) + ( $($executor:ident $(<$param:ident $(: $bound:path)?>)?($operation:ty)),+ $(,)? ) => { $( + fn $executor $(<$param $(: $bound)?>)?(&mut self, authority: &AccountId, operation: $operation) { + iroha_executor::default::$executor(self, authority, operation) } )+ }; } -impl Visit for Validator { +impl Visit for Executor { defaults! { visit_unsupported(T), - visit_transaction(&VersionedSignedTransaction), - visit_instruction(&InstructionBox), + visit_transaction(&SignedTransaction), + visit_instruction(&InstructionExpr), visit_expression(&EvaluatesTo), - visit_sequence(&SequenceBox), - visit_if(&Conditional), - visit_pair(&Pair), + visit_sequence(&SequenceExpr), + visit_if(&ConditionalExpr), + visit_pair(&PairExpr), // Peer validation visit_unregister_peer(Unregister), @@ -70,17 +68,17 @@ impl Visit for Validator { // Account validation visit_unregister_account(Unregister), - visit_mint_account_public_key(Mint), - visit_burn_account_public_key(Burn), - visit_mint_account_signature_check_condition(Mint), + visit_mint_account_public_key(Mint), + visit_burn_account_public_key(Burn), + visit_mint_account_signature_check_condition(Mint), visit_set_account_key_value(SetKeyValue), visit_remove_account_key_value(RemoveKeyValue), // Asset validation visit_register_asset(Register), visit_unregister_asset(Unregister), - visit_mint_asset(Mint), - visit_burn_asset(Burn), + visit_mint_asset(Mint), + visit_burn_asset(Burn), visit_transfer_asset(Transfer), visit_set_asset_key_value(SetKeyValue), visit_remove_asset_key_value(RemoveKeyValue), @@ -92,18 +90,19 @@ impl Visit for Validator { visit_remove_asset_definition_key_value(RemoveKeyValue), // Permission validation - visit_grant_account_permission(Grant), - visit_revoke_account_permission(Revoke), + visit_grant_account_permission(Grant), + visit_revoke_account_permission(Revoke), // Role validation visit_register_role(Register), visit_unregister_role(Unregister), - visit_grant_account_role(Grant), - visit_revoke_account_role(Revoke), + visit_grant_account_role(Grant), + visit_revoke_account_role(Revoke), // Trigger validation - visit_unregister_trigger(Unregister>), - visit_mint_trigger_repetitions(Mint, u32>), + visit_unregister_trigger(Unregister>), + visit_mint_trigger_repetitions(Mint>), + visit_burn_trigger_repetitions(Burn>), visit_execute_trigger(ExecuteTrigger), // Parameter validation @@ -111,11 +110,11 @@ impl Visit for Validator { visit_new_parameter(NewParameter), // Upgrade validation - visit_upgrade_validator(Upgrade), + visit_upgrade_executor(Upgrade), } } -impl Validate for Validator { +impl Validate for Executor { fn verdict(&self) -> &Result { &self.verdict } @@ -129,32 +128,31 @@ impl Validate for Validator { } } -impl ExpressionEvaluator for Validator { +impl ExpressionEvaluator for Executor { fn evaluate( &self, expression: &E, - ) -> core::result::Result { + ) -> core::result::Result { self.host.evaluate(expression) } } -/// Migrate previous validator to the current version. -/// Called by Iroha once just before upgrading validator. +/// Migrate previous executor to the current version. +/// Called by Iroha once just before upgrading executor. /// /// # Errors /// /// Concrete errors are specific to the implementation. /// /// If `migrate()` entrypoint fails then the whole `Upgrade` instruction -/// will be denied and previous validator will stay unchanged. +/// will be denied and previous executor will stay unchanged. #[entrypoint] -pub fn migrate(block_height: u64) -> MigrationResult { - Validator::ensure_genesis(block_height)?; - +pub fn migrate(_: u64) -> MigrationResult { let schema = default_permission_token_schema(); let (token_ids, schema_str) = schema.serialize(); - iroha_validator::iroha_wasm::set_permission_token_schema( - &iroha_validator::data_model::permission::PermissionTokenSchema::new(token_ids, schema_str), + + iroha_executor::set_permission_token_schema( + &iroha_executor::data_model::permission::PermissionTokenSchema::new(token_ids, schema_str), ); Ok(()) @@ -163,28 +161,28 @@ pub fn migrate(block_height: u64) -> MigrationResult { #[entrypoint] pub fn validate_transaction( authority: AccountId, - transaction: VersionedSignedTransaction, + transaction: SignedTransaction, block_height: u64, ) -> Result { - let mut validator = Validator::new(block_height); - validator.visit_transaction(&authority, &transaction); - validator.verdict + let mut executor = Executor::new(block_height); + executor.visit_transaction(&authority, &transaction); + executor.verdict } #[entrypoint] pub fn validate_instruction( authority: AccountId, - instruction: InstructionBox, + instruction: InstructionExpr, block_height: u64, ) -> Result { - let mut validator = Validator::new(block_height); - validator.visit_instruction(&authority, &instruction); - validator.verdict + let mut executor = Executor::new(block_height); + executor.visit_instruction(&authority, &instruction); + executor.verdict } #[entrypoint] pub fn validate_query(authority: AccountId, query: QueryBox, block_height: u64) -> Result { - let mut validator = Validator::new(block_height); - validator.visit_query(&authority, &query); - validator.verdict + let mut executor = Executor::new(block_height); + executor.visit_query(&authority, &query); + executor.verdict } diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/parse/SchemaReader.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/parse/SchemaReader.kt index f32e5a5a3..1edc96eac 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/parse/SchemaReader.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/parse/SchemaReader.kt @@ -20,7 +20,7 @@ class SchemaReader { val lines = resource.bufferedReader().lines().toList() lines.forEach { line -> line.countRepeatedWithGenerics() } - repeated.entries.removeIf { it.value < 2 } + repeated.entries.removeIf { (it.key != "Trigger" && it.key != "Action") && it.value < 2 } toReplace.putAll(lines.mapNotNull { it.getReplacePairOrNull() }.toMap()) lines.forEach { line -> sb.appendLine(line.replace()) } diff --git a/modules/codegen/src/main/resources/schema.json b/modules/codegen/src/main/resources/schema.json index 6bfdccebe..17d8eb33d 100644 --- a/modules/codegen/src/main/resources/schema.json +++ b/modules/codegen/src/main/resources/schema.json @@ -20,10 +20,6 @@ { "name": "metadata", "type": "Metadata" - }, - { - "name": "roles", - "type": "SortedVec" } ] }, @@ -149,13 +145,13 @@ }, "AccountId": { "Struct": [ - { - "name": "name", - "type": "Name" - }, { "name": "domain_id", "type": "DomainId" + }, + { + "name": "name", + "type": "Name" } ] }, @@ -183,7 +179,7 @@ } ] }, - "Action": { + "Action": { "Struct": [ { "name": "executable", @@ -207,30 +203,6 @@ } ] }, - "Action": { - "Struct": [ - { - "name": "executable", - "type": "OptimizedExecutable" - }, - { - "name": "repeats", - "type": "Repeats" - }, - { - "name": "authority", - "type": "AccountId" - }, - { - "name": "filter", - "type": "TriggeringFilterBox" - }, - { - "name": "metadata", - "type": "Metadata" - } - ] - }, "Add": { "Struct": [ { @@ -619,6 +591,24 @@ ] }, "BatchedResponse": { + "Enum": [ + { + "tag": "V1", + "discriminant": 1, + "type": "BatchedResponseV1" + } + ] + }, + "BatchedResponse>": { + "Enum": [ + { + "tag": "V1", + "discriminant": 1, + "type": "BatchedResponseV1>" + } + ] + }, + "BatchedResponseV1": { "Struct": [ { "name": "batch", @@ -630,11 +620,11 @@ } ] }, - "BatchedResponse>": { + "BatchedResponseV1>": { "Struct": [ { "name": "batch", - "type": "Vec" + "type": "Vec" }, { "name": "cursor", @@ -657,40 +647,52 @@ "BlockHeader": { "Struct": [ { - "name": "timestamp", - "type": "u128" + "name": "height", + "type": "u64" }, { - "name": "consensus_estimation", + "name": "timestamp_ms", "type": "u64" }, { - "name": "height", - "type": "u64" + "name": "previous_block_hash", + "type": "Option>" + }, + { + "name": "transactions_hash", + "type": "Option>>" }, { "name": "view_change_index", "type": "u64" }, { - "name": "previous_block_hash", - "type": "Option>" + "name": "consensus_estimation_ms", + "type": "u64" + } + ] + }, + "BlockMessage": "SignedBlock", + "BlockPayload": { + "Struct": [ + { + "name": "header", + "type": "BlockHeader" }, { - "name": "transactions_hash", - "type": "Option>>" + "name": "commit_topology", + "type": "UniqueVec" }, { - "name": "rejected_transactions_hash", - "type": "Option>>" + "name": "transactions", + "type": "Vec" }, { - "name": "committed_with_topology", - "type": "Vec" + "name": "event_recommendations", + "type": "Vec" } ] }, - "BlockMessage": "VersionedCommittedBlock", "BlockRejectionReason": { "Enum": [ { @@ -700,7 +702,7 @@ ] }, "BlockSubscriptionRequest": "NonZero", - "BurnBox": { + "BurnExpr": { "Struct": [ { "name": "object", @@ -712,27 +714,7 @@ } ] }, - "CommittedBlock": { - "Struct": [ - { - "name": "header", - "type": "BlockHeader" - }, - { - "name": "transactions", - "type": "Vec" - }, - { - "name": "event_recommendations", - "type": "Vec" - }, - { - "name": "signatures", - "type": "SignaturesOf" - } - ] - }, - "Conditional": { + "ConditionalExpr": { "Struct": [ { "name": "condition", @@ -740,11 +722,11 @@ }, { "name": "then", - "type": "InstructionBox" + "type": "InstructionExpr" }, { "name": "otherwise", - "type": "Option" + "type": "Option" } ] }, @@ -927,9 +909,9 @@ "type": "ConfigurationEvent" }, { - "tag": "Validator", + "tag": "Executor", "discriminant": 9, - "type": "ValidatorEvent" + "type": "ExecutorEvent" } ] }, @@ -1132,7 +1114,7 @@ } ] }, - "EvaluatesTo>": { + "EvaluatesTo>": { "Struct": [ { "name": "expression", @@ -1140,7 +1122,7 @@ } ] }, - "EvaluatesTo>": { + "EvaluatesTo>": { "Struct": [ { "name": "expression", @@ -1312,7 +1294,7 @@ { "tag": "Instructions", "discriminant": 0, - "type": "Vec" + "type": "Vec" }, { "tag": "Wasm", @@ -1321,14 +1303,6 @@ } ] }, - "ExecuteTriggerBox": { - "Struct": [ - { - "name": "trigger_id", - "type": "EvaluatesTo" - } - ] - }, "ExecuteTriggerEvent": { "Struct": [ { @@ -1353,6 +1327,14 @@ } ] }, + "ExecuteTriggerExpr": { + "Struct": [ + { + "name": "trigger_id", + "type": "EvaluatesTo" + } + ] + }, "ExecutionTime": { "Enum": [ { @@ -1366,6 +1348,36 @@ } ] }, + "Executor": { + "Struct": [ + { + "name": "wasm", + "type": "WasmSmartContract" + } + ] + }, + "ExecutorEvent": { + "Enum": [ + { + "tag": "Upgraded", + "discriminant": 0 + } + ] + }, + "ExecutorMode": { + "Enum": [ + { + "tag": "Path", + "discriminant": 0, + "type": "String" + }, + { + "tag": "Inline", + "discriminant": 1, + "type": "Executor" + } + ] + }, "Expression": { "Enum": [ { @@ -1470,7 +1482,7 @@ } ] }, - "FailBox": { + "Fail": { "Struct": [ { "name": "message", @@ -1945,7 +1957,7 @@ "Struct": [ { "name": "hash", - "type": "EvaluatesTo>" + "type": "EvaluatesTo>" } ] }, @@ -1999,12 +2011,12 @@ { "tag": "Block", "discriminant": 5, - "type": "HashOf" + "type": "HashOf" }, { "tag": "Transaction", "discriminant": 6, - "type": "HashOf" + "type": "HashOf" }, { "tag": "Peer", @@ -2075,7 +2087,7 @@ "Struct": [ { "name": "hash", - "type": "EvaluatesTo>" + "type": "EvaluatesTo>" } ] }, @@ -2158,7 +2170,7 @@ } ] }, - "GrantBox": { + "GrantExpr": { "Struct": [ { "name": "object", @@ -2166,7 +2178,7 @@ }, { "name": "destination_id", - "type": "EvaluatesTo" + "type": "EvaluatesTo" } ] }, @@ -2183,21 +2195,20 @@ ] }, "Hash": "Array", - "HashOf>": "Hash", - "HashOf": "Hash", - "HashOf": "Hash", - "HashOf": "Hash", + "HashOf>": "Hash", + "HashOf": "Hash", + "HashOf": "Hash", "HashValue": { "Enum": [ { "tag": "Transaction", "discriminant": 0, - "type": "HashOf" + "type": "HashOf" }, { "tag": "Block", "discriminant": 1, - "type": "HashOf" + "type": "HashOf" } ] }, @@ -2300,7 +2311,7 @@ { "tag": "Trigger", "discriminant": 9, - "type": "TriggerBox" + "type": "Trigger" }, { "tag": "Role", @@ -2330,100 +2341,6 @@ } ] }, - "InstructionBox": { - "Enum": [ - { - "tag": "Register", - "discriminant": 0, - "type": "RegisterBox" - }, - { - "tag": "Unregister", - "discriminant": 1, - "type": "UnregisterBox" - }, - { - "tag": "Mint", - "discriminant": 2, - "type": "MintBox" - }, - { - "tag": "Burn", - "discriminant": 3, - "type": "BurnBox" - }, - { - "tag": "Transfer", - "discriminant": 4, - "type": "TransferBox" - }, - { - "tag": "If", - "discriminant": 5, - "type": "Conditional" - }, - { - "tag": "Pair", - "discriminant": 6, - "type": "Pair" - }, - { - "tag": "Sequence", - "discriminant": 7, - "type": "SequenceBox" - }, - { - "tag": "SetKeyValue", - "discriminant": 8, - "type": "SetKeyValueBox" - }, - { - "tag": "RemoveKeyValue", - "discriminant": 9, - "type": "RemoveKeyValueBox" - }, - { - "tag": "Grant", - "discriminant": 10, - "type": "GrantBox" - }, - { - "tag": "Revoke", - "discriminant": 11, - "type": "RevokeBox" - }, - { - "tag": "ExecuteTrigger", - "discriminant": 12, - "type": "ExecuteTriggerBox" - }, - { - "tag": "SetParameter", - "discriminant": 13, - "type": "SetParameterBox" - }, - { - "tag": "NewParameter", - "discriminant": 14, - "type": "NewParameterBox" - }, - { - "tag": "Upgrade", - "discriminant": 15, - "type": "UpgradeBox" - }, - { - "tag": "Log", - "discriminant": 16, - "type": "LogBox" - }, - { - "tag": "Fail", - "discriminant": 17, - "type": "FailBox" - } - ] - }, "InstructionEvaluationError": { "Enum": [ { @@ -2511,7 +2428,7 @@ "Struct": [ { "name": "instruction", - "type": "InstructionBox" + "type": "InstructionExpr" }, { "name": "reason", @@ -2519,96 +2436,190 @@ } ] }, - "InstructionType": { + "InstructionExpr": { "Enum": [ { "tag": "Register", - "discriminant": 0 + "discriminant": 0, + "type": "RegisterExpr" }, { "tag": "Unregister", - "discriminant": 1 + "discriminant": 1, + "type": "UnregisterExpr" }, { "tag": "Mint", - "discriminant": 2 + "discriminant": 2, + "type": "MintExpr" }, { "tag": "Burn", - "discriminant": 3 + "discriminant": 3, + "type": "BurnExpr" }, { "tag": "Transfer", - "discriminant": 4 + "discriminant": 4, + "type": "TransferExpr" }, { "tag": "If", - "discriminant": 5 + "discriminant": 5, + "type": "ConditionalExpr" }, { "tag": "Pair", - "discriminant": 6 + "discriminant": 6, + "type": "PairExpr" }, { "tag": "Sequence", - "discriminant": 7 + "discriminant": 7, + "type": "SequenceExpr" }, { "tag": "SetKeyValue", - "discriminant": 8 + "discriminant": 8, + "type": "SetKeyValueExpr" }, { "tag": "RemoveKeyValue", - "discriminant": 9 + "discriminant": 9, + "type": "RemoveKeyValueExpr" }, { "tag": "Grant", - "discriminant": 10 + "discriminant": 10, + "type": "GrantExpr" }, { "tag": "Revoke", - "discriminant": 11 + "discriminant": 11, + "type": "RevokeExpr" }, { "tag": "ExecuteTrigger", - "discriminant": 12 + "discriminant": 12, + "type": "ExecuteTriggerExpr" }, { "tag": "SetParameter", - "discriminant": 13 + "discriminant": 13, + "type": "SetParameterExpr" }, { "tag": "NewParameter", - "discriminant": 14 + "discriminant": 14, + "type": "NewParameterExpr" }, { "tag": "Upgrade", - "discriminant": 15 + "discriminant": 15, + "type": "UpgradeExpr" }, { "tag": "Log", - "discriminant": 16 + "discriminant": 16, + "type": "LogExpr" }, { "tag": "Fail", - "discriminant": 17 + "discriminant": 17, + "type": "Fail" } ] }, - "Interval": { - "Struct": [ + "InstructionType": { + "Enum": [ { - "name": "start", - "type": "u16" + "tag": "Register", + "discriminant": 0 }, { - "name": "limit", - "type": "u16" - } - ] - }, - "Interval": { - "Struct": [ + "tag": "Unregister", + "discriminant": 1 + }, + { + "tag": "Mint", + "discriminant": 2 + }, + { + "tag": "Burn", + "discriminant": 3 + }, + { + "tag": "Transfer", + "discriminant": 4 + }, + { + "tag": "If", + "discriminant": 5 + }, + { + "tag": "Pair", + "discriminant": 6 + }, + { + "tag": "Sequence", + "discriminant": 7 + }, + { + "tag": "SetKeyValue", + "discriminant": 8 + }, + { + "tag": "RemoveKeyValue", + "discriminant": 9 + }, + { + "tag": "Grant", + "discriminant": 10 + }, + { + "tag": "Revoke", + "discriminant": 11 + }, + { + "tag": "ExecuteTrigger", + "discriminant": 12 + }, + { + "tag": "SetParameter", + "discriminant": 13 + }, + { + "tag": "NewParameter", + "discriminant": 14 + }, + { + "tag": "Upgrade", + "discriminant": 15 + }, + { + "tag": "Log", + "discriminant": 16 + }, + { + "tag": "Fail", + "discriminant": 17 + } + ] + }, + "Interval": { + "Struct": [ + { + "name": "start", + "type": "u16" + }, + { + "name": "limit", + "type": "u16" + } + ] + }, + "Interval": { + "Struct": [ { "name": "start", "type": "u8" @@ -2637,18 +2648,6 @@ "Ipv4Predicate": "Array, 4>", "Ipv6Addr": "Array", "Ipv6Predicate": "Array, 8>", - "IsAssetDefinitionOwner": { - "Struct": [ - { - "name": "asset_definition_id", - "type": "EvaluatesTo" - }, - { - "name": "account_id", - "type": "EvaluatesTo" - } - ] - }, "LengthLimits": { "Struct": [ { @@ -2709,7 +2708,7 @@ } ] }, - "LogBox": { + "LogExpr": { "Struct": [ { "name": "level", @@ -2759,8 +2758,8 @@ } ] }, - "MerkleTree": { - "Vec": "HashOf" + "MerkleTree": { + "Vec": "HashOf" }, "Metadata": { "Struct": [ @@ -2862,7 +2861,7 @@ } ] }, - "MintBox": { + "MintExpr": { "Struct": [ { "name": "object", @@ -3019,7 +3018,7 @@ } ] }, - "NewParameterBox": { + "NewParameterExpr": { "Struct": [ { "name": "parameter", @@ -3092,20 +3091,6 @@ } ] }, - "OptimizedExecutable": { - "Enum": [ - { - "tag": "WasmInternalRepr", - "discriminant": 0, - "type": "WasmInternalRepr" - }, - { - "tag": "Instructions", - "discriminant": 1, - "type": "Vec" - } - ] - }, "Option": { "Option": "DomainId" }, @@ -3115,14 +3100,14 @@ "Option": { "Option": "Hash" }, - "Option>>": { - "Option": "HashOf>" + "Option>>": { + "Option": "HashOf>" }, - "Option>": { - "Option": "HashOf" + "Option>": { + "Option": "HashOf" }, - "Option": { - "Option": "InstructionBox" + "Option": { + "Option": "InstructionExpr" }, "Option": { "Option": "IpfsPath" @@ -3173,15 +3158,15 @@ "OriginFilter": "PeerId", "OriginFilter": "RoleId", "OriginFilter": "TriggerId", - "Pair": { + "PairExpr": { "Struct": [ { "name": "left_instruction", - "type": "InstructionBox" + "type": "InstructionExpr" }, { "name": "right_instruction", - "type": "InstructionBox" + "type": "InstructionExpr" } ] }, @@ -3501,124 +3486,119 @@ "discriminant": 16, "type": "FindTotalAssetQuantityByAssetDefinitionId" }, - { - "tag": "IsAssetDefinitionOwner", - "discriminant": 17, - "type": "IsAssetDefinitionOwner" - }, { "tag": "FindAssetKeyValueByIdAndKey", - "discriminant": 18, + "discriminant": 17, "type": "FindAssetKeyValueByIdAndKey" }, { "tag": "FindAssetDefinitionKeyValueByIdAndKey", - "discriminant": 19, + "discriminant": 18, "type": "FindAssetDefinitionKeyValueByIdAndKey" }, { "tag": "FindAllDomains", - "discriminant": 20, + "discriminant": 19, "type": "FindAllDomains" }, { "tag": "FindDomainById", - "discriminant": 21, + "discriminant": 20, "type": "FindDomainById" }, { "tag": "FindDomainKeyValueByIdAndKey", - "discriminant": 22, + "discriminant": 21, "type": "FindDomainKeyValueByIdAndKey" }, { "tag": "FindAllPeers", - "discriminant": 23, + "discriminant": 22, "type": "FindAllPeers" }, { "tag": "FindAllBlocks", - "discriminant": 24, + "discriminant": 23, "type": "FindAllBlocks" }, { "tag": "FindAllBlockHeaders", - "discriminant": 25, + "discriminant": 24, "type": "FindAllBlockHeaders" }, { "tag": "FindBlockHeaderByHash", - "discriminant": 26, + "discriminant": 25, "type": "FindBlockHeaderByHash" }, { "tag": "FindAllTransactions", - "discriminant": 27, + "discriminant": 26, "type": "FindAllTransactions" }, { "tag": "FindTransactionsByAccountId", - "discriminant": 28, + "discriminant": 27, "type": "FindTransactionsByAccountId" }, { "tag": "FindTransactionByHash", - "discriminant": 29, + "discriminant": 28, "type": "FindTransactionByHash" }, { "tag": "FindPermissionTokensByAccountId", - "discriminant": 30, + "discriminant": 29, "type": "FindPermissionTokensByAccountId" }, { "tag": "FindPermissionTokenSchema", - "discriminant": 31, + "discriminant": 30, "type": "FindPermissionTokenSchema" }, { "tag": "FindAllActiveTriggerIds", - "discriminant": 32, + "discriminant": 31, "type": "FindAllActiveTriggerIds" }, { "tag": "FindTriggerById", - "discriminant": 33, + "discriminant": 32, "type": "FindTriggerById" }, { "tag": "FindTriggerKeyValueByIdAndKey", - "discriminant": 34, + "discriminant": 33, "type": "FindTriggerKeyValueByIdAndKey" }, { "tag": "FindTriggersByDomainId", - "discriminant": 35, + "discriminant": 34, "type": "FindTriggersByDomainId" }, { "tag": "FindAllRoles", - "discriminant": 36, + "discriminant": 35, "type": "FindAllRoles" }, { "tag": "FindAllRoleIds", - "discriminant": 37, + "discriminant": 36, "type": "FindAllRoleIds" }, { "tag": "FindRoleByRoleId", - "discriminant": 38, + "discriminant": 37, "type": "FindRoleByRoleId" }, { "tag": "FindRolesByAccountId", - "discriminant": 39, + "discriminant": 38, "type": "FindRolesByAccountId" }, { "tag": "FindAllParameters", - "discriminant": 40, + "discriminant": 39, "type": "FindAllParameters" } ] @@ -3644,10 +3624,6 @@ "tag": "Conversion", "discriminant": 3, "type": "String" - }, - { - "tag": "Unauthorized", - "discriminant": 4 } ] }, @@ -3683,15 +3659,15 @@ "Struct": [ { "name": "transactions", - "type": "Vec>" + "type": "Vec>" }, { - "name": "validator", - "type": "ValidatorMode" + "name": "executor", + "type": "ExecutorMode" } ] }, - "RegisterBox": { + "RegisterExpr": { "Struct": [ { "name": "object", @@ -3729,7 +3705,7 @@ { "tag": "Trigger", "discriminant": 5, - "type": "Trigger" + "type": "Trigger" }, { "tag": "Role", @@ -3738,7 +3714,7 @@ } ] }, - "RemoveKeyValueBox": { + "RemoveKeyValueExpr": { "Struct": [ { "name": "object_id", @@ -3775,7 +3751,7 @@ } ] }, - "RevokeBox": { + "RevokeExpr": { "Struct": [ { "name": "object", @@ -3783,7 +3759,7 @@ }, { "name": "destination_id", - "type": "EvaluatesTo" + "type": "EvaluatesTo" } ] }, @@ -3921,15 +3897,15 @@ } ] }, - "SequenceBox": { + "SequenceExpr": { "Struct": [ { "name": "instructions", - "type": "Vec" + "type": "Vec" } ] }, - "SetKeyValueBox": { + "SetKeyValueExpr": { "Struct": [ { "name": "object_id", @@ -3945,7 +3921,7 @@ } ] }, - "SetParameterBox": { + "SetParameterExpr": { "Struct": [ { "name": "parameter", @@ -3965,15 +3941,28 @@ } ] }, - "SignatureCheckCondition": "EvaluatesTo", - "SignatureOf": "Signature", + "SignatureCheckCondition": { + "Enum": [ + { + "tag": "AnyAccountSignatureOr", + "discriminant": 0, + "type": "Vec" + }, + { + "tag": "AllAccountSignaturesAnd", + "discriminant": 1, + "type": "Vec" + } + ] + }, + "SignatureOf": "Signature", "SignatureOf": "Signature", "SignatureOf": "Signature", - "SignaturesOf": { + "SignaturesOf": { "Struct": [ { "name": "signatures", - "type": "SortedVec>" + "type": "SortedVec>" } ] }, @@ -3985,7 +3974,37 @@ } ] }, + "SignedBlock": { + "Enum": [ + { + "tag": "V1", + "discriminant": 1, + "type": "SignedBlockV1" + } + ] + }, + "SignedBlockV1": { + "Struct": [ + { + "name": "signatures", + "type": "SignaturesOf" + }, + { + "name": "payload", + "type": "BlockPayload" + } + ] + }, "SignedQuery": { + "Enum": [ + { + "tag": "V1", + "discriminant": 1, + "type": "SignedQueryV1" + } + ] + }, + "SignedQueryV1": { "Struct": [ { "name": "signature", @@ -3998,6 +4017,15 @@ ] }, "SignedTransaction": { + "Enum": [ + { + "tag": "V1", + "discriminant": 1, + "type": "SignedTransactionV1" + } + ] + }, + "SignedTransactionV1": { "Struct": [ { "name": "signatures", @@ -4118,11 +4146,8 @@ "SortedVec": { "Vec": "PublicKey" }, - "SortedVec": { - "Vec": "RoleId" - }, - "SortedVec>": { - "Vec": "SignatureOf" + "SortedVec>": { + "Vec": "SignatureOf" }, "SortedVec>": { "Vec": "SignatureOf" @@ -4241,12 +4266,12 @@ "TransactionQueryOutput": { "Struct": [ { - "name": "transaction", - "type": "TransactionValue" + "name": "block_hash", + "type": "HashOf" }, { - "name": "block_hash", - "type": "HashOf" + "name": "transaction", + "type": "TransactionValue" } ] }, @@ -4277,13 +4302,9 @@ "discriminant": 4, "type": "WasmExecutionFail" }, - { - "tag": "UnexpectedGenesisAccountSignature", - "discriminant": 5 - }, { "tag": "Expired", - "discriminant": 6 + "discriminant": 5 } ] }, @@ -4291,7 +4312,7 @@ "Struct": [ { "name": "value", - "type": "VersionedSignedTransaction" + "type": "SignedTransaction" }, { "name": "error", @@ -4299,7 +4320,7 @@ } ] }, - "TransferBox": { + "TransferExpr": { "Struct": [ { "name": "source_id", @@ -4315,7 +4336,7 @@ } ] }, - "Trigger": { + "Trigger": { "Struct": [ { "name": "id", @@ -4323,33 +4344,7 @@ }, { "name": "action", - "type": "Action" - } - ] - }, - "Trigger": { - "Struct": [ - { - "name": "id", - "type": "TriggerId" - }, - { - "name": "action", - "type": "Action" - } - ] - }, - "TriggerBox": { - "Enum": [ - { - "tag": "Raw", - "discriminant": 0, - "type": "Trigger" - }, - { - "tag": "Optimized", - "discriminant": 1, - "type": "Trigger" + "type": "Action" } ] }, @@ -4460,13 +4455,13 @@ }, "TriggerId": { "Struct": [ - { - "name": "name", - "type": "Name" - }, { "name": "domain_id", "type": "Option" + }, + { + "name": "name", + "type": "Name" } ] }, @@ -4525,7 +4520,8 @@ } ] }, - "UnregisterBox": { + "UniqueVec": "Vec", + "UnregisterExpr": { "Struct": [ { "name": "object_id", @@ -4536,13 +4532,13 @@ "UpgradableBox": { "Enum": [ { - "tag": "Validator", + "tag": "Executor", "discriminant": 0, - "type": "Validator" + "type": "Executor" } ] }, - "UpgradeBox": { + "UpgradeExpr": { "Struct": [ { "name": "object", @@ -4577,36 +4573,6 @@ } ] }, - "Validator": { - "Struct": [ - { - "name": "wasm", - "type": "WasmSmartContract" - } - ] - }, - "ValidatorEvent": { - "Enum": [ - { - "tag": "Upgraded", - "discriminant": 0 - } - ] - }, - "ValidatorMode": { - "Enum": [ - { - "tag": "Path", - "discriminant": 0, - "type": "String" - }, - { - "tag": "Inline", - "discriminant": 1, - "type": "Validator" - } - ] - }, "Value": { "Enum": [ { @@ -4692,7 +4658,7 @@ { "tag": "Block", "discriminant": 16, - "type": "VersionedCommittedBlock" + "type": "SignedBlock" }, { "tag": "BlockHeader", @@ -4715,9 +4681,9 @@ "type": "NumericValue" }, { - "tag": "Validator", + "tag": "Executor", "discriminant": 21, - "type": "Validator" + "type": "Executor" }, { "tag": "LogLevel", @@ -4787,8 +4753,8 @@ "Vec>": { "Vec": "GenericPredicateBox" }, - "Vec": { - "Vec": "InstructionBox" + "Vec": { + "Vec": "InstructionExpr" }, "Vec": { "Vec": "Name" @@ -4796,102 +4762,24 @@ "Vec": { "Vec": "PeerId" }, + "Vec": { + "Vec": "PublicKey" + }, + "Vec": { + "Vec": "SignedTransaction" + }, "Vec": { "Vec": "TransactionValue" }, "Vec": { "Vec": "Value" }, - "Vec>": { - "Vec": "Vec" - }, - "Vec": { - "Vec": "VersionedSignedTransaction" + "Vec>": { + "Vec": "Vec" }, "Vec": { "Vec": "u8" }, - "VersionedBatchedResponse": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "BatchedResponse" - } - ] - }, - "VersionedBatchedResponse>": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "BatchedResponse>" - } - ] - }, - "VersionedBlockMessage": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "BlockMessage" - } - ] - }, - "VersionedBlockSubscriptionRequest": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "BlockSubscriptionRequest" - } - ] - }, - "VersionedCommittedBlock": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "CommittedBlock" - } - ] - }, - "VersionedEventMessage": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "EventMessage" - } - ] - }, - "VersionedEventSubscriptionRequest": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "EventSubscriptionRequest" - } - ] - }, - "VersionedSignedQuery": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "SignedQuery" - } - ] - }, - "VersionedSignedTransaction": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "SignedTransaction" - } - ] - }, "WasmExecutionFail": { "Struct": [ { @@ -4900,18 +4788,6 @@ } ] }, - "WasmInternalRepr": { - "Struct": [ - { - "name": "serialized", - "type": "Vec" - }, - { - "name": "blob_hash", - "type": "HashOf" - } - ] - }, "WasmSmartContract": "Vec", "Where": { "Struct": [ @@ -4944,4 +4820,4 @@ "u8": { "Int": "FixedWidth" } -} \ No newline at end of file +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Account.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Account.kt index 0a7aafb34..2d6a33ea0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Account.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Account.kt @@ -24,7 +24,6 @@ public data class Account( public val signatories: List, public val signatureCheckCondition: SignatureCheckCondition, public val metadata: Metadata, - public val roles: List, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Account = try { @@ -34,7 +33,6 @@ public data class Account( reader.readVec(reader.readCompactInt()) { PublicKey.read(reader) }, SignatureCheckCondition.read(reader), Metadata.read(reader), - reader.readVec(reader.readCompactInt()) { RoleId.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) @@ -57,12 +55,6 @@ public data class Account( } SignatureCheckCondition.write(writer, instance.signatureCheckCondition) Metadata.write(writer, instance.metadata) - writer.writeCompact(instance.roles.size) - instance.roles.sortedWith( - RoleId.comparator(), - ).forEach { value -> - RoleId.write(writer, value) - } } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountId.kt index 20c667509..a827615f2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountId.kt @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'AccountId' regular structure */ public data class AccountId( - public val name: Name, public val domainId: DomainId, + public val name: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AccountId = try { AccountId( - Name.read(reader), DomainId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AccountId): Unit = try { - Name.write(writer, instance.name) DomainId.write(writer, instance.domainId) + Name.write(writer, instance.name) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndExecutable.kt deleted file mode 100644 index c746e9f97..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndExecutable.kt +++ /dev/null @@ -1,51 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * ActionOfFilterBoxAndExecutable - * - * Generated from 'ActionOfFilterBoxAndExecutable' regular structure - */ -public data class ActionOfFilterBoxAndExecutable( - public val executable: Executable, - public val repeats: Repeats, - public val authority: AccountId, - public val filter: FilterBox, - public val metadata: Metadata, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): ActionOfFilterBoxAndExecutable = try { - ActionOfFilterBoxAndExecutable( - Executable.read(reader), - Repeats.read(reader), - AccountId.read(reader), - FilterBox.read(reader), - Metadata.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: ActionOfFilterBoxAndExecutable): Unit = - try { - Executable.write(writer, instance.executable) - Repeats.write(writer, instance.repeats) - AccountId.write(writer, instance.authority) - FilterBox.write(writer, instance.filter) - Metadata.write(writer, instance.metadata) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndOptimizedExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndOptimizedExecutable.kt deleted file mode 100644 index 277fbd957..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfFilterBoxAndOptimizedExecutable.kt +++ /dev/null @@ -1,50 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * ActionOfFilterBoxAndOptimizedExecutable - * - * Generated from 'ActionOfFilterBoxAndOptimizedExecutable' regular structure - */ -public data class ActionOfFilterBoxAndOptimizedExecutable( - public val executable: OptimizedExecutable, - public val repeats: Repeats, - public val authority: AccountId, - public val filter: FilterBox, - public val metadata: Metadata, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): ActionOfFilterBoxAndOptimizedExecutable = try { - ActionOfFilterBoxAndOptimizedExecutable( - OptimizedExecutable.read(reader), - Repeats.read(reader), - AccountId.read(reader), - FilterBox.read(reader), - Metadata.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: ActionOfFilterBoxAndOptimizedExecutable): Unit = try { - OptimizedExecutable.write(writer, instance.executable) - Repeats.write(writer, instance.repeats) - AccountId.write(writer, instance.authority) - FilterBox.write(writer, instance.filter) - Metadata.write(writer, instance.metadata) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt similarity index 70% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndExecutable.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt index b14424706..17f5c0da4 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndExecutable.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt @@ -11,11 +11,11 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ActionOfTriggeringFilterBoxAndExecutable + * ActionOfTriggeringFilterBox * - * Generated from 'ActionOfTriggeringFilterBoxAndExecutable' regular structure + * Generated from 'ActionOfTriggeringFilterBox' regular structure */ -public data class ActionOfTriggeringFilterBoxAndExecutable( +public data class ActionOfTriggeringFilterBox( public val executable: Executable, public val repeats: Repeats, public val authority: AccountId, @@ -23,10 +23,10 @@ public data class ActionOfTriggeringFilterBoxAndExecutable( public val metadata: Metadata, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): ActionOfTriggeringFilterBoxAndExecutable = try { - ActionOfTriggeringFilterBoxAndExecutable( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): ActionOfTriggeringFilterBox = try { + ActionOfTriggeringFilterBox( Executable.read(reader), Repeats.read(reader), AccountId.read(reader), @@ -37,10 +37,7 @@ public data class ActionOfTriggeringFilterBoxAndExecutable( throw wrapException(ex) } - override fun write( - writer: ScaleCodecWriter, - instance: ActionOfTriggeringFilterBoxAndExecutable, - ): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: ActionOfTriggeringFilterBox): Unit = try { Executable.write(writer, instance.executable) Repeats.write(writer, instance.repeats) AccountId.write(writer, instance.authority) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndOptimizedExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndOptimizedExecutable.kt deleted file mode 100644 index cf79e24eb..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBoxAndOptimizedExecutable.kt +++ /dev/null @@ -1,54 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * ActionOfTriggeringFilterBoxAndOptimizedExecutable - * - * Generated from 'ActionOfTriggeringFilterBoxAndOptimizedExecutable' regular structure - */ -public data class ActionOfTriggeringFilterBoxAndOptimizedExecutable( - public val executable: OptimizedExecutable, - public val repeats: Repeats, - public val authority: AccountId, - public val filter: TriggeringFilterBox, - public val metadata: Metadata, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): ActionOfTriggeringFilterBoxAndOptimizedExecutable = - try { - ActionOfTriggeringFilterBoxAndOptimizedExecutable( - OptimizedExecutable.read(reader), - Repeats.read(reader), - AccountId.read(reader), - TriggeringFilterBox.read(reader), - Metadata.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: ActionOfTriggeringFilterBoxAndOptimizedExecutable, - ): Unit = try { - OptimizedExecutable.write(writer, instance.executable) - Repeats.write(writer, instance.repeats) - AccountId.write(writer, instance.authority) - TriggeringFilterBox.write(writer, instance.filter) - Metadata.write(writer, instance.metadata) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponse.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponse.kt index f390c8ad7..c70c71c67 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponse.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponse.kt @@ -3,44 +3,75 @@ // package jp.co.soramitsu.iroha2.generated +import jp.co.soramitsu.iroha2.ModelEnum import jp.co.soramitsu.iroha2.codec.ScaleCodecReader import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException import kotlin.Any +import kotlin.Int import kotlin.Unit import kotlin.collections.List /** * BatchedResponse * - * Generated from 'BatchedResponse>' regular structure + * Generated from 'BatchedResponse>' enum */ -public data class BatchedResponse( - public val batch: List, - public val cursor: ForwardCursor, -) { +public sealed class BatchedResponse : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'V1' variant + */ + public data class V1( + public val batchedResponseV1: BatchedResponseV1>, + ) : BatchedResponse>() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 1 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BatchedResponse.V1 = try { + V1( + BatchedResponseV1.read(reader) as BatchedResponseV1>, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.BatchedResponse.V1, + ): Unit = try { + BatchedResponseV1.write(writer, instance.batchedResponseV1) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + public companion object : ScaleReader>, ScaleWriter> { - override fun read(reader: ScaleCodecReader): BatchedResponse = try { - BatchedResponse( - reader.readVec(reader.readCompactInt()) { VersionedSignedTransaction.read(reader) }, - ForwardCursor.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): BatchedResponse = when ( + val discriminant = + reader.readUByte() + ) { + 1 -> V1.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: BatchedResponse): Unit = try { - writer.writeCompact(instance.batch.size) - instance.batch.forEach { value -> - VersionedSignedTransaction.write(writer, value) - } - ForwardCursor.write(writer, instance.cursor) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: BatchedResponse) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 1 -> V1.write(writer, instance as V1) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseOfValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseOfValue.kt index aae5321eb..541b5300c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseOfValue.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseOfValue.kt @@ -3,37 +3,71 @@ // package jp.co.soramitsu.iroha2.generated +import jp.co.soramitsu.iroha2.ModelEnum import jp.co.soramitsu.iroha2.codec.ScaleCodecReader import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException +import kotlin.Int import kotlin.Unit /** * BatchedResponseOfValue * - * Generated from 'BatchedResponseOfValue' regular structure + * Generated from 'BatchedResponseOfValue' enum */ -public data class BatchedResponseOfValue( - public val batch: Value, - public val cursor: ForwardCursor, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): BatchedResponseOfValue = try { - BatchedResponseOfValue( - Value.read(reader), - ForwardCursor.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) +public sealed class BatchedResponseOfValue : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'V1' variant + */ + public data class V1( + public val batchedResponseV1OfValue: BatchedResponseV1OfValue, + ) : BatchedResponseOfValue() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 1 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue.V1 = try { + V1( + BatchedResponseV1OfValue.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue.V1, + ): Unit = try { + BatchedResponseV1OfValue.write(writer, instance.batchedResponseV1OfValue) + } catch (ex: Exception) { + throw wrapException(ex) + } } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BatchedResponseOfValue = when ( + val discriminant = + reader.readUByte() + ) { + 1 -> V1.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: BatchedResponseOfValue): Unit = try { - Value.write(writer, instance.batch) - ForwardCursor.write(writer, instance.cursor) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: BatchedResponseOfValue) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 1 -> V1.write(writer, instance as V1) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1.kt new file mode 100644 index 000000000..dd3b6c1d8 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1.kt @@ -0,0 +1,46 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Any +import kotlin.Unit +import kotlin.collections.List + +/** + * BatchedResponseV1 + * + * Generated from 'BatchedResponseV1>' regular structure + */ +public data class BatchedResponseV1( + public val batch: List, + public val cursor: ForwardCursor, +) { + public companion object : + ScaleReader>, + ScaleWriter> { + override fun read(reader: ScaleCodecReader): BatchedResponseV1 = try { + BatchedResponseV1( + reader.readVec(reader.readCompactInt()) { SignedTransaction.read(reader) }, + ForwardCursor.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BatchedResponseV1): Unit = try { + writer.writeCompact(instance.batch.size) + instance.batch.forEach { value -> + SignedTransaction.write(writer, value) + } + ForwardCursor.write(writer, instance.cursor) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1OfValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1OfValue.kt new file mode 100644 index 000000000..c751b2940 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1OfValue.kt @@ -0,0 +1,41 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit + +/** + * BatchedResponseV1OfValue + * + * Generated from 'BatchedResponseV1OfValue' regular structure + */ +public data class BatchedResponseV1OfValue( + public val batch: Value, + public val cursor: ForwardCursor, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): BatchedResponseV1OfValue = try { + BatchedResponseV1OfValue( + Value.read(reader), + ForwardCursor.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BatchedResponseV1OfValue): Unit = try { + Value.write(writer, instance.batch) + ForwardCursor.write(writer, instance.cursor) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeader.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeader.kt index 37fa0aaf9..bb92154a5 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeader.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeader.kt @@ -18,43 +18,34 @@ import kotlin.collections.List * Generated from 'BlockHeader' regular structure */ public data class BlockHeader( - public val timestamp: BigInteger, - public val consensusEstimation: BigInteger, public val height: BigInteger, + public val timestampMs: BigInteger, + public val previousBlockHash: HashOf? = null, + public val transactionsHash: HashOf>? = null, public val viewChangeIndex: BigInteger, - public val previousBlockHash: HashOf? = null, - public val transactionsHash: HashOf>? = null, - public val rejectedTransactionsHash: HashOf>? = null, - public val committedWithTopology: List, + public val consensusEstimationMs: BigInteger, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): BlockHeader = try { BlockHeader( - reader.readUint128(), reader.readUint64(), reader.readUint64(), + reader.readNullable(HashOf) as HashOf?, + reader.readNullable(HashOf) as HashOf>?, + reader.readUint64(), reader.readUint64(), - reader.readNullable(HashOf) as HashOf?, - reader.readNullable(HashOf) as HashOf>?, - reader.readNullable(HashOf) as HashOf>?, - reader.readVec(reader.readCompactInt()) { PeerId.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: BlockHeader): Unit = try { - writer.writeUint128(instance.timestamp) - writer.writeUint64(instance.consensusEstimation) writer.writeUint64(instance.height) - writer.writeUint64(instance.viewChangeIndex) + writer.writeUint64(instance.timestampMs) writer.writeNullable(HashOf, instance.previousBlockHash) writer.writeNullable(HashOf, instance.transactionsHash) - writer.writeNullable(HashOf, instance.rejectedTransactionsHash) - writer.writeCompact(instance.committedWithTopology.size) - instance.committedWithTopology.forEach { value -> - PeerId.write(writer, value) - } + writer.writeUint64(instance.viewChangeIndex) + writer.writeUint64(instance.consensusEstimationMs) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockMessage.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockMessage.kt index f1c417cea..5c968e2fa 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockMessage.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockMessage.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'BlockMessage' regular structure */ public data class BlockMessage( - public val versionedCommittedBlock: VersionedCommittedBlock, + public val signedBlock: SignedBlock, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): BlockMessage = try { BlockMessage( - VersionedCommittedBlock.read(reader), + SignedBlock.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: BlockMessage): Unit = try { - VersionedCommittedBlock.write(writer, instance.versionedCommittedBlock) + SignedBlock.write(writer, instance.signedBlock) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedBlock.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt similarity index 69% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedBlock.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt index ffeb1cf3d..fcccd60ee 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedBlock.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt @@ -12,30 +12,31 @@ import kotlin.Unit import kotlin.collections.List /** - * CommittedBlock + * BlockPayload * - * Generated from 'CommittedBlock' regular structure + * Generated from 'BlockPayload' regular structure */ -public data class CommittedBlock( +public data class BlockPayload( public val `header`: BlockHeader, + public val commitTopology: UniqueVec, public val transactions: List, public val eventRecommendations: List, - public val signatures: SignaturesOfOfCommittedBlock, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): CommittedBlock = try { - CommittedBlock( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockPayload = try { + BlockPayload( BlockHeader.read(reader), + UniqueVec.read(reader) as UniqueVec, reader.readVec(reader.readCompactInt()) { TransactionValue.read(reader) }, reader.readVec(reader.readCompactInt()) { Event.read(reader) }, - SignaturesOfOfCommittedBlock.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: CommittedBlock): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: BlockPayload): Unit = try { BlockHeader.write(writer, instance.`header`) + UniqueVec.write(writer, instance.commitTopology) writer.writeCompact(instance.transactions.size) instance.transactions.forEach { value -> TransactionValue.write(writer, value) @@ -44,7 +45,6 @@ public data class CommittedBlock( instance.eventRecommendations.forEach { value -> Event.write(writer, value) } - SignaturesOfOfCommittedBlock.write(writer, instance.signatures) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.kt similarity index 77% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.kt index b7851398d..79a1382d3 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.kt @@ -11,17 +11,17 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * BurnBox + * BurnExpr * - * Generated from 'BurnBox' regular structure + * Generated from 'BurnExpr' regular structure */ -public data class BurnBox( +public data class BurnExpr( public val `object`: EvaluatesTo, public val destinationId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): BurnBox = try { - BurnBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BurnExpr = try { + BurnExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, ) @@ -29,7 +29,7 @@ public data class BurnBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: BurnBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: BurnExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) EvaluatesTo.write(writer, instance.destinationId) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Conditional.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt similarity index 58% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Conditional.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt index 7e01d37a7..ca93e6b81 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Conditional.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt @@ -12,30 +12,30 @@ import kotlin.Boolean import kotlin.Unit /** - * Conditional + * ConditionalExpr * - * Generated from 'Conditional' regular structure + * Generated from 'ConditionalExpr' regular structure */ -public data class Conditional( +public data class ConditionalExpr( public val condition: EvaluatesTo, - public val then: InstructionBox, - public val otherwise: InstructionBox? = null, + public val then: InstructionExpr, + public val otherwise: InstructionExpr? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Conditional = try { - Conditional( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ConditionalExpr = try { + ConditionalExpr( EvaluatesTo.read(reader) as EvaluatesTo, - InstructionBox.read(reader), - reader.readNullable(InstructionBox) as InstructionBox?, + InstructionExpr.read(reader), + reader.readNullable(InstructionExpr) as InstructionExpr?, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Conditional): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: ConditionalExpr): Unit = try { EvaluatesTo.write(writer, instance.condition) - InstructionBox.write(writer, instance.then) - writer.writeNullable(InstructionBox, instance.otherwise) + InstructionExpr.write(writer, instance.then) + writer.writeNullable(InstructionExpr, instance.otherwise) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEvent.kt index 114ec456f..b2e516d8c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEvent.kt @@ -314,21 +314,21 @@ public sealed class DataEvent : ModelEnum { } /** - * 'Validator' variant + * 'Executor' variant */ - public data class Validator( - public val validatorEvent: ValidatorEvent, + public data class Executor( + public val executorEvent: ExecutorEvent, ) : DataEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 9 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Validator = try { - Validator( - ValidatorEvent.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Executor = try { + Executor( + ExecutorEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -336,9 +336,9 @@ public sealed class DataEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEvent.Validator, + instance: jp.co.soramitsu.iroha2.generated.DataEvent.Executor, ): Unit = try { - ValidatorEvent.write(writer, instance.validatorEvent) + ExecutorEvent.write(writer, instance.executorEvent) } catch (ex: Exception) { throw wrapException(ex) } @@ -359,7 +359,7 @@ public sealed class DataEvent : ModelEnum { 6 -> Role.read(reader) 7 -> PermissionToken.read(reader) 8 -> Configuration.read(reader) - 9 -> Validator.read(reader) + 9 -> Executor.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: DataEvent) { @@ -374,7 +374,7 @@ public sealed class DataEvent : ModelEnum { 6 -> Role.write(writer, instance as Role) 7 -> PermissionToken.write(writer, instance as PermissionToken) 8 -> Configuration.write(writer, instance as Configuration) - 9 -> Validator.write(writer, instance as Validator) + 9 -> Executor.write(writer, instance as Executor) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DoesAccountHavePermissionToken.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DoesAccountHavePermissionToken.kt deleted file mode 100644 index 49e6b7b43..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DoesAccountHavePermissionToken.kt +++ /dev/null @@ -1,42 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * DoesAccountHavePermissionToken - * - * Generated from 'DoesAccountHavePermissionToken' regular structure - */ -public data class DoesAccountHavePermissionToken( - public val accountId: EvaluatesTo, - public val permissionToken: EvaluatesTo, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): DoesAccountHavePermissionToken = try { - DoesAccountHavePermissionToken( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: DoesAccountHavePermissionToken): Unit = - try { - EvaluatesTo.write(writer, instance.accountId) - EvaluatesTo.write(writer, instance.permissionToken) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executable.kt index db40f7a1f..53d947639 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executable.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executable.kt @@ -28,7 +28,7 @@ public sealed class Executable : ModelEnum { * 'Instructions' variant */ public data class Instructions( - public val vec: List, + public val vec: List, ) : Executable() { override fun discriminant(): Int = DISCRIMINANT @@ -39,7 +39,7 @@ public sealed class Executable : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Executable.Instructions = try { Instructions( - reader.readVec(reader.readCompactInt()) { InstructionBox.read(reader) }, + reader.readVec(reader.readCompactInt()) { InstructionExpr.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) @@ -51,7 +51,7 @@ public sealed class Executable : ModelEnum { ): Unit = try { writer.writeCompact(instance.vec.size) instance.vec.forEach { value -> - InstructionBox.write(writer, value) + InstructionExpr.write(writer, value) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt similarity index 74% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt index d72da7132..ee9a688c8 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ExecuteTriggerBox + * ExecuteTriggerExpr * - * Generated from 'ExecuteTriggerBox' regular structure + * Generated from 'ExecuteTriggerExpr' regular structure */ -public data class ExecuteTriggerBox( +public data class ExecuteTriggerExpr( public val triggerId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ExecuteTriggerBox = try { - ExecuteTriggerBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecuteTriggerExpr = try { + ExecuteTriggerExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ExecuteTriggerBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: ExecuteTriggerExpr): Unit = try { EvaluatesTo.write(writer, instance.triggerId) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Validator.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executor.kt similarity index 66% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Validator.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executor.kt index 319941ed3..a436cc11b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Validator.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Executor.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * Validator + * Executor * - * Generated from 'Validator' regular structure + * Generated from 'Executor' regular structure */ -public data class Validator( +public data class Executor( public val wasm: WasmSmartContract, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Validator = try { - Validator( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Executor = try { + Executor( WasmSmartContract.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Validator): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: Executor): Unit = try { WasmSmartContract.write(writer, instance.wasm) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt similarity index 71% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt index b24081471..101b8d67a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt @@ -15,11 +15,11 @@ import kotlin.Int import kotlin.Unit /** - * ValidatorEvent + * ExecutorEvent * - * Generated from 'ValidatorEvent' enum + * Generated from 'ExecutorEvent' enum */ -public sealed class ValidatorEvent : ModelEnum { +public sealed class ExecutorEvent : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -36,15 +36,15 @@ public sealed class ValidatorEvent : ModelEnum { /** * 'Upgraded' variant */ - public class Upgraded : ValidatorEvent() { + public class Upgraded : ExecutorEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 0 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ValidatorEvent.Upgraded = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ExecutorEvent.Upgraded = try { Upgraded() } catch (ex: Exception) { throw wrapException(ex) @@ -52,30 +52,30 @@ public sealed class ValidatorEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValidatorEvent.Upgraded, + instance: jp.co.soramitsu.iroha2.generated.ExecutorEvent.Upgraded, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.ValidatorEvent.Upgraded, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.ExecutorEvent.Upgraded, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".ValidatorEvent.Upgraded".hashCode() + override fun hashCode(): Int = ".ExecutorEvent.Upgraded".hashCode() } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ValidatorEvent = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecutorEvent = when ( val discriminant = reader.readUByte() ) { 0 -> Upgraded.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: ValidatorEvent) { + override fun write(writer: ScaleCodecWriter, instance: ExecutorEvent) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Upgraded.write(writer, instance as Upgraded) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorMode.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt similarity index 69% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorMode.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt index 6a8dac34d..ec7d70d66 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValidatorMode.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt @@ -14,11 +14,11 @@ import kotlin.String import kotlin.Unit /** - * ValidatorMode + * ExecutorMode * - * Generated from 'ValidatorMode' enum + * Generated from 'ExecutorMode' enum */ -public sealed class ValidatorMode : ModelEnum { +public sealed class ExecutorMode : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -29,15 +29,15 @@ public sealed class ValidatorMode : ModelEnum { */ public data class Path( public val string: String, - ) : ValidatorMode() { + ) : ExecutorMode() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 0 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ValidatorMode.Path = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ExecutorMode.Path = try { Path( reader.readString(), ) @@ -47,7 +47,7 @@ public sealed class ValidatorMode : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValidatorMode.Path, + instance: jp.co.soramitsu.iroha2.generated.ExecutorMode.Path, ): Unit = try { writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { @@ -60,18 +60,18 @@ public sealed class ValidatorMode : ModelEnum { * 'Inline' variant */ public data class Inline( - public val validator: Validator, - ) : ValidatorMode() { + public val executor: Executor, + ) : ExecutorMode() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 1 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ValidatorMode.Inline = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ExecutorMode.Inline = try { Inline( - Validator.read(reader), + Executor.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -79,17 +79,17 @@ public sealed class ValidatorMode : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValidatorMode.Inline, + instance: jp.co.soramitsu.iroha2.generated.ExecutorMode.Inline, ): Unit = try { - Validator.write(writer, instance.validator) + Executor.write(writer, instance.executor) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ValidatorMode = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecutorMode = when ( val discriminant = reader.readUByte() ) { @@ -97,7 +97,7 @@ public sealed class ValidatorMode : ModelEnum { 1 -> Inline.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: ValidatorMode) { + override fun write(writer: ScaleCodecWriter, instance: ExecutorMode) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Path.write(writer, instance as Path) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FailBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt similarity index 74% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FailBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt index 9c68485e3..af2b81604 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FailBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt @@ -12,23 +12,23 @@ import kotlin.String import kotlin.Unit /** - * FailBox + * Fail * - * Generated from 'FailBox' regular structure + * Generated from 'Fail' regular structure */ -public data class FailBox( +public data class Fail( public val message: String, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FailBox = try { - FailBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Fail = try { + Fail( reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: FailBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: Fail): Unit = try { writer.writeAsList(instance.message.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaderByHash.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaderByHash.kt index 8e90df543..340224bf3 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaderByHash.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaderByHash.kt @@ -16,12 +16,12 @@ import kotlin.Unit * Generated from 'FindBlockHeaderByHash' regular structure */ public data class FindBlockHeaderByHash( - public val hash: EvaluatesTo>, + public val hash: EvaluatesTo>, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindBlockHeaderByHash = try { FindBlockHeaderByHash( - EvaluatesTo.read(reader) as EvaluatesTo>, + EvaluatesTo.read(reader) as EvaluatesTo>, ) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindError.kt index 835afb266..d24d648cd 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindError.kt @@ -187,7 +187,7 @@ public sealed class FindError : ModelEnum { * 'Block' variant */ public data class Block( - public val hashOf: HashOf, + public val hashOf: HashOf, ) : FindError() { override fun discriminant(): Int = DISCRIMINANT @@ -198,7 +198,7 @@ public sealed class FindError : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.FindError.Block = try { Block( - HashOf.read(reader) as HashOf, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) @@ -219,7 +219,7 @@ public sealed class FindError : ModelEnum { * 'Transaction' variant */ public data class Transaction( - public val hashOf: HashOf, + public val hashOf: HashOf, ) : FindError() { override fun discriminant(): Int = DISCRIMINANT @@ -230,7 +230,7 @@ public sealed class FindError : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.FindError.Transaction = try { Transaction( - HashOf.read(reader) as HashOf, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionByHash.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionByHash.kt index 21a97aad4..ef9d688e0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionByHash.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionByHash.kt @@ -16,12 +16,12 @@ import kotlin.Unit * Generated from 'FindTransactionByHash' regular structure */ public data class FindTransactionByHash( - public val hash: EvaluatesTo>, + public val hash: EvaluatesTo>, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTransactionByHash = try { FindTransactionByHash( - EvaluatesTo.read(reader) as EvaluatesTo>, + EvaluatesTo.read(reader) as EvaluatesTo>, ) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.kt similarity index 67% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.kt index 8bfa269e4..08b3fac41 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.kt @@ -11,25 +11,25 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * GrantBox + * GrantExpr * - * Generated from 'GrantBox' regular structure + * Generated from 'GrantExpr' regular structure */ -public data class GrantBox( +public data class GrantExpr( public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, + public val destinationId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): GrantBox = try { - GrantBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): GrantExpr = try { + GrantExpr( EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: GrantBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: GrantExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) EvaluatesTo.write(writer, instance.destinationId) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashOf.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashOf.kt index 438cc08c7..124af9934 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashOf.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashOf.kt @@ -14,7 +14,7 @@ import kotlin.Unit /** * HashOf * - * Generated from 'HashOf' regular structure + * Generated from 'HashOf' regular structure */ public data class HashOf( public val hash: Hash, diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashValue.kt index a5573dae2..9b6eff62e 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashValue.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashValue.kt @@ -27,7 +27,7 @@ public sealed class HashValue : ModelEnum { * 'Transaction' variant */ public data class Transaction( - public val hashOf: HashOf, + public val hashOf: HashOf, ) : HashValue() { override fun discriminant(): Int = DISCRIMINANT @@ -38,7 +38,7 @@ public sealed class HashValue : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.HashValue.Transaction = try { Transaction( - HashOf.read(reader) as HashOf, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) @@ -59,7 +59,7 @@ public sealed class HashValue : ModelEnum { * 'Block' variant */ public data class Block( - public val hashOf: HashOf, + public val hashOf: HashOf, ) : HashValue() { override fun discriminant(): Int = DISCRIMINANT @@ -70,7 +70,7 @@ public sealed class HashValue : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.HashValue.Block = try { Block( - HashOf.read(reader) as HashOf, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdentifiableBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdentifiableBox.kt index 61d19e4a1..4b5159833 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdentifiableBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdentifiableBox.kt @@ -318,7 +318,7 @@ public sealed class IdentifiableBox : ModelEnum { * 'Trigger' variant */ public data class Trigger( - public val triggerBox: TriggerBox, + public val triggerOfTriggeringFilterBox: TriggerOfTriggeringFilterBox, ) : IdentifiableBox() { override fun discriminant(): Int = DISCRIMINANT @@ -329,7 +329,7 @@ public sealed class IdentifiableBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.IdentifiableBox.Trigger = try { Trigger( - TriggerBox.read(reader), + TriggerOfTriggeringFilterBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -339,7 +339,7 @@ public sealed class IdentifiableBox : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.IdentifiableBox.Trigger, ): Unit = try { - TriggerBox.write(writer, instance.triggerBox) + TriggerOfTriggeringFilterBox.write(writer, instance.triggerOfTriggeringFilterBox) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionFail.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionFail.kt index 96f0c4d1b..3fcf06d2a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionFail.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionFail.kt @@ -17,7 +17,7 @@ import kotlin.Unit * Generated from 'InstructionExecutionFail' regular structure */ public data class InstructionExecutionFail( - public val instruction: InstructionBox, + public val instruction: InstructionExpr, public val reason: String, ) { public companion object : @@ -25,7 +25,7 @@ public data class InstructionExecutionFail( ScaleWriter { override fun read(reader: ScaleCodecReader): InstructionExecutionFail = try { InstructionExecutionFail( - InstructionBox.read(reader), + InstructionExpr.read(reader), reader.readString(), ) } catch (ex: Exception) { @@ -33,7 +33,7 @@ public data class InstructionExecutionFail( } override fun write(writer: ScaleCodecWriter, instance: InstructionExecutionFail): Unit = try { - InstructionBox.write(writer, instance.instruction) + InstructionExpr.write(writer, instance.instruction) writer.writeAsList(instance.reason.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt similarity index 75% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt index f5213e247..f71697e9d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * InstructionBox + * InstructionExpr * - * Generated from 'InstructionBox' enum + * Generated from 'InstructionExpr' enum */ -public sealed class InstructionBox : ModelEnum { +public sealed class InstructionExpr : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,18 +27,18 @@ public sealed class InstructionBox : ModelEnum { * 'Register' variant */ public data class Register( - public val registerBox: RegisterBox, - ) : InstructionBox() { + public val registerExpr: RegisterExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 0 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Register = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Register = try { Register( - RegisterBox.read(reader), + RegisterExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Register, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Register, ): Unit = try { - RegisterBox.write(writer, instance.registerBox) + RegisterExpr.write(writer, instance.registerExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -59,18 +59,18 @@ public sealed class InstructionBox : ModelEnum { * 'Unregister' variant */ public data class Unregister( - public val unregisterBox: UnregisterBox, - ) : InstructionBox() { + public val unregisterExpr: UnregisterExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 1 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Unregister = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Unregister = try { Unregister( - UnregisterBox.read(reader), + UnregisterExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,9 +78,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Unregister, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Unregister, ): Unit = try { - UnregisterBox.write(writer, instance.unregisterBox) + UnregisterExpr.write(writer, instance.unregisterExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -91,18 +91,18 @@ public sealed class InstructionBox : ModelEnum { * 'Mint' variant */ public data class Mint( - public val mintBox: MintBox, - ) : InstructionBox() { + public val mintExpr: MintExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 2 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Mint = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Mint = try { Mint( - MintBox.read(reader), + MintExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -110,9 +110,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Mint, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Mint, ): Unit = try { - MintBox.write(writer, instance.mintBox) + MintExpr.write(writer, instance.mintExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -123,18 +123,18 @@ public sealed class InstructionBox : ModelEnum { * 'Burn' variant */ public data class Burn( - public val burnBox: BurnBox, - ) : InstructionBox() { + public val burnExpr: BurnExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 3 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Burn = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Burn = try { Burn( - BurnBox.read(reader), + BurnExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -142,9 +142,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Burn, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Burn, ): Unit = try { - BurnBox.write(writer, instance.burnBox) + BurnExpr.write(writer, instance.burnExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -155,18 +155,18 @@ public sealed class InstructionBox : ModelEnum { * 'Transfer' variant */ public data class Transfer( - public val transferBox: TransferBox, - ) : InstructionBox() { + public val transferExpr: TransferExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 4 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Transfer = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Transfer = try { Transfer( - TransferBox.read(reader), + TransferExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -174,9 +174,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Transfer, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Transfer, ): Unit = try { - TransferBox.write(writer, instance.transferBox) + TransferExpr.write(writer, instance.transferExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -187,18 +187,18 @@ public sealed class InstructionBox : ModelEnum { * 'If' variant */ public data class If( - public val conditional: Conditional, - ) : InstructionBox() { + public val conditionalExpr: ConditionalExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 5 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.If = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.If = try { If( - Conditional.read(reader), + ConditionalExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -206,9 +206,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.If, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.If, ): Unit = try { - Conditional.write(writer, instance.conditional) + ConditionalExpr.write(writer, instance.conditionalExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -219,18 +219,18 @@ public sealed class InstructionBox : ModelEnum { * 'Pair' variant */ public data class Pair( - public val pair: jp.co.soramitsu.iroha2.generated.Pair, - ) : InstructionBox() { + public val pairExpr: PairExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 6 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Pair = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Pair = try { Pair( - jp.co.soramitsu.iroha2.generated.Pair.read(reader), + PairExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -238,9 +238,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Pair, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Pair, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Pair.write(writer, instance.pair) + PairExpr.write(writer, instance.pairExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -251,18 +251,18 @@ public sealed class InstructionBox : ModelEnum { * 'Sequence' variant */ public data class Sequence( - public val sequenceBox: SequenceBox, - ) : InstructionBox() { + public val sequenceExpr: SequenceExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 7 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Sequence = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Sequence = try { Sequence( - SequenceBox.read(reader), + SequenceExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -270,9 +270,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Sequence, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Sequence, ): Unit = try { - SequenceBox.write(writer, instance.sequenceBox) + SequenceExpr.write(writer, instance.sequenceExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -283,18 +283,18 @@ public sealed class InstructionBox : ModelEnum { * 'SetKeyValue' variant */ public data class SetKeyValue( - public val setKeyValueBox: SetKeyValueBox, - ) : InstructionBox() { + public val setKeyValueExpr: SetKeyValueExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 8 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.SetKeyValue = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.SetKeyValue = try { SetKeyValue( - SetKeyValueBox.read(reader), + SetKeyValueExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -302,9 +302,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.SetKeyValue, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.SetKeyValue, ): Unit = try { - SetKeyValueBox.write(writer, instance.setKeyValueBox) + SetKeyValueExpr.write(writer, instance.setKeyValueExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -315,18 +315,18 @@ public sealed class InstructionBox : ModelEnum { * 'RemoveKeyValue' variant */ public data class RemoveKeyValue( - public val removeKeyValueBox: RemoveKeyValueBox, - ) : InstructionBox() { + public val removeKeyValueExpr: RemoveKeyValueExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 9 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.RemoveKeyValue = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.RemoveKeyValue = try { RemoveKeyValue( - RemoveKeyValueBox.read(reader), + RemoveKeyValueExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -334,9 +334,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.RemoveKeyValue, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.RemoveKeyValue, ): Unit = try { - RemoveKeyValueBox.write(writer, instance.removeKeyValueBox) + RemoveKeyValueExpr.write(writer, instance.removeKeyValueExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -347,18 +347,18 @@ public sealed class InstructionBox : ModelEnum { * 'Grant' variant */ public data class Grant( - public val grantBox: GrantBox, - ) : InstructionBox() { + public val grantExpr: GrantExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 10 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Grant = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Grant = try { Grant( - GrantBox.read(reader), + GrantExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -366,9 +366,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Grant, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Grant, ): Unit = try { - GrantBox.write(writer, instance.grantBox) + GrantExpr.write(writer, instance.grantExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -379,18 +379,18 @@ public sealed class InstructionBox : ModelEnum { * 'Revoke' variant */ public data class Revoke( - public val revokeBox: RevokeBox, - ) : InstructionBox() { + public val revokeExpr: RevokeExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 11 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Revoke = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Revoke = try { Revoke( - RevokeBox.read(reader), + RevokeExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -398,9 +398,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Revoke, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Revoke, ): Unit = try { - RevokeBox.write(writer, instance.revokeBox) + RevokeExpr.write(writer, instance.revokeExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -411,18 +411,18 @@ public sealed class InstructionBox : ModelEnum { * 'ExecuteTrigger' variant */ public data class ExecuteTrigger( - public val executeTriggerBox: ExecuteTriggerBox, - ) : InstructionBox() { + public val executeTriggerExpr: ExecuteTriggerExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 12 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.ExecuteTrigger = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.ExecuteTrigger = try { ExecuteTrigger( - ExecuteTriggerBox.read(reader), + ExecuteTriggerExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -430,9 +430,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.ExecuteTrigger, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.ExecuteTrigger, ): Unit = try { - ExecuteTriggerBox.write(writer, instance.executeTriggerBox) + ExecuteTriggerExpr.write(writer, instance.executeTriggerExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -443,18 +443,18 @@ public sealed class InstructionBox : ModelEnum { * 'SetParameter' variant */ public data class SetParameter( - public val setParameterBox: SetParameterBox, - ) : InstructionBox() { + public val setParameterExpr: SetParameterExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 13 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.SetParameter = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.SetParameter = try { SetParameter( - SetParameterBox.read(reader), + SetParameterExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -462,9 +462,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.SetParameter, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.SetParameter, ): Unit = try { - SetParameterBox.write(writer, instance.setParameterBox) + SetParameterExpr.write(writer, instance.setParameterExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -475,18 +475,18 @@ public sealed class InstructionBox : ModelEnum { * 'NewParameter' variant */ public data class NewParameter( - public val newParameterBox: NewParameterBox, - ) : InstructionBox() { + public val newParameterExpr: NewParameterExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 14 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.NewParameter = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.NewParameter = try { NewParameter( - NewParameterBox.read(reader), + NewParameterExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -494,9 +494,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.NewParameter, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.NewParameter, ): Unit = try { - NewParameterBox.write(writer, instance.newParameterBox) + NewParameterExpr.write(writer, instance.newParameterExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -507,18 +507,18 @@ public sealed class InstructionBox : ModelEnum { * 'Upgrade' variant */ public data class Upgrade( - public val upgradeBox: UpgradeBox, - ) : InstructionBox() { + public val upgradeExpr: UpgradeExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 15 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Upgrade = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Upgrade = try { Upgrade( - UpgradeBox.read(reader), + UpgradeExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -526,9 +526,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Upgrade, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Upgrade, ): Unit = try { - UpgradeBox.write(writer, instance.upgradeBox) + UpgradeExpr.write(writer, instance.upgradeExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -539,18 +539,18 @@ public sealed class InstructionBox : ModelEnum { * 'Log' variant */ public data class Log( - public val logBox: LogBox, - ) : InstructionBox() { + public val logExpr: LogExpr, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 16 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Log = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Log = try { Log( - LogBox.read(reader), + LogExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -558,9 +558,9 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Log, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Log, ): Unit = try { - LogBox.write(writer, instance.logBox) + LogExpr.write(writer, instance.logExpr) } catch (ex: Exception) { throw wrapException(ex) } @@ -571,18 +571,18 @@ public sealed class InstructionBox : ModelEnum { * 'Fail' variant */ public data class Fail( - public val failBox: FailBox, - ) : InstructionBox() { + public val fail: jp.co.soramitsu.iroha2.generated.Fail, + ) : InstructionExpr() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 17 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Fail = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Fail = try { Fail( - FailBox.read(reader), + jp.co.soramitsu.iroha2.generated.Fail.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -590,17 +590,17 @@ public sealed class InstructionBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Fail, + instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Fail, ): Unit = try { - FailBox.write(writer, instance.failBox) + jp.co.soramitsu.iroha2.generated.Fail.write(writer, instance.fail) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): InstructionBox = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): InstructionExpr = when ( val discriminant = reader.readUByte() ) { @@ -624,7 +624,7 @@ public sealed class InstructionBox : ModelEnum { 17 -> Fail.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: InstructionBox) { + override fun write(writer: ScaleCodecWriter, instance: InstructionExpr) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Register.write(writer, instance as Register) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IsAssetDefinitionOwner.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IsAssetDefinitionOwner.kt deleted file mode 100644 index b2c7c2e83..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IsAssetDefinitionOwner.kt +++ /dev/null @@ -1,39 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * IsAssetDefinitionOwner - * - * Generated from 'IsAssetDefinitionOwner' regular structure - */ -public data class IsAssetDefinitionOwner( - public val assetDefinitionId: EvaluatesTo, - public val accountId: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): IsAssetDefinitionOwner = try { - IsAssetDefinitionOwner( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: IsAssetDefinitionOwner): Unit = try { - EvaluatesTo.write(writer, instance.assetDefinitionId) - EvaluatesTo.write(writer, instance.accountId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.kt similarity index 77% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.kt index 927dc5938..f6c2d8b0c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.kt @@ -12,17 +12,17 @@ import kotlin.String import kotlin.Unit /** - * LogBox + * LogExpr * - * Generated from 'LogBox' regular structure + * Generated from 'LogExpr' regular structure */ -public data class LogBox( +public data class LogExpr( public val level: EvaluatesTo, public val msg: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): LogBox = try { - LogBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): LogExpr = try { + LogExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, ) @@ -30,7 +30,7 @@ public data class LogBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: LogBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: LogExpr): Unit = try { EvaluatesTo.write(writer, instance.level) EvaluatesTo.write(writer, instance.msg) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.kt similarity index 77% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.kt index 227dee489..18b99bddf 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.kt @@ -11,17 +11,17 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * MintBox + * MintExpr * - * Generated from 'MintBox' regular structure + * Generated from 'MintExpr' regular structure */ -public data class MintBox( +public data class MintExpr( public val `object`: EvaluatesTo, public val destinationId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): MintBox = try { - MintBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): MintExpr = try { + MintExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, ) @@ -29,7 +29,7 @@ public data class MintBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: MintBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: MintExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) EvaluatesTo.write(writer, instance.destinationId) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt similarity index 75% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt index 45d729e54..c9e759d74 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * NewParameterBox + * NewParameterExpr * - * Generated from 'NewParameterBox' regular structure + * Generated from 'NewParameterExpr' regular structure */ -public data class NewParameterBox( +public data class NewParameterExpr( public val parameter: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): NewParameterBox = try { - NewParameterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): NewParameterExpr = try { + NewParameterExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: NewParameterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: NewParameterExpr): Unit = try { EvaluatesTo.write(writer, instance.parameter) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OptimizedExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OptimizedExecutable.kt deleted file mode 100644 index 73806cd27..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OptimizedExecutable.kt +++ /dev/null @@ -1,112 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit -import kotlin.collections.List - -/** - * OptimizedExecutable - * - * Generated from 'OptimizedExecutable' enum - */ -public sealed class OptimizedExecutable : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'WasmInternalRepr' variant - */ - public data class WasmInternalRepr( - public val wasmInternalRepr: jp.co.soramitsu.iroha2.generated.WasmInternalRepr, - ) : OptimizedExecutable() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 0 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.OptimizedExecutable.WasmInternalRepr = try { - WasmInternalRepr( - jp.co.soramitsu.iroha2.generated.WasmInternalRepr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.OptimizedExecutable.WasmInternalRepr, - ): Unit = - try { - jp.co.soramitsu.iroha2.generated.WasmInternalRepr.write(writer, instance.wasmInternalRepr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Instructions' variant - */ - public data class Instructions( - public val vec: List, - ) : OptimizedExecutable() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.OptimizedExecutable.Instructions = try { - Instructions( - reader.readVec(reader.readCompactInt()) { InstructionBox.read(reader) }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.OptimizedExecutable.Instructions, - ): Unit = try { - writer.writeCompact(instance.vec.size) - instance.vec.forEach { value -> - InstructionBox.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): OptimizedExecutable = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> WasmInternalRepr.read(reader) - 1 -> Instructions.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: OptimizedExecutable) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> WasmInternalRepr.write(writer, instance as WasmInternalRepr) - 1 -> Instructions.write(writer, instance as Instructions) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pair.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.kt similarity index 50% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pair.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.kt index abe0088c8..f69aa607a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pair.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.kt @@ -11,27 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * Pair + * PairExpr * - * Generated from 'Pair' regular structure + * Generated from 'PairExpr' regular structure */ -public data class Pair( - public val leftInstruction: InstructionBox, - public val rightInstruction: InstructionBox, +public data class PairExpr( + public val leftInstruction: InstructionExpr, + public val rightInstruction: InstructionExpr, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Pair = try { - Pair( - InstructionBox.read(reader), - InstructionBox.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PairExpr = try { + PairExpr( + InstructionExpr.read(reader), + InstructionExpr.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Pair): Unit = try { - InstructionBox.write(writer, instance.leftInstruction) - InstructionBox.write(writer, instance.rightInstruction) + override fun write(writer: ScaleCodecWriter, instance: PairExpr): Unit = try { + InstructionExpr.write(writer, instance.leftInstruction) + InstructionExpr.write(writer, instance.rightInstruction) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryBox.kt index 66ae2f587..39f8c150e 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryBox.kt @@ -609,41 +609,6 @@ public sealed class QueryBox : ModelEnum { } } - /** - * 'IsAssetDefinitionOwner' variant - */ - public data class IsAssetDefinitionOwner( - public val isAssetDefinitionOwner: jp.co.soramitsu.iroha2.generated.IsAssetDefinitionOwner, - ) : QueryBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 17 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.IsAssetDefinitionOwner = try { - IsAssetDefinitionOwner( - jp.co.soramitsu.iroha2.generated.IsAssetDefinitionOwner.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryBox.IsAssetDefinitionOwner, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.IsAssetDefinitionOwner.write( - writer, - instance.isAssetDefinitionOwner, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'FindAssetKeyValueByIdAndKey' variant */ @@ -656,7 +621,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 18 + public const val DISCRIMINANT: Int = 17 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetKeyValueByIdAndKey = try { FindAssetKeyValueByIdAndKey( @@ -693,7 +658,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 19 + public const val DISCRIMINANT: Int = 18 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetDefinitionKeyValueByIdAndKey = try { FindAssetDefinitionKeyValueByIdAndKey( @@ -728,7 +693,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 20 + public const val DISCRIMINANT: Int = 19 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllDomains = try { FindAllDomains( @@ -760,7 +725,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 21 + public const val DISCRIMINANT: Int = 20 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindDomainById = try { FindDomainById( @@ -793,7 +758,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 22 + public const val DISCRIMINANT: Int = 21 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindDomainKeyValueByIdAndKey = try { FindDomainKeyValueByIdAndKey( @@ -829,7 +794,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 23 + public const val DISCRIMINANT: Int = 22 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllPeers = try { FindAllPeers( @@ -861,7 +826,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 24 + public const val DISCRIMINANT: Int = 23 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllBlocks = try { FindAllBlocks( @@ -893,7 +858,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 25 + public const val DISCRIMINANT: Int = 24 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllBlockHeaders = try { FindAllBlockHeaders( @@ -928,7 +893,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 26 + public const val DISCRIMINANT: Int = 25 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindBlockHeaderByHash = try { FindBlockHeaderByHash( @@ -963,7 +928,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 27 + public const val DISCRIMINANT: Int = 26 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllTransactions = try { FindAllTransactions( @@ -999,7 +964,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 28 + public const val DISCRIMINANT: Int = 27 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTransactionsByAccountId = try { FindTransactionsByAccountId( @@ -1035,7 +1000,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 29 + public const val DISCRIMINANT: Int = 28 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTransactionByHash = try { FindTransactionByHash( @@ -1071,7 +1036,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 30 + public const val DISCRIMINANT: Int = 29 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokensByAccountId = try { FindPermissionTokensByAccountId( @@ -1107,7 +1072,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 31 + public const val DISCRIMINANT: Int = 30 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokenSchema = try { FindPermissionTokenSchema( @@ -1142,7 +1107,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 32 + public const val DISCRIMINANT: Int = 31 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllActiveTriggerIds = try { FindAllActiveTriggerIds( @@ -1177,7 +1142,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 33 + public const val DISCRIMINANT: Int = 32 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggerById = try { FindTriggerById( @@ -1210,7 +1175,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 34 + public const val DISCRIMINANT: Int = 33 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggerKeyValueByIdAndKey = try { FindTriggerKeyValueByIdAndKey( @@ -1246,7 +1211,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 35 + public const val DISCRIMINANT: Int = 34 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByDomainId = try { FindTriggersByDomainId( @@ -1281,7 +1246,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 36 + public const val DISCRIMINANT: Int = 35 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllRoles = try { FindAllRoles( @@ -1313,7 +1278,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 37 + public const val DISCRIMINANT: Int = 36 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllRoleIds = try { FindAllRoleIds( @@ -1345,7 +1310,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 38 + public const val DISCRIMINANT: Int = 37 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindRoleByRoleId = try { FindRoleByRoleId( @@ -1377,7 +1342,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 39 + public const val DISCRIMINANT: Int = 38 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindRolesByAccountId = try { FindRolesByAccountId( @@ -1412,7 +1377,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 40 + public const val DISCRIMINANT: Int = 39 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllParameters = try { FindAllParameters( @@ -1455,30 +1420,29 @@ public sealed class QueryBox : ModelEnum { 14 -> FindAssetsByDomainIdAndAssetDefinitionId.read(reader) 15 -> FindAssetQuantityById.read(reader) 16 -> FindTotalAssetQuantityByAssetDefinitionId.read(reader) - 17 -> IsAssetDefinitionOwner.read(reader) - 18 -> FindAssetKeyValueByIdAndKey.read(reader) - 19 -> FindAssetDefinitionKeyValueByIdAndKey.read(reader) - 20 -> FindAllDomains.read(reader) - 21 -> FindDomainById.read(reader) - 22 -> FindDomainKeyValueByIdAndKey.read(reader) - 23 -> FindAllPeers.read(reader) - 24 -> FindAllBlocks.read(reader) - 25 -> FindAllBlockHeaders.read(reader) - 26 -> FindBlockHeaderByHash.read(reader) - 27 -> FindAllTransactions.read(reader) - 28 -> FindTransactionsByAccountId.read(reader) - 29 -> FindTransactionByHash.read(reader) - 30 -> FindPermissionTokensByAccountId.read(reader) - 31 -> FindPermissionTokenSchema.read(reader) - 32 -> FindAllActiveTriggerIds.read(reader) - 33 -> FindTriggerById.read(reader) - 34 -> FindTriggerKeyValueByIdAndKey.read(reader) - 35 -> FindTriggersByDomainId.read(reader) - 36 -> FindAllRoles.read(reader) - 37 -> FindAllRoleIds.read(reader) - 38 -> FindRoleByRoleId.read(reader) - 39 -> FindRolesByAccountId.read(reader) - 40 -> FindAllParameters.read(reader) + 17 -> FindAssetKeyValueByIdAndKey.read(reader) + 18 -> FindAssetDefinitionKeyValueByIdAndKey.read(reader) + 19 -> FindAllDomains.read(reader) + 20 -> FindDomainById.read(reader) + 21 -> FindDomainKeyValueByIdAndKey.read(reader) + 22 -> FindAllPeers.read(reader) + 23 -> FindAllBlocks.read(reader) + 24 -> FindAllBlockHeaders.read(reader) + 25 -> FindBlockHeaderByHash.read(reader) + 26 -> FindAllTransactions.read(reader) + 27 -> FindTransactionsByAccountId.read(reader) + 28 -> FindTransactionByHash.read(reader) + 29 -> FindPermissionTokensByAccountId.read(reader) + 30 -> FindPermissionTokenSchema.read(reader) + 31 -> FindAllActiveTriggerIds.read(reader) + 32 -> FindTriggerById.read(reader) + 33 -> FindTriggerKeyValueByIdAndKey.read(reader) + 34 -> FindTriggersByDomainId.read(reader) + 35 -> FindAllRoles.read(reader) + 36 -> FindAllRoleIds.read(reader) + 37 -> FindRoleByRoleId.read(reader) + 38 -> FindRolesByAccountId.read(reader) + 39 -> FindAllParameters.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: QueryBox) { @@ -1509,38 +1473,37 @@ public sealed class QueryBox : ModelEnum { instance as FindTotalAssetQuantityByAssetDefinitionId, ) - 17 -> IsAssetDefinitionOwner.write(writer, instance as IsAssetDefinitionOwner) - 18 -> FindAssetKeyValueByIdAndKey.write(writer, instance as FindAssetKeyValueByIdAndKey) - 19 -> FindAssetDefinitionKeyValueByIdAndKey.write( + 17 -> FindAssetKeyValueByIdAndKey.write(writer, instance as FindAssetKeyValueByIdAndKey) + 18 -> FindAssetDefinitionKeyValueByIdAndKey.write( writer, instance as FindAssetDefinitionKeyValueByIdAndKey, ) - 20 -> FindAllDomains.write(writer, instance as FindAllDomains) - 21 -> FindDomainById.write(writer, instance as FindDomainById) - 22 -> FindDomainKeyValueByIdAndKey.write(writer, instance as FindDomainKeyValueByIdAndKey) - 23 -> FindAllPeers.write(writer, instance as FindAllPeers) - 24 -> FindAllBlocks.write(writer, instance as FindAllBlocks) - 25 -> FindAllBlockHeaders.write(writer, instance as FindAllBlockHeaders) - 26 -> FindBlockHeaderByHash.write(writer, instance as FindBlockHeaderByHash) - 27 -> FindAllTransactions.write(writer, instance as FindAllTransactions) - 28 -> FindTransactionsByAccountId.write(writer, instance as FindTransactionsByAccountId) - 29 -> FindTransactionByHash.write(writer, instance as FindTransactionByHash) - 30 -> FindPermissionTokensByAccountId.write( + 19 -> FindAllDomains.write(writer, instance as FindAllDomains) + 20 -> FindDomainById.write(writer, instance as FindDomainById) + 21 -> FindDomainKeyValueByIdAndKey.write(writer, instance as FindDomainKeyValueByIdAndKey) + 22 -> FindAllPeers.write(writer, instance as FindAllPeers) + 23 -> FindAllBlocks.write(writer, instance as FindAllBlocks) + 24 -> FindAllBlockHeaders.write(writer, instance as FindAllBlockHeaders) + 25 -> FindBlockHeaderByHash.write(writer, instance as FindBlockHeaderByHash) + 26 -> FindAllTransactions.write(writer, instance as FindAllTransactions) + 27 -> FindTransactionsByAccountId.write(writer, instance as FindTransactionsByAccountId) + 28 -> FindTransactionByHash.write(writer, instance as FindTransactionByHash) + 29 -> FindPermissionTokensByAccountId.write( writer, instance as FindPermissionTokensByAccountId, ) - 31 -> FindPermissionTokenSchema.write(writer, instance as FindPermissionTokenSchema) - 32 -> FindAllActiveTriggerIds.write(writer, instance as FindAllActiveTriggerIds) - 33 -> FindTriggerById.write(writer, instance as FindTriggerById) - 34 -> FindTriggerKeyValueByIdAndKey.write(writer, instance as FindTriggerKeyValueByIdAndKey) - 35 -> FindTriggersByDomainId.write(writer, instance as FindTriggersByDomainId) - 36 -> FindAllRoles.write(writer, instance as FindAllRoles) - 37 -> FindAllRoleIds.write(writer, instance as FindAllRoleIds) - 38 -> FindRoleByRoleId.write(writer, instance as FindRoleByRoleId) - 39 -> FindRolesByAccountId.write(writer, instance as FindRolesByAccountId) - 40 -> FindAllParameters.write(writer, instance as FindAllParameters) + 30 -> FindPermissionTokenSchema.write(writer, instance as FindPermissionTokenSchema) + 31 -> FindAllActiveTriggerIds.write(writer, instance as FindAllActiveTriggerIds) + 32 -> FindTriggerById.write(writer, instance as FindTriggerById) + 33 -> FindTriggerKeyValueByIdAndKey.write(writer, instance as FindTriggerKeyValueByIdAndKey) + 34 -> FindTriggersByDomainId.write(writer, instance as FindTriggersByDomainId) + 35 -> FindAllRoles.write(writer, instance as FindAllRoles) + 36 -> FindAllRoleIds.write(writer, instance as FindAllRoleIds) + 37 -> FindRoleByRoleId.write(writer, instance as FindRoleByRoleId) + 38 -> FindRolesByAccountId.write(writer, instance as FindRolesByAccountId) + 39 -> FindAllParameters.write(writer, instance as FindAllParameters) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryExecutionFail.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryExecutionFail.kt index e7b1fce7e..569f3815c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryExecutionFail.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryExecutionFail.kt @@ -9,8 +9,6 @@ import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException -import kotlin.Any -import kotlin.Boolean import kotlin.Int import kotlin.String import kotlin.Unit @@ -26,14 +24,6 @@ public sealed class QueryExecutionFail : ModelEnum { */ public abstract fun discriminant(): Int - override fun equals(other: Any?): Boolean = when (this) { - is Unauthorized -> Unauthorized.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Unauthorized -> Unauthorized.hashCode() - else -> super.hashCode() } - /** * 'Signature' variant */ @@ -162,43 +152,6 @@ public sealed class QueryExecutionFail : ModelEnum { } } - /** - * 'Unauthorized' variant - */ - public class Unauthorized : QueryExecutionFail() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 4 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Unauthorized = try { - Unauthorized() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Unauthorized, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Unauthorized, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".QueryExecutionFail.Unauthorized".hashCode() - } - } - public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): QueryExecutionFail = when ( val discriminant = @@ -208,7 +161,6 @@ public sealed class QueryExecutionFail : ModelEnum { 1 -> Evaluate.read(reader) 2 -> Find.read(reader) 3 -> Conversion.read(reader) - 4 -> Unauthorized.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: QueryExecutionFail) { @@ -218,7 +170,6 @@ public sealed class QueryExecutionFail : ModelEnum { 1 -> Evaluate.write(writer, instance as Evaluate) 2 -> Find.write(writer, instance as Find) 3 -> Conversion.write(writer, instance as Conversion) - 4 -> Unauthorized.write(writer, instance as Unauthorized) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisBlock.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisBlock.kt index 6c1691253..6ed1cb2db 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisBlock.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisBlock.kt @@ -17,14 +17,14 @@ import kotlin.collections.List * Generated from 'RawGenesisBlock' regular structure */ public data class RawGenesisBlock( - public val transactions: List>, - public val validator: ValidatorMode, + public val transactions: List>, + public val executor: ExecutorMode, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): RawGenesisBlock = try { RawGenesisBlock( - reader.readVec(reader.readCompactInt()) { reader.readVec(reader.readCompactInt()) { InstructionBox.read(reader) } }, - ValidatorMode.read(reader), + reader.readVec(reader.readCompactInt()) { reader.readVec(reader.readCompactInt()) { InstructionExpr.read(reader) } }, + ExecutorMode.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -35,10 +35,10 @@ public data class RawGenesisBlock( instance.transactions.forEach { value -> writer.writeCompact(value.size) value.forEach { value -> - InstructionBox.write(writer, value) + InstructionExpr.write(writer, value) } } - ValidatorMode.write(writer, instance.validator) + ExecutorMode.write(writer, instance.executor) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt similarity index 71% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt index b2fceb700..612db06ce 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * RegisterBox + * RegisterExpr * - * Generated from 'RegisterBox' regular structure + * Generated from 'RegisterExpr' regular structure */ -public data class RegisterBox( +public data class RegisterExpr( public val `object`: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RegisterBox = try { - RegisterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterExpr = try { + RegisterExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: RegisterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: RegisterExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegistrableBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegistrableBox.kt index e35b3d63b..acb40bf5a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegistrableBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegistrableBox.kt @@ -187,7 +187,7 @@ public sealed class RegistrableBox : ModelEnum { * 'Trigger' variant */ public data class Trigger( - public val triggerOfTriggeringFilterBoxAndExecutable: TriggerOfTriggeringFilterBoxAndExecutable, + public val triggerOfTriggeringFilterBox: TriggerOfTriggeringFilterBox, ) : RegistrableBox() { override fun discriminant(): Int = DISCRIMINANT @@ -198,7 +198,7 @@ public sealed class RegistrableBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegistrableBox.Trigger = try { Trigger( - TriggerOfTriggeringFilterBoxAndExecutable.read(reader), + TriggerOfTriggeringFilterBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -208,10 +208,7 @@ public sealed class RegistrableBox : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Trigger, ): Unit = try { - TriggerOfTriggeringFilterBoxAndExecutable.write( - writer, - instance.triggerOfTriggeringFilterBoxAndExecutable, - ) + TriggerOfTriggeringFilterBox.write(writer, instance.triggerOfTriggeringFilterBox) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt similarity index 77% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt index 37144f7a8..d15252320 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt @@ -11,17 +11,17 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * RemoveKeyValueBox + * RemoveKeyValueExpr * - * Generated from 'RemoveKeyValueBox' regular structure + * Generated from 'RemoveKeyValueExpr' regular structure */ -public data class RemoveKeyValueBox( +public data class RemoveKeyValueExpr( public val objectId: EvaluatesTo, public val key: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RemoveKeyValueBox = try { - RemoveKeyValueBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueExpr = try { + RemoveKeyValueExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, ) @@ -29,7 +29,7 @@ public data class RemoveKeyValueBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueExpr): Unit = try { EvaluatesTo.write(writer, instance.objectId) EvaluatesTo.write(writer, instance.key) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.kt similarity index 66% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.kt index 51b815a85..fff39018f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.kt @@ -11,25 +11,25 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * RevokeBox + * RevokeExpr * - * Generated from 'RevokeBox' regular structure + * Generated from 'RevokeExpr' regular structure */ -public data class RevokeBox( +public data class RevokeExpr( public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, + public val destinationId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RevokeBox = try { - RevokeBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RevokeExpr = try { + RevokeExpr( EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: RevokeBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: RevokeExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) EvaluatesTo.write(writer, instance.destinationId) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.kt similarity index 65% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.kt index 890a57102..237dec6fb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.kt @@ -12,26 +12,26 @@ import kotlin.Unit import kotlin.collections.List /** - * SequenceBox + * SequenceExpr * - * Generated from 'SequenceBox' regular structure + * Generated from 'SequenceExpr' regular structure */ -public data class SequenceBox( - public val instructions: List, +public data class SequenceExpr( + public val instructions: List, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SequenceBox = try { - SequenceBox( - reader.readVec(reader.readCompactInt()) { InstructionBox.read(reader) }, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SequenceExpr = try { + SequenceExpr( + reader.readVec(reader.readCompactInt()) { InstructionExpr.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SequenceBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: SequenceExpr): Unit = try { writer.writeCompact(instance.instructions.size) instance.instructions.forEach { value -> - InstructionBox.write(writer, value) + InstructionExpr.write(writer, value) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.kt similarity index 81% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.kt index dbdd7c68d..85424f801 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.kt @@ -11,18 +11,18 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * SetKeyValueBox + * SetKeyValueExpr * - * Generated from 'SetKeyValueBox' regular structure + * Generated from 'SetKeyValueExpr' regular structure */ -public data class SetKeyValueBox( +public data class SetKeyValueExpr( public val objectId: EvaluatesTo, public val key: EvaluatesTo, public val `value`: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SetKeyValueBox = try { - SetKeyValueBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueExpr = try { + SetKeyValueExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, @@ -31,7 +31,7 @@ public data class SetKeyValueBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SetKeyValueBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueExpr): Unit = try { EvaluatesTo.write(writer, instance.objectId) EvaluatesTo.write(writer, instance.key) EvaluatesTo.write(writer, instance.`value`) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt similarity index 75% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt index 3452435ee..3b8f842a4 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * SetParameterBox + * SetParameterExpr * - * Generated from 'SetParameterBox' regular structure + * Generated from 'SetParameterExpr' regular structure */ -public data class SetParameterBox( +public data class SetParameterExpr( public val parameter: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SetParameterBox = try { - SetParameterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetParameterExpr = try { + SetParameterExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SetParameterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: SetParameterExpr): Unit = try { EvaluatesTo.write(writer, instance.parameter) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignatureCheckCondition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignatureCheckCondition.kt index 8da9a6ee8..17ee559d8 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignatureCheckCondition.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignatureCheckCondition.kt @@ -3,37 +3,114 @@ // package jp.co.soramitsu.iroha2.generated +import jp.co.soramitsu.iroha2.ModelEnum import jp.co.soramitsu.iroha2.codec.ScaleCodecReader import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException -import kotlin.Boolean +import kotlin.Int import kotlin.Unit +import kotlin.collections.List /** * SignatureCheckCondition * - * Generated from 'SignatureCheckCondition' regular structure + * Generated from 'SignatureCheckCondition' enum */ -public data class SignatureCheckCondition( - public val evaluatesToOfBool: EvaluatesTo, -) { +public sealed class SignatureCheckCondition : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'AnyAccountSignatureOr' variant + */ + public data class AnyAccountSignatureOr( + public val vec: List, + ) : SignatureCheckCondition() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 0 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.AnyAccountSignatureOr = try { + AnyAccountSignatureOr( + reader.readVec(reader.readCompactInt()) { PublicKey.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.AnyAccountSignatureOr, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + PublicKey.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AllAccountSignaturesAnd' variant + */ + public data class AllAccountSignaturesAnd( + public val vec: List, + ) : SignatureCheckCondition() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 1 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.AllAccountSignaturesAnd = try { + AllAccountSignaturesAnd( + reader.readVec(reader.readCompactInt()) { PublicKey.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.AllAccountSignaturesAnd, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + PublicKey.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SignatureCheckCondition = try { - SignatureCheckCondition( - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): SignatureCheckCondition = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> AnyAccountSignatureOr.read(reader) + 1 -> AllAccountSignaturesAnd.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: SignatureCheckCondition): Unit = try { - EvaluatesTo.write(writer, instance.evaluatesToOfBool) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: SignatureCheckCondition) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> AnyAccountSignatureOr.write(writer, instance as AnyAccountSignatureOr) + 1 -> AllAccountSignaturesAnd.write(writer, instance as AllAccountSignaturesAnd) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfCommittedBlock.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfBlockPayload.kt similarity index 70% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfCommittedBlock.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfBlockPayload.kt index ad1ca8b05..7430296b9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfCommittedBlock.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfBlockPayload.kt @@ -13,28 +13,28 @@ import kotlin.Unit import kotlin.collections.List /** - * SignaturesOfOfCommittedBlock + * SignaturesOfOfBlockPayload * - * Generated from 'SignaturesOfOfCommittedBlock' regular structure + * Generated from 'SignaturesOfOfBlockPayload' regular structure */ -public data class SignaturesOfOfCommittedBlock( - public val signatures: List>, +public data class SignaturesOfOfBlockPayload( + public val signatures: List>, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): SignaturesOfOfCommittedBlock = try { - SignaturesOfOfCommittedBlock( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): SignaturesOfOfBlockPayload = try { + SignaturesOfOfBlockPayload( reader.readVec(reader.readCompactInt()) { SignatureOf.read(reader) as - SignatureOf + SignatureOf }, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SignaturesOfOfCommittedBlock): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: SignaturesOfOfBlockPayload): Unit = try { writer.writeCompact(instance.signatures.size) instance.signatures.sortedWith( SignatureOf.comparator(), diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedQuery.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlock.kt similarity index 59% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedQuery.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlock.kt index 996f1601c..78e399da4 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedQuery.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlock.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * VersionedSignedQuery + * SignedBlock * - * Generated from 'VersionedSignedQuery' enum + * Generated from 'SignedBlock' enum */ -public sealed class VersionedSignedQuery : ModelEnum { +public sealed class SignedBlock : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,43 +27,44 @@ public sealed class VersionedSignedQuery : ModelEnum { * 'V1' variant */ public data class V1( - public val signedQuery: SignedQuery, - ) : VersionedSignedQuery() { + public val signedBlockV1: SignedBlockV1, + ) : SignedBlock() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 1 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedSignedQuery.V1 = try { - V1( - SignedQuery.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SignedBlock.V1 = + try { + V1( + SignedBlockV1.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedSignedQuery.V1, + instance: jp.co.soramitsu.iroha2.generated.SignedBlock.V1, ): Unit = try { - SignedQuery.write(writer, instance.signedQuery) + SignedBlockV1.write(writer, instance.signedBlockV1) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedSignedQuery = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedBlock = when ( val discriminant = reader.readUByte() ) { 1 -> V1.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: VersionedSignedQuery) { + override fun write(writer: ScaleCodecWriter, instance: SignedBlock) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 1 -> V1.write(writer, instance as V1) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockV1.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockV1.kt new file mode 100644 index 000000000..f09cae599 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockV1.kt @@ -0,0 +1,39 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit + +/** + * SignedBlockV1 + * + * Generated from 'SignedBlockV1' regular structure + */ +public data class SignedBlockV1( + public val signatures: SignaturesOfOfBlockPayload, + public val payload: BlockPayload, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedBlockV1 = try { + SignedBlockV1( + SignaturesOfOfBlockPayload.read(reader), + BlockPayload.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SignedBlockV1): Unit = try { + SignaturesOfOfBlockPayload.write(writer, instance.signatures) + BlockPayload.write(writer, instance.payload) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQuery.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQuery.kt index 0e9ecd370..5a7bb5853 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQuery.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQuery.kt @@ -3,37 +3,72 @@ // package jp.co.soramitsu.iroha2.generated +import jp.co.soramitsu.iroha2.ModelEnum import jp.co.soramitsu.iroha2.codec.ScaleCodecReader import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException +import kotlin.Int import kotlin.Unit /** * SignedQuery * - * Generated from 'SignedQuery' regular structure + * Generated from 'SignedQuery' enum */ -public data class SignedQuery( - public val signature: SignatureOf, - public val payload: QueryPayload, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SignedQuery = try { - SignedQuery( - SignatureOf.read(reader) as SignatureOf, - QueryPayload.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) +public sealed class SignedQuery : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'V1' variant + */ + public data class V1( + public val signedQueryV1: SignedQueryV1, + ) : SignedQuery() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 1 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SignedQuery.V1 = + try { + V1( + SignedQueryV1.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignedQuery.V1, + ): Unit = try { + SignedQueryV1.write(writer, instance.signedQueryV1) + } catch (ex: Exception) { + throw wrapException(ex) + } } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedQuery = when ( + val discriminant = + reader.readUByte() + ) { + 1 -> V1.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: SignedQuery): Unit = try { - SignatureOf.write(writer, instance.signature) - QueryPayload.write(writer, instance.payload) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: SignedQuery) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 1 -> V1.write(writer, instance as V1) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQueryV1.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQueryV1.kt new file mode 100644 index 000000000..f483dd170 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedQueryV1.kt @@ -0,0 +1,39 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit + +/** + * SignedQueryV1 + * + * Generated from 'SignedQueryV1' regular structure + */ +public data class SignedQueryV1( + public val signature: SignatureOf, + public val payload: QueryPayload, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedQueryV1 = try { + SignedQueryV1( + SignatureOf.read(reader) as SignatureOf, + QueryPayload.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SignedQueryV1): Unit = try { + SignatureOf.write(writer, instance.signature) + QueryPayload.write(writer, instance.payload) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransaction.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransaction.kt index 95cf0efab..18c1ad006 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransaction.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransaction.kt @@ -3,37 +3,71 @@ // package jp.co.soramitsu.iroha2.generated +import jp.co.soramitsu.iroha2.ModelEnum import jp.co.soramitsu.iroha2.codec.ScaleCodecReader import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException +import kotlin.Int import kotlin.Unit /** * SignedTransaction * - * Generated from 'SignedTransaction' regular structure + * Generated from 'SignedTransaction' enum */ -public data class SignedTransaction( - public val signatures: SignaturesOfOfTransactionPayload, - public val payload: TransactionPayload, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SignedTransaction = try { - SignedTransaction( - SignaturesOfOfTransactionPayload.read(reader), - TransactionPayload.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) +public sealed class SignedTransaction : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'V1' variant + */ + public data class V1( + public val signedTransactionV1: SignedTransactionV1, + ) : SignedTransaction() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 1 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SignedTransaction.V1 = try { + V1( + SignedTransactionV1.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignedTransaction.V1, + ): Unit = try { + SignedTransactionV1.write(writer, instance.signedTransactionV1) + } catch (ex: Exception) { + throw wrapException(ex) + } } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedTransaction = when ( + val discriminant = + reader.readUByte() + ) { + 1 -> V1.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: SignedTransaction): Unit = try { - SignaturesOfOfTransactionPayload.write(writer, instance.signatures) - TransactionPayload.write(writer, instance.payload) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: SignedTransaction) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 1 -> V1.write(writer, instance as V1) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionV1.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionV1.kt new file mode 100644 index 000000000..063f577d6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionV1.kt @@ -0,0 +1,39 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit + +/** + * SignedTransactionV1 + * + * Generated from 'SignedTransactionV1' regular structure + */ +public data class SignedTransactionV1( + public val signatures: SignaturesOfOfTransactionPayload, + public val payload: TransactionPayload, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedTransactionV1 = try { + SignedTransactionV1( + SignaturesOfOfTransactionPayload.read(reader), + TransactionPayload.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SignedTransactionV1): Unit = try { + SignaturesOfOfTransactionPayload.write(writer, instance.signatures) + TransactionPayload.write(writer, instance.payload) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutput.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutput.kt index 11e06e8cc..d993ec685 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutput.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutput.kt @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'TransactionQueryOutput' regular structure */ public data class TransactionQueryOutput( + public val blockHash: HashOf, public val transaction: TransactionValue, - public val blockHash: HashOf, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TransactionQueryOutput = try { TransactionQueryOutput( + HashOf.read(reader) as HashOf, TransactionValue.read(reader), - HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: TransactionQueryOutput): Unit = try { - TransactionValue.write(writer, instance.transaction) HashOf.write(writer, instance.blockHash) + TransactionValue.write(writer, instance.transaction) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionRejectionReason.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionRejectionReason.kt index c2783266f..1b0d8b50d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionRejectionReason.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionRejectionReason.kt @@ -26,12 +26,10 @@ public sealed class TransactionRejectionReason : ModelEnum { public abstract fun discriminant(): Int override fun equals(other: Any?): Boolean = when (this) { - is UnexpectedGenesisAccountSignature -> UnexpectedGenesisAccountSignature.equals(this, other) is Expired -> Expired.equals(this, other) else -> super.equals(other) } override fun hashCode(): Int = when (this) { - is UnexpectedGenesisAccountSignature -> UnexpectedGenesisAccountSignature.hashCode() is Expired -> Expired.hashCode() else -> super.hashCode() } @@ -197,44 +195,6 @@ public sealed class TransactionRejectionReason : ModelEnum { } } - /** - * 'UnexpectedGenesisAccountSignature' variant - */ - public class UnexpectedGenesisAccountSignature : TransactionRejectionReason() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 5 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.UnexpectedGenesisAccountSignature = try { - UnexpectedGenesisAccountSignature() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.UnexpectedGenesisAccountSignature, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.UnexpectedGenesisAccountSignature, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = - ".TransactionRejectionReason.UnexpectedGenesisAccountSignature".hashCode() - } - } - /** * 'Expired' variant */ @@ -244,7 +204,7 @@ public sealed class TransactionRejectionReason : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 6 + public const val DISCRIMINANT: Int = 5 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.Expired = try { Expired() @@ -284,8 +244,7 @@ public sealed class TransactionRejectionReason : ModelEnum { 2 -> Validation.read(reader) 3 -> InstructionExecution.read(reader) 4 -> WasmExecution.read(reader) - 5 -> UnexpectedGenesisAccountSignature.read(reader) - 6 -> Expired.read(reader) + 5 -> Expired.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: TransactionRejectionReason) { @@ -296,12 +255,7 @@ public sealed class TransactionRejectionReason : ModelEnum { 2 -> Validation.write(writer, instance as Validation) 3 -> InstructionExecution.write(writer, instance as InstructionExecution) 4 -> WasmExecution.write(writer, instance as WasmExecution) - 5 -> UnexpectedGenesisAccountSignature.write( - writer, - instance as - UnexpectedGenesisAccountSignature, - ) - 6 -> Expired.write(writer, instance as Expired) + 5 -> Expired.write(writer, instance as Expired) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionValue.kt index 8520d93f4..322e720ec 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionValue.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionValue.kt @@ -16,13 +16,13 @@ import kotlin.Unit * Generated from 'TransactionValue' regular structure */ public data class TransactionValue( - public val `value`: VersionedSignedTransaction, + public val `value`: SignedTransaction, public val error: TransactionRejectionReason? = null, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TransactionValue = try { TransactionValue( - VersionedSignedTransaction.read(reader), + SignedTransaction.read(reader), reader.readNullable(TransactionRejectionReason) as TransactionRejectionReason?, ) } catch (ex: Exception) { @@ -30,7 +30,7 @@ public data class TransactionValue( } override fun write(writer: ScaleCodecWriter, instance: TransactionValue): Unit = try { - VersionedSignedTransaction.write(writer, instance.`value`) + SignedTransaction.write(writer, instance.`value`) writer.writeNullable(TransactionRejectionReason, instance.error) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.kt similarity index 78% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.kt index b5145fafe..405492889 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.kt @@ -11,18 +11,18 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * TransferBox + * TransferExpr * - * Generated from 'TransferBox' regular structure + * Generated from 'TransferExpr' regular structure */ -public data class TransferBox( +public data class TransferExpr( public val sourceId: EvaluatesTo, public val `object`: EvaluatesTo, public val destinationId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TransferBox = try { - TransferBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferExpr = try { + TransferExpr( EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, EvaluatesTo.read(reader) as EvaluatesTo, @@ -31,7 +31,7 @@ public data class TransferBox( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: TransferBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: TransferExpr): Unit = try { EvaluatesTo.write(writer, instance.sourceId) EvaluatesTo.write(writer, instance.`object`) EvaluatesTo.write(writer, instance.destinationId) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerBox.kt deleted file mode 100644 index 96cc19de0..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerBox.kt +++ /dev/null @@ -1,115 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * TriggerBox - * - * Generated from 'TriggerBox' enum - */ -public sealed class TriggerBox : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'Raw' variant - */ - public data class Raw( - public val triggerOfTriggeringFilterBoxAndExecutable: TriggerOfTriggeringFilterBoxAndExecutable, - ) : TriggerBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 0 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggerBox.Raw = - try { - Raw( - TriggerOfTriggeringFilterBoxAndExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerBox.Raw, - ): Unit = try { - TriggerOfTriggeringFilterBoxAndExecutable.write( - writer, - instance.triggerOfTriggeringFilterBoxAndExecutable, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Optimized' variant - */ - public data class Optimized( - public val triggerOfTriggeringFilterBoxAndOptimizedExecutable: - TriggerOfTriggeringFilterBoxAndOptimizedExecutable, - ) : TriggerBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggerBox.Optimized = try { - Optimized( - TriggerOfTriggeringFilterBoxAndOptimizedExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerBox.Optimized, - ): Unit = try { - TriggerOfTriggeringFilterBoxAndOptimizedExecutable.write( - writer, - instance.triggerOfTriggeringFilterBoxAndOptimizedExecutable, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerBox = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Raw.read(reader) - 1 -> Optimized.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: TriggerBox) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Raw.write(writer, instance as Raw) - 1 -> Optimized.write(writer, instance as Optimized) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerId.kt index a1fd1b661..44d1ddb4f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerId.kt @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'TriggerId' regular structure */ public data class TriggerId( - public val name: Name, public val domainId: DomainId? = null, + public val name: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TriggerId = try { TriggerId( - Name.read(reader), reader.readNullable(DomainId) as DomainId?, + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: TriggerId): Unit = try { - Name.write(writer, instance.name) writer.writeNullable(DomainId, instance.domainId) + Name.write(writer, instance.name) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndExecutable.kt deleted file mode 100644 index 87cb6ea18..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndExecutable.kt +++ /dev/null @@ -1,42 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * TriggerOfFilterBoxAndExecutable - * - * Generated from 'TriggerOfFilterBoxAndExecutable' regular structure - */ -public data class TriggerOfFilterBoxAndExecutable( - public val id: TriggerId, - public val action: ActionOfFilterBoxAndExecutable, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerOfFilterBoxAndExecutable = try { - TriggerOfFilterBoxAndExecutable( - TriggerId.read(reader), - ActionOfFilterBoxAndExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: TriggerOfFilterBoxAndExecutable): Unit = - try { - TriggerId.write(writer, instance.id) - ActionOfFilterBoxAndExecutable.write(writer, instance.action) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndOptimizedExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndOptimizedExecutable.kt deleted file mode 100644 index 23d8a6e57..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfFilterBoxAndOptimizedExecutable.kt +++ /dev/null @@ -1,44 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * TriggerOfFilterBoxAndOptimizedExecutable - * - * Generated from 'TriggerOfFilterBoxAndOptimizedExecutable' regular structure - */ -public data class TriggerOfFilterBoxAndOptimizedExecutable( - public val id: TriggerId, - public val action: ActionOfFilterBoxAndOptimizedExecutable, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerOfFilterBoxAndOptimizedExecutable = try { - TriggerOfFilterBoxAndOptimizedExecutable( - TriggerId.read(reader), - ActionOfFilterBoxAndOptimizedExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: TriggerOfFilterBoxAndOptimizedExecutable, - ): Unit = try { - TriggerId.write(writer, instance.id) - ActionOfFilterBoxAndOptimizedExecutable.write(writer, instance.action) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBox.kt new file mode 100644 index 000000000..f5d23a373 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBox.kt @@ -0,0 +1,41 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit + +/** + * TriggerOfTriggeringFilterBox + * + * Generated from 'TriggerOfTriggeringFilterBox' regular structure + */ +public data class TriggerOfTriggeringFilterBox( + public val id: TriggerId, + public val action: ActionOfTriggeringFilterBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TriggerOfTriggeringFilterBox = try { + TriggerOfTriggeringFilterBox( + TriggerId.read(reader), + ActionOfTriggeringFilterBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TriggerOfTriggeringFilterBox): Unit = try { + TriggerId.write(writer, instance.id) + ActionOfTriggeringFilterBox.write(writer, instance.action) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndExecutable.kt deleted file mode 100644 index a4e113e9f..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndExecutable.kt +++ /dev/null @@ -1,44 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * TriggerOfTriggeringFilterBoxAndExecutable - * - * Generated from 'TriggerOfTriggeringFilterBoxAndExecutable' regular structure - */ -public data class TriggerOfTriggeringFilterBoxAndExecutable( - public val id: TriggerId, - public val action: ActionOfTriggeringFilterBoxAndExecutable, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerOfTriggeringFilterBoxAndExecutable = try { - TriggerOfTriggeringFilterBoxAndExecutable( - TriggerId.read(reader), - ActionOfTriggeringFilterBoxAndExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: TriggerOfTriggeringFilterBoxAndExecutable, - ): Unit = try { - TriggerId.write(writer, instance.id) - ActionOfTriggeringFilterBoxAndExecutable.write(writer, instance.action) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndOptimizedExecutable.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndOptimizedExecutable.kt deleted file mode 100644 index 4656be789..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBoxAndOptimizedExecutable.kt +++ /dev/null @@ -1,44 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit - -/** - * TriggerOfTriggeringFilterBoxAndOptimizedExecutable - * - * Generated from 'TriggerOfTriggeringFilterBoxAndOptimizedExecutable' regular structure - */ -public data class TriggerOfTriggeringFilterBoxAndOptimizedExecutable( - public val id: TriggerId, - public val action: ActionOfTriggeringFilterBoxAndOptimizedExecutable, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerOfTriggeringFilterBoxAndOptimizedExecutable = try { - TriggerOfTriggeringFilterBoxAndOptimizedExecutable( - TriggerId.read(reader), - ActionOfTriggeringFilterBoxAndOptimizedExecutable.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: TriggerOfTriggeringFilterBoxAndOptimizedExecutable, - ): Unit = try { - TriggerId.write(writer, instance.id) - ActionOfTriggeringFilterBoxAndOptimizedExecutable.write(writer, instance.action) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UniqueVec.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UniqueVec.kt new file mode 100644 index 000000000..c8cc42729 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UniqueVec.kt @@ -0,0 +1,41 @@ +// +// Auto-generated file. DO NOT EDIT! +// +package jp.co.soramitsu.iroha2.generated + +import jp.co.soramitsu.iroha2.codec.ScaleCodecReader +import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter +import jp.co.soramitsu.iroha2.codec.ScaleReader +import jp.co.soramitsu.iroha2.codec.ScaleWriter +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Any +import kotlin.Unit +import kotlin.collections.List + +/** + * UniqueVec + * + * Generated from 'UniqueVec' regular structure + */ +public data class UniqueVec( + public val vecOfPeerId: List, +) { + public companion object : ScaleReader>, ScaleWriter> { + override fun read(reader: ScaleCodecReader): UniqueVec = try { + UniqueVec( + reader.readVec(reader.readCompactInt()) { PeerId.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: UniqueVec): Unit = try { + writer.writeCompact(instance.vecOfPeerId.size) + instance.vecOfPeerId.forEach { value -> + PeerId.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt similarity index 70% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt index a1afd5ae2..a89bc5ac7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * UnregisterBox + * UnregisterExpr * - * Generated from 'UnregisterBox' regular structure + * Generated from 'UnregisterExpr' regular structure */ -public data class UnregisterBox( +public data class UnregisterExpr( public val objectId: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): UnregisterBox = try { - UnregisterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterExpr = try { + UnregisterExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: UnregisterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: UnregisterExpr): Unit = try { EvaluatesTo.write(writer, instance.objectId) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradableBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradableBox.kt index 27c8603cb..6c1c27085 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradableBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradableBox.kt @@ -24,21 +24,21 @@ public sealed class UpgradableBox : ModelEnum { public abstract fun discriminant(): Int /** - * 'Validator' variant + * 'Executor' variant */ - public data class Validator( - public val validator: jp.co.soramitsu.iroha2.generated.Validator, + public data class Executor( + public val executor: jp.co.soramitsu.iroha2.generated.Executor, ) : UpgradableBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 0 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.UpgradableBox.Validator = try { - Validator( - jp.co.soramitsu.iroha2.generated.Validator.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.UpgradableBox.Executor = try { + Executor( + jp.co.soramitsu.iroha2.generated.Executor.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class UpgradableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.UpgradableBox.Validator, + instance: jp.co.soramitsu.iroha2.generated.UpgradableBox.Executor, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Validator.write(writer, instance.validator) + jp.co.soramitsu.iroha2.generated.Executor.write(writer, instance.executor) } catch (ex: Exception) { throw wrapException(ex) } @@ -60,13 +60,13 @@ public sealed class UpgradableBox : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Validator.read(reader) + 0 -> Executor.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: UpgradableBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Validator.write(writer, instance as Validator) + 0 -> Executor.write(writer, instance as Executor) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt similarity index 72% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt index 12a0562e6..0847a02ad 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * UpgradeBox + * UpgradeExpr * - * Generated from 'UpgradeBox' regular structure + * Generated from 'UpgradeExpr' regular structure */ -public data class UpgradeBox( +public data class UpgradeExpr( public val `object`: EvaluatesTo, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): UpgradeBox = try { - UpgradeBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UpgradeExpr = try { + UpgradeExpr( EvaluatesTo.read(reader) as EvaluatesTo, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: UpgradeBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: UpgradeExpr): Unit = try { EvaluatesTo.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Value.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Value.kt index d042efb84..5ed881ba1 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Value.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Value.kt @@ -554,7 +554,7 @@ public sealed class Value : ModelEnum { * 'Block' variant */ public data class Block( - public val versionedCommittedBlock: VersionedCommittedBlock, + public val signedBlock: SignedBlock, ) : Value() { override fun discriminant(): Int = DISCRIMINANT @@ -566,7 +566,7 @@ public sealed class Value : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Block = try { Block( - VersionedCommittedBlock.read(reader), + SignedBlock.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -576,7 +576,7 @@ public sealed class Value : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.Value.Block, ): Unit = try { - VersionedCommittedBlock.write(writer, instance.versionedCommittedBlock) + SignedBlock.write(writer, instance.signedBlock) } catch (ex: Exception) { throw wrapException(ex) } @@ -715,31 +715,32 @@ public sealed class Value : ModelEnum { } /** - * 'Validator' variant + * 'Executor' variant */ - public data class Validator( - public val validator: jp.co.soramitsu.iroha2.generated.Validator, + public data class Executor( + public val executor: jp.co.soramitsu.iroha2.generated.Executor, ) : Value() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 21 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Validator = try { - Validator( - jp.co.soramitsu.iroha2.generated.Validator.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Executor = + try { + Executor( + jp.co.soramitsu.iroha2.generated.Executor.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Validator, + instance: jp.co.soramitsu.iroha2.generated.Value.Executor, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Validator.write(writer, instance.validator) + jp.co.soramitsu.iroha2.generated.Executor.write(writer, instance.executor) } catch (ex: Exception) { throw wrapException(ex) } @@ -802,7 +803,7 @@ public sealed class Value : ModelEnum { 18 -> Ipv4Addr.read(reader) 19 -> Ipv6Addr.read(reader) 20 -> Numeric.read(reader) - 21 -> Validator.read(reader) + 21 -> Executor.read(reader) 22 -> LogLevel.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } @@ -830,7 +831,7 @@ public sealed class Value : ModelEnum { 18 -> Ipv4Addr.write(writer, instance as Ipv4Addr) 19 -> Ipv6Addr.write(writer, instance as Ipv6Addr) 20 -> Numeric.write(writer, instance as Numeric) - 21 -> Validator.write(writer, instance as Validator) + 21 -> Executor.write(writer, instance as Executor) 22 -> LogLevel.write(writer, instance as LogLevel) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponse.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponse.kt deleted file mode 100644 index 9ea848f21..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponse.kt +++ /dev/null @@ -1,77 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Any -import kotlin.Int -import kotlin.Unit -import kotlin.collections.List - -/** - * VersionedBatchedResponse - * - * Generated from 'VersionedBatchedResponse>' enum - */ -public sealed class VersionedBatchedResponse : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val batchedResponse: BatchedResponse>, - ) : VersionedBatchedResponse>() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedBatchedResponse.V1 = try { - V1( - BatchedResponse.read(reader) as BatchedResponse>, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedBatchedResponse.V1, - ): Unit = try { - BatchedResponse.write(writer, instance.batchedResponse) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader>, - ScaleWriter> { - override fun read(reader: ScaleCodecReader): VersionedBatchedResponse = when ( - val - discriminant = reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedBatchedResponse) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponseOfValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponseOfValue.kt deleted file mode 100644 index 0fbf69d96..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBatchedResponseOfValue.kt +++ /dev/null @@ -1,75 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedBatchedResponseOfValue - * - * Generated from 'VersionedBatchedResponseOfValue' enum - */ -public sealed class VersionedBatchedResponseOfValue : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val batchedResponseOfValue: BatchedResponseOfValue, - ) : VersionedBatchedResponseOfValue() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedBatchedResponseOfValue.V1 = try { - V1( - BatchedResponseOfValue.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedBatchedResponseOfValue.V1, - ): Unit = try { - BatchedResponseOfValue.write(writer, instance.batchedResponseOfValue) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedBatchedResponseOfValue = when ( - val - discriminant = reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedBatchedResponseOfValue) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockMessage.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockMessage.kt deleted file mode 100644 index 78bbd6eaf..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockMessage.kt +++ /dev/null @@ -1,73 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedBlockMessage - * - * Generated from 'VersionedBlockMessage' enum - */ -public sealed class VersionedBlockMessage : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val blockMessage: BlockMessage, - ) : VersionedBlockMessage() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedBlockMessage.V1 = try { - V1( - BlockMessage.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedBlockMessage.V1, - ): Unit = try { - BlockMessage.write(writer, instance.blockMessage) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedBlockMessage = when ( - val discriminant = - reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedBlockMessage) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockSubscriptionRequest.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockSubscriptionRequest.kt deleted file mode 100644 index aa88f6389..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedBlockSubscriptionRequest.kt +++ /dev/null @@ -1,76 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedBlockSubscriptionRequest - * - * Generated from 'VersionedBlockSubscriptionRequest' enum - */ -public sealed class VersionedBlockSubscriptionRequest : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val blockSubscriptionRequest: BlockSubscriptionRequest, - ) : VersionedBlockSubscriptionRequest() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedBlockSubscriptionRequest.V1 = try { - V1( - BlockSubscriptionRequest.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedBlockSubscriptionRequest.V1, - ): Unit = - try { - BlockSubscriptionRequest.write(writer, instance.blockSubscriptionRequest) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedBlockSubscriptionRequest = when ( - val - discriminant = reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedBlockSubscriptionRequest) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedCommittedBlock.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedCommittedBlock.kt deleted file mode 100644 index 2dca11c52..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedCommittedBlock.kt +++ /dev/null @@ -1,75 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedCommittedBlock - * - * Generated from 'VersionedCommittedBlock' enum - */ -public sealed class VersionedCommittedBlock : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val committedBlock: CommittedBlock, - ) : VersionedCommittedBlock() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock.V1 = try { - V1( - CommittedBlock.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedCommittedBlock.V1, - ): Unit = try { - CommittedBlock.write(writer, instance.committedBlock) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedCommittedBlock = when ( - val discriminant = - reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedCommittedBlock) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventMessage.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventMessage.kt deleted file mode 100644 index 44323a294..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventMessage.kt +++ /dev/null @@ -1,73 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedEventMessage - * - * Generated from 'VersionedEventMessage' enum - */ -public sealed class VersionedEventMessage : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val eventMessage: EventMessage, - ) : VersionedEventMessage() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedEventMessage.V1 = try { - V1( - EventMessage.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedEventMessage.V1, - ): Unit = try { - EventMessage.write(writer, instance.eventMessage) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedEventMessage = when ( - val discriminant = - reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedEventMessage) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventSubscriptionRequest.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventSubscriptionRequest.kt deleted file mode 100644 index 600f53d95..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedEventSubscriptionRequest.kt +++ /dev/null @@ -1,76 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedEventSubscriptionRequest - * - * Generated from 'VersionedEventSubscriptionRequest' enum - */ -public sealed class VersionedEventSubscriptionRequest : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val eventSubscriptionRequest: EventSubscriptionRequest, - ) : VersionedEventSubscriptionRequest() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedEventSubscriptionRequest.V1 = try { - V1( - EventSubscriptionRequest.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedEventSubscriptionRequest.V1, - ): Unit = - try { - EventSubscriptionRequest.write(writer, instance.eventSubscriptionRequest) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedEventSubscriptionRequest = when ( - val - discriminant = reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedEventSubscriptionRequest) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedTransaction.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedTransaction.kt deleted file mode 100644 index 350d034de..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/VersionedSignedTransaction.kt +++ /dev/null @@ -1,75 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.ModelEnum -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Int -import kotlin.Unit - -/** - * VersionedSignedTransaction - * - * Generated from 'VersionedSignedTransaction' enum - */ -public sealed class VersionedSignedTransaction : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'V1' variant - */ - public data class V1( - public val signedTransaction: SignedTransaction, - ) : VersionedSignedTransaction() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction.V1 = try { - V1( - SignedTransaction.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.VersionedSignedTransaction.V1, - ): Unit = try { - SignedTransaction.write(writer, instance.signedTransaction) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): VersionedSignedTransaction = when ( - val discriminant = - reader.readUByte() - ) { - 1 -> V1.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: VersionedSignedTransaction) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmInternalRepr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmInternalRepr.kt deleted file mode 100644 index edc0981a9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmInternalRepr.kt +++ /dev/null @@ -1,40 +0,0 @@ -// -// Auto-generated file. DO NOT EDIT! -// -package jp.co.soramitsu.iroha2.generated - -import jp.co.soramitsu.iroha2.codec.ScaleCodecReader -import jp.co.soramitsu.iroha2.codec.ScaleCodecWriter -import jp.co.soramitsu.iroha2.codec.ScaleReader -import jp.co.soramitsu.iroha2.codec.ScaleWriter -import jp.co.soramitsu.iroha2.wrapException -import kotlin.ByteArray -import kotlin.Unit - -/** - * WasmInternalRepr - * - * Generated from 'WasmInternalRepr' regular structure - */ -public data class WasmInternalRepr( - public val serialized: ByteArray, - public val blobHash: HashOf, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): WasmInternalRepr = try { - WasmInternalRepr( - reader.readByteArray(), - HashOf.read(reader) as HashOf, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: WasmInternalRepr): Unit = try { - writer.writeAsList(instance.serialized) - HashOf.write(writer, instance.blobHash) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaContainer.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaContainer.kt index 4ab87fe2e..2df4d251f 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaContainer.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaContainer.kt @@ -71,8 +71,8 @@ open class IrohaContainer : GenericContainer { config.genesis?.writeToFile(genesisFileLocation) config.genesisPath?.also { path -> Files.copy(Path(path).toAbsolutePath(), genesisFileLocation) } - getResource(DEFAULT_VALIDATOR_FILE_NAME).readBytes().let { content -> - validatorFileLocation.toFile().writeBytes(content) + getResource(DEFAULT_EXECUTOR_FILE_NAME).readBytes().let { content -> + executorFileLocation.toFile().writeBytes(content) } getResource(DEFAULT_CONFIG_FILE_NAME).readBytes().let { content -> configFileLocation.toFile().writeBytes(content) @@ -91,7 +91,7 @@ open class IrohaContainer : GenericContainer { // await genesis was applied and seen in status HttpWaitStrategy() .forStatusCode(200) - .forPort(telemetryPort) + .forPort(apiPort) .forPath(STATUS_ENDPOINT) .forResponsePredicate { it.readStatusBlocks()?.equals(1.0) ?: false } .withStartupTimeout(CONTAINER_STARTUP_TIMEOUT), @@ -110,7 +110,7 @@ open class IrohaContainer : GenericContainer { private val genesisFileLocation = Path("$configDirLocation/$DEFAULT_GENESIS_FILE_NAME") private val configFileLocation = Path("$configDirLocation/$DEFAULT_CONFIG_FILE_NAME") - private val validatorFileLocation = Path("$configDirLocation/$DEFAULT_VALIDATOR_FILE_NAME") + private val executorFileLocation = Path("$configDirLocation/$DEFAULT_EXECUTOR_FILE_NAME") override fun start() { logger().debug("Starting Iroha container") @@ -144,9 +144,9 @@ open class IrohaContainer : GenericContainer { companion object { const val NETWORK_ALIAS = "iroha" - const val DEFAULT_IMAGE_TAG = "stable-2.0.0-pre-rc.19" + const val DEFAULT_IMAGE_TAG = "stable-2.0.0-pre-rc.20" const val DEFAULT_IMAGE_NAME = "hyperledger/iroha2" - const val DEFAULT_VALIDATOR_FILE_NAME = "validator.wasm" + const val DEFAULT_EXECUTOR_FILE_NAME = "executor.wasm" const val DEFAULT_GENESIS_FILE_NAME = "genesis.json" const val DEFAULT_CONFIG_FILE_NAME = "config.json" const val DEFAULT_CONFIG_DIR = "config" diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/TestConsts.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/TestConsts.kt index 6eb0eb00a..a61b1a1fd 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/TestConsts.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/TestConsts.kt @@ -31,7 +31,7 @@ val ALICE_KEYPAIR = generateKeyPair() val BOB_ACCOUNT_NAME = BOB_ACCOUNT.asName() @JvmField -val BOB_ACCOUNT_ID = AccountId(BOB_ACCOUNT_NAME, DEFAULT_DOMAIN_ID) +val BOB_ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, BOB_ACCOUNT_NAME) @JvmField val BOB_KEYPAIR = generateKeyPair() diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/WithIroha.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/WithIroha.kt index 41a669642..dce8846a2 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/WithIroha.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/WithIroha.kt @@ -43,7 +43,7 @@ annotation class WithIrohaManual( * Empty genesis with no instructions */ open class EmptyGenesis : Genesis( - RawGenesisBlock(listOf(emptyList()), validatorMode), + RawGenesisBlock(listOf(emptyList()), executorMode), ) const val IROHA_CONFIG_DELIMITER = "=" diff --git a/modules/test-tools/src/main/resources/executor.wasm b/modules/test-tools/src/main/resources/executor.wasm new file mode 100755 index 000000000..d0f406bf4 Binary files /dev/null and b/modules/test-tools/src/main/resources/executor.wasm differ diff --git a/modules/test-tools/src/main/resources/genesis.json b/modules/test-tools/src/main/resources/genesis.json index 9b809d43b..38bd9255d 100644 --- a/modules/test-tools/src/main/resources/genesis.json +++ b/modules/test-tools/src/main/resources/genesis.json @@ -45,9 +45,13 @@ }, { "Grant": { - "PermissionToken": { - "definition_id": "CanTransferAssetsWithDefinition", - "payload": null + "object": { + "PermissionToken": { + "definition_id": "CanTransferAssetsWithDefinition", + "payload" : { + "asset_definition_id" : "xor#wonderland" + } + } }, "destination_id": { "AccountId": "alice@wonderland" @@ -56,9 +60,13 @@ }, { "Grant": { - "PermissionToken": { - "definition_id": "CanTransferAssetsWithDefinition", - "payload": null + "object": { + "PermissionToken": { + "definition_id": "CanTransferAssetsWithDefinition", + "payload" : { + "asset_definition_id" : "xor#wonderland" + } + } }, "destination_id": { "AccountId": "bob@wonderland" @@ -67,7 +75,7 @@ }, { "Mint": { - "U32": 100, + "object": "100_u32", "destination_id": { "AssetId": "xor#wonderland#alice@wonderland" } @@ -75,7 +83,7 @@ }, { "Mint": { - "U32": 100, + "object": "100_u32", "destination_id": { "AssetId": "xor#wonderland#bob@wonderland" } @@ -83,5 +91,5 @@ } ] ], - "validator": "validator.wasm" -} \ No newline at end of file + "executor": "./executor.wasm" +} diff --git a/modules/test-tools/src/main/resources/genesis2.json b/modules/test-tools/src/main/resources/genesis2.json index a535cd5c9..89e6c3491 100644 --- a/modules/test-tools/src/main/resources/genesis2.json +++ b/modules/test-tools/src/main/resources/genesis2.json @@ -213,10 +213,12 @@ } }, { "Grant" : { - "PermissionToken" : { - "definition_id" : "CanSetKeyValueInUserAssets", - "payload" : { - "asset_id" : "123#test#alice@wonderland" + "object": { + "PermissionToken" : { + "definition_id" : "CanSetKeyValueInUserAssets", + "payload" : { + "asset_id" : "123#test#alice@wonderland" + } } }, "destination_id" : { @@ -224,5 +226,5 @@ } } } ] ], - "validator": "./validator.wasm" -} \ No newline at end of file + "executor": "./executor.wasm" +} diff --git a/modules/test-tools/src/main/resources/genesis3.json b/modules/test-tools/src/main/resources/genesis3.json index 32042c1a8..13a5371c7 100644 --- a/modules/test-tools/src/main/resources/genesis3.json +++ b/modules/test-tools/src/main/resources/genesis3.json @@ -120,17 +120,19 @@ } }, { "Mint" : { - "U32" : 100, + "object" : "100_u32", "destination_id" : { "AssetId" : "xor#wonderland#alice@wonderland" } } }, { "Grant" : { - "PermissionToken" : { - "definition_id" : "CanBurnAssetWithDefinition", - "payload" : { - "asset_definition_id" : "xor#wonderland" + "object": { + "PermissionToken" : { + "definition_id" : "CanBurnAssetWithDefinition", + "payload" : { + "asset_definition_id" : "xor#wonderland" + } } }, "destination_id" : { @@ -162,25 +164,25 @@ } },{ "Mint" : { - "U32" : 100, + "object" : "100_u32", "destination_id" : { "AssetId" : "xor#wonderland#bob@wonderland" } } }, { "Mint" : { - "U32" : 1, + "object" : "1_u32", "destination_id" : { "AssetId" : "xor#wonderland#alice@wonderland" } } }, { "Mint" : { - "U32" : 1, + "object" : "1_u32", "destination_id" : { "AssetId" : "val#wonderland#alice@wonderland" } } } ] ], - "validator": "./validator.wasm" -} \ No newline at end of file + "executor": "./executor.wasm" +} diff --git a/modules/test-tools/src/main/resources/validator.wasm b/modules/test-tools/src/main/resources/validator.wasm deleted file mode 100644 index 581371842..000000000 Binary files a/modules/test-tools/src/main/resources/validator.wasm and /dev/null differ