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 8dcde1484..5cb2dbbba 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 @@ -1052,13 +1052,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 + 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 index 2541fd45c..1fdfd0ddb 100644 --- a/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/SerializerTest.kt +++ b/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/SerializerTest.kt @@ -1,5 +1,7 @@ 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 @@ -45,4 +47,39 @@ class SerializerTest { 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/client/src/test/resources/genesis.json b/modules/client/src/test/resources/genesis.json index 9c0205370..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": {