diff --git a/.gitignore b/.gitignore index 94496ec1f..d2c8cb243 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,8 @@ build/ */*/out # Rust -**/target +**/target/ **/Cargo.lock +**/storage/ +**/*.rs.bk +**/rusty-tags.vi diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index be3258324..c5a73ba4a 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -1,90 +1,112 @@ -version: "3.8" - services: - iroha: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 + irohad0: + image: hyperledger/iroha:2.0.0-pre-rc.22.2 + platform: linux/amd64 environment: - TORII_P2P_ADDR: iroha:1337 - TORII_API_URL: iroha:8080 - TORII_TELEMETRY_URL: iroha:8180 - IROHA_PUBLIC_KEY: "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" - IROHA_PRIVATE_KEY: '{"digest_function": "ed25519", "payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"}' - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha:1337", "public_key": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"}, {"address":"iroha1:1338", "public_key": "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1"}, {"address": "iroha2:1339", "public_key": "ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020"}, {"address": "iroha3:1340", "public_key": "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"}]' - IROHA_GENESIS_ACCOUNT_PUBLIC_KEY: 'ed01203f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255' - IROHA_GENESIS_ACCOUNT_PRIVATE_KEY: '{ "digest_function": "ed25519", "payload": "038ae16b219da35aa036335ed0a43c28a2cc737150112c78a7b8034b9d99c9023f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255" }' - WSV_WASM_RUNTIME_CONFIG: "{\"FUEL_LIMIT\":900000000000, \"MAX_MEMORY\": 524288000}" + CHAIN: 00000000-0000-0000-0000-000000000000 + PUBLIC_KEY: ed0120A98BAFB0663CE08D75EBD506FEC38A84E576A7C9B0897693ED4B04FD9EF2D18D + PRIVATE_KEY: 802620A4DFC16789FBF9A588525E4AC7F791AC51B12AEE8919EACC03EB2FC31D32C692 + P2P_ADDRESS: 0.0.0.0:1337 + API_ADDRESS: 0.0.0.0:8080 + TRUSTED_PEERS: '[{"address":"irohad2:1339","public_key":"ed01204EE2FCD53E1730AF142D1E23951198678295047F9314B4006B0CB61850B1DB10"},{"address":"irohad1:1338","public_key":"ed01209897952D14BDFAEA780087C38FF3EB800CB20B882748FC95A575ADB9CD2CB21D"},{"address":"irohad3:1340","public_key":"ed0120CACF3A84B8DC8710CE9D6B968EE95EC7EE4C93C85858F026F3B4417F569592CE"}]' + GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 + GENESIS_PRIVATE_KEY: 80262082B3BDE54AEBECA4146257DA0DE8D59D8E46D5FE34887DCD8072866792FCB3AD + GENESIS: /tmp/genesis.signed.scale + TOPOLOGY: '[{"address":"irohad2:1339","public_key":"ed01204EE2FCD53E1730AF142D1E23951198678295047F9314B4006B0CB61850B1DB10"},{"address":"irohad1:1338","public_key":"ed01209897952D14BDFAEA780087C38FF3EB800CB20B882748FC95A575ADB9CD2CB21D"},{"address":"irohad0:1337","public_key":"ed0120A98BAFB0663CE08D75EBD506FEC38A84E576A7C9B0897693ED4B04FD9EF2D18D"},{"address":"irohad3:1340","public_key":"ed0120CACF3A84B8DC8710CE9D6B968EE95EC7EE4C93C85858F026F3B4417F569592CE"}]' ports: - - "1337:1337" - - "8080:8080" - - "8180:8180" + - 1337:1337 + - 8080:8080 volumes: - - "../modules/test-tools/src/main/resources:/config" - - "../modules/test-tools/src/main/resources:/app/.cache/wasmtime" + - "../modules/test-tools/src/main/resources:/config" init: true - command: iroha --submit-genesis - - iroha1: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 + healthcheck: + test: test $(curl -s http://127.0.0.1:8080/status/blocks) -gt 0 + interval: 2s + timeout: 1s + retries: 30 + start_period: 4s + command: |- + /bin/sh -c " + EXECUTOR_RELATIVE_PATH=$(jq -r '.executor' /config/genesis.json) && \\ + EXECUTOR_ABSOLUTE_PATH=$(realpath \"/config/$$EXECUTOR_RELATIVE_PATH\") && \\ + jq \\ + --arg executor \"$$EXECUTOR_ABSOLUTE_PATH\" \\ + --argjson topology \"$$TOPOLOGY\" \\ + '.executor = $$executor | .topology = $$topology' /config/genesis.json \\ + >/tmp/genesis.json && \\ + kagami genesis sign /tmp/genesis.json \\ + --public-key $$GENESIS_PUBLIC_KEY \\ + --private-key $$GENESIS_PRIVATE_KEY \\ + --out-file $$GENESIS \\ + && \\ + irohad + " + irohad1: + image: hyperledger/iroha:2.0.0-pre-rc.22.2 + platform: linux/amd64 environment: - TORII_P2P_ADDR: iroha1:1338 - TORII_API_URL: iroha1:8081 - TORII_TELEMETRY_URL: iroha1:8181 - IROHA_PUBLIC_KEY: "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1" - IROHA_PRIVATE_KEY: '{"digest_function": "ed25519", "payload": "3bac34cda9e3763fa069c1198312d1ec73b53023b8180c822ac355435edc4a24cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1"}' - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha:1337", "public_key": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"}, {"address":"iroha1:1338", "public_key": "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1"}, {"address": "iroha2:1339", "public_key": "ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020"}, {"address": "iroha3:1340", "public_key": "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"}]' - IROHA_GENESIS_ACCOUNT_PUBLIC_KEY: 'ed01203f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255' - IROHA_GENESIS_ACCOUNT_PRIVATE_KEY: '{ "digest_function": "ed25519", "payload": "038ae16b219da35aa036335ed0a43c28a2cc737150112c78a7b8034b9d99c9023f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255" }' - WSV_WASM_RUNTIME_CONFIG: "{\"FUEL_LIMIT\":900000000000, \"MAX_MEMORY\": 524288000}" + CHAIN: 00000000-0000-0000-0000-000000000000 + PUBLIC_KEY: ed01209897952D14BDFAEA780087C38FF3EB800CB20B882748FC95A575ADB9CD2CB21D + PRIVATE_KEY: 8026203ECA64ADC23DC106C9D703233375EA6AC345AD7299FF3AD45F355DE6CD1B5510 + P2P_ADDRESS: 0.0.0.0:1338 + API_ADDRESS: 0.0.0.0:8081 + GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 + TRUSTED_PEERS: '[{"address":"irohad2:1339","public_key":"ed01204EE2FCD53E1730AF142D1E23951198678295047F9314B4006B0CB61850B1DB10"},{"address":"irohad0:1337","public_key":"ed0120A98BAFB0663CE08D75EBD506FEC38A84E576A7C9B0897693ED4B04FD9EF2D18D"},{"address":"irohad3:1340","public_key":"ed0120CACF3A84B8DC8710CE9D6B968EE95EC7EE4C93C85858F026F3B4417F569592CE"}]' ports: - - "1338:1338" - - "8081:8081" - - "8181:8181" + - 1338:1338 + - 8081:8081 volumes: - - "../modules/test-tools/src/main/resources:/config" - - "../modules/test-tools/src/main/resources:/app/.cache/wasmtime" + - "../modules/test-tools/src/main/resources:/config" init: true - command: iroha - - iroha2: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 + healthcheck: + test: test $(curl -s http://127.0.0.1:8081/status/blocks) -gt 0 + interval: 2s + timeout: 1s + retries: 30 + start_period: 4s + irohad2: + image: hyperledger/iroha:2.0.0-pre-rc.22.2 + platform: linux/amd64 environment: - TORII_P2P_ADDR: iroha2:1339 - TORII_API_URL: iroha2:8082 - TORII_TELEMETRY_URL: iroha2:8182 - IROHA_PUBLIC_KEY: "ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020" - IROHA_PRIVATE_KEY: '{"digest_function": "ed25519", "payload": "1261a436d36779223d7d6cf20e8b644510e488e6a50bafd77a7485264d27197dfaca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020"}' - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha:1337", "public_key": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"}, {"address":"iroha1:1338", "public_key": "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1"}, {"address": "iroha2:1339", "public_key": "ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020"}, {"address": "iroha3:1340", "public_key": "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"}]' - IROHA_GENESIS_ACCOUNT_PUBLIC_KEY: 'ed01203f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255' - IROHA_GENESIS_ACCOUNT_PRIVATE_KEY: '{ "digest_function": "ed25519", "payload": "038ae16b219da35aa036335ed0a43c28a2cc737150112c78a7b8034b9d99c9023f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255" }' - WSV_WASM_RUNTIME_CONFIG: "{\"FUEL_LIMIT\":900000000000, \"MAX_MEMORY\": 524288000}" + CHAIN: 00000000-0000-0000-0000-000000000000 + PUBLIC_KEY: ed01204EE2FCD53E1730AF142D1E23951198678295047F9314B4006B0CB61850B1DB10 + PRIVATE_KEY: 8026207B1C78F733EDAFD6AF9BAC3A0D6C5A494557DD031609A4FDD9796EEF471D928C + P2P_ADDRESS: 0.0.0.0:1339 + API_ADDRESS: 0.0.0.0:8082 + GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 + TRUSTED_PEERS: '[{"address":"irohad1:1338","public_key":"ed01209897952D14BDFAEA780087C38FF3EB800CB20B882748FC95A575ADB9CD2CB21D"},{"address":"irohad0:1337","public_key":"ed0120A98BAFB0663CE08D75EBD506FEC38A84E576A7C9B0897693ED4B04FD9EF2D18D"},{"address":"irohad3:1340","public_key":"ed0120CACF3A84B8DC8710CE9D6B968EE95EC7EE4C93C85858F026F3B4417F569592CE"}]' ports: - - "1339:1339" - - "8082:8082" - - "8182:8182" + - 1339:1339 + - 8082:8082 volumes: - - "../modules/test-tools/src/main/resources:/config" - - "../modules/test-tools/src/main/resources:/app/.cache/wasmtime" + - "../modules/test-tools/src/main/resources:/config" init: true - command: iroha - - iroha3: - image: hyperledger/iroha2:stable-2.0.0-pre-rc.20 + healthcheck: + test: test $(curl -s http://127.0.0.1:8082/status/blocks) -gt 0 + interval: 2s + timeout: 1s + retries: 30 + start_period: 4s + irohad3: + image: hyperledger/iroha:2.0.0-pre-rc.22.2 + platform: linux/amd64 environment: - TORII_P2P_ADDR: iroha3:1340 - TORII_API_URL: iroha3:8083 - TORII_TELEMETRY_URL: iroha3:8183 - IROHA_PUBLIC_KEY: "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f" - IROHA_PRIVATE_KEY: '{"digest_function": "ed25519", "payload": "a70dab95c7482eb9f159111b65947e482108cfe67df877bd8d3b9441a781c7c98e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"}' - SUMERAGI_TRUSTED_PEERS: '[{"address":"iroha:1337", "public_key": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0"}, {"address":"iroha1:1338", "public_key": "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1"}, {"address": "iroha2:1339", "public_key": "ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020"}, {"address": "iroha3:1340", "public_key": "ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f"}]' - IROHA_GENESIS_ACCOUNT_PUBLIC_KEY: 'ed01203f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255' - IROHA_GENESIS_ACCOUNT_PRIVATE_KEY: '{ "digest_function": "ed25519", "payload": "038ae16b219da35aa036335ed0a43c28a2cc737150112c78a7b8034b9d99c9023f4e3e98571b55514edc5ccf7e53ca7509d89b2868e62921180a6f57c2f4e255" }' - WSV_WASM_RUNTIME_CONFIG: "{\"FUEL_LIMIT\":900000000000, \"MAX_MEMORY\": 524288000}" + CHAIN: 00000000-0000-0000-0000-000000000000 + PUBLIC_KEY: ed0120CACF3A84B8DC8710CE9D6B968EE95EC7EE4C93C85858F026F3B4417F569592CE + PRIVATE_KEY: 8026206C7FF4CA09D395C7B7332C654099406E929C6238942E3CE85155CC1A5E2CF519 + P2P_ADDRESS: 0.0.0.0:1340 + API_ADDRESS: 0.0.0.0:8083 + GENESIS_PUBLIC_KEY: ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 + TRUSTED_PEERS: '[{"address":"irohad2:1339","public_key":"ed01204EE2FCD53E1730AF142D1E23951198678295047F9314B4006B0CB61850B1DB10"},{"address":"irohad1:1338","public_key":"ed01209897952D14BDFAEA780087C38FF3EB800CB20B882748FC95A575ADB9CD2CB21D"},{"address":"irohad0:1337","public_key":"ed0120A98BAFB0663CE08D75EBD506FEC38A84E576A7C9B0897693ED4B04FD9EF2D18D"}]' ports: - - "1340:1340" - - "8083:8083" - - "8183:8183" + - 1340:1340 + - 8083:8083 volumes: - - "../modules/test-tools/src/main/resources:/config" - - "../modules/test-tools/src/main/resources:/app/.cache/wasmtime" + - "../modules/test-tools/src/main/resources:/config" init: true - command: iroha + healthcheck: + test: test $(curl -s http://127.0.0.1:8083/status/blocks) -gt 0 + interval: 2s + timeout: 1s + retries: 30 + start_period: 4s 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 20e24d511..e091981f4 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 @@ -1,63 +1,69 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.generated.AccountId +import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.AssetType import jp.co.soramitsu.iroha2.generated.AssetValue -import jp.co.soramitsu.iroha2.generated.AssetValueType import kotlinx.coroutines.runBlocking import java.net.URL +import java.util.UUID 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("wonderland".asDomainId(), "bob".asName()) + val chainId = UUID.fromString("00000000-0000-0000-0000-000000000000") + val apiUrl = "http://127.0.0.1:8080" + val peerUrl = "http://127.0.0.1:1337" + val admin = AccountId( + "wonderland".asDomainId(), + publicKeyFromHex("CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03").toIrohaPublicKey(), + ) val adminKeyPair = keyPairFromHex( - "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", - "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", + "CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03", + "CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53", ) - - val client = AdminIroha2Client(URL(peerUrl), URL(peerUrl), URL(telemetryUrl), log = true) + val client = AdminIroha2Client(URL(apiUrl), URL(peerUrl), log = true) val query = Query(client, admin, adminKeyPair) query.findAllDomains() .also { println("ALL DOMAINS: ${it.map { d -> d.id.asString() }}") } + query.findAllAccounts() + .also { println("ALL ACCOUNTS: ${it.map { d -> d.id.asString() }}") } + query.findAllAssets() + .also { println("ALL ASSETS: ${it.map { d -> d.id.asString() }}") } - val sendTransaction = SendTransaction(client, admin, adminKeyPair) + val sendTransaction = SendTransaction(client, admin, adminKeyPair, chainId) val domain = "looking_glass_${System.currentTimeMillis()}" sendTransaction.registerDomain(domain).also { println("DOMAIN $domain CREATED") } - val madHatter = "madHatter_${System.currentTimeMillis()}$ACCOUNT_ID_DELIMITER$domain" val madHatterKeyPair = generateKeyPair() - sendTransaction.registerAccount(madHatter, listOf(madHatterKeyPair.public.toIrohaPublicKey())) + val madHatter = AccountId(domain.asDomainId(), madHatterKeyPair.public.toIrohaPublicKey()) + sendTransaction.registerAccount(madHatter.asString()) .also { println("ACCOUNT $madHatter CREATED") } - query.findAllAccounts() - .also { println("ALL ACCOUNTS: ${it.map { a -> a.id.asString() }}") } - val assetDefinition = "asset_time_${System.currentTimeMillis()}$ASSET_ID_DELIMITER$domain" - sendTransaction.registerAssetDefinition(assetDefinition, AssetValueType.Quantity()) + sendTransaction.registerAssetDefinition(assetDefinition, AssetType.numeric()) .also { println("ASSET DEFINITION $assetDefinition CREATED") } - val madHatterAsset = "$assetDefinition$ASSET_ID_DELIMITER$madHatter" - sendTransaction.registerAsset(madHatterAsset, AssetValue.Quantity(100)) + val madHatterAsset = AssetId(madHatter, assetDefinition.asAssetDefinitionId()) + sendTransaction.registerAsset(madHatterAsset, AssetValue.Numeric(100.asNumeric())) .also { println("ASSET $madHatterAsset CREATED") } - val whiteRabbit = "whiteRabbit_${System.currentTimeMillis()}$ACCOUNT_ID_DELIMITER$domain" val whiteRabbitKeyPair = generateKeyPair() - sendTransaction.registerAccount(whiteRabbit, listOf(whiteRabbitKeyPair.public.toIrohaPublicKey())) + val whiteRabbit = AccountId(domain.asDomainId(), whiteRabbitKeyPair.public.toIrohaPublicKey()) + sendTransaction.registerAccount(whiteRabbit.asString()) .also { println("ACCOUNT $whiteRabbit CREATED") } - val whiteRabbitAsset = "$assetDefinition$ASSET_ID_DELIMITER$whiteRabbit" - sendTransaction.registerAsset(whiteRabbitAsset, AssetValue.Quantity(0)) + val whiteRabbitAsset = AssetId(whiteRabbit, assetDefinition.asAssetDefinitionId()) + sendTransaction.registerAsset(whiteRabbitAsset, AssetValue.Numeric(0.asNumeric())) .also { println("ASSET $whiteRabbitAsset CREATED") } - sendTransaction.transferAsset(madHatterAsset, 10, whiteRabbit, madHatter.asAccountId(), madHatterKeyPair) + sendTransaction.transferAsset(madHatterAsset, 10, whiteRabbit.asString(), madHatter, madHatterKeyPair) .also { println("$madHatter TRANSFERRED FROM $madHatterAsset TO $whiteRabbitAsset: 10") } - query.getAccountAmount(madHatter, madHatterAsset).also { println("$madHatterAsset BALANCE: $it") } - query.getAccountAmount(whiteRabbit, whiteRabbitAsset).also { println("$whiteRabbitAsset BALANCE: $it") } + query.getAccountAmount(madHatter, madHatterAsset.definition).also { println("$madHatterAsset BALANCE: $it") } + query.getAccountAmount(whiteRabbit, whiteRabbitAsset.definition).also { println("$whiteRabbitAsset BALANCE: $it") } - sendTransaction.burnAssets(madHatterAsset, 10, madHatter.asAccountId(), madHatterKeyPair) + sendTransaction.burnAssets(madHatterAsset, 10, madHatter, madHatterKeyPair) .also { println("$madHatterAsset WAS BURN") } - query.getAccountAmount(madHatter, madHatterAsset) + query.getAccountAmount(madHatter, madHatterAsset.definition) .also { println("$madHatterAsset BALANCE: $it AFTER ASSETS BURNING") } } diff --git a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Query.kt b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Query.kt index 1c2cf9274..75e12d25b 100644 --- a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Query.kt +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Query.kt @@ -1,10 +1,12 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.generated.AccountId +import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetValue import jp.co.soramitsu.iroha2.generated.GenericPredicateBox -import jp.co.soramitsu.iroha2.generated.ValuePredicate +import jp.co.soramitsu.iroha2.generated.QueryOutputPredicate import jp.co.soramitsu.iroha2.query.QueryBuilder +import java.math.BigInteger import java.security.KeyPair open class Query( @@ -13,33 +15,31 @@ open class Query( private val keyPair: KeyPair, ) { - suspend fun findAllDomains(queryFilter: GenericPredicateBox? = null) = QueryBuilder + suspend fun findAllDomains(queryFilter: GenericPredicateBox? = null) = QueryBuilder .findAllDomains(queryFilter) .account(admin) .buildSigned(keyPair) .let { client.sendQuery(it) } - suspend fun findAllAccounts(queryFilter: GenericPredicateBox? = null) = QueryBuilder + suspend fun findAllAccounts(queryFilter: GenericPredicateBox? = null) = QueryBuilder .findAllAccounts(queryFilter) .account(admin) .buildSigned(keyPair) - .let { - client.sendQuery(it) - } + .let { client.sendQuery(it) } - suspend fun findAllAssets(queryFilter: GenericPredicateBox? = null) = QueryBuilder + suspend fun findAllAssets(queryFilter: GenericPredicateBox? = null) = QueryBuilder .findAllAssets(queryFilter) .account(admin) .buildSigned(keyPair) .let { client.sendQuery(it) } - suspend fun getAccountAmount(accountId: String, assetId: String): Long = - QueryBuilder.findAccountById(accountId.asAccountId()) + suspend fun getAccountAmount(accountId: AccountId, assetDefinitionId: AssetDefinitionId): BigInteger = + QueryBuilder.findAssetsByAccountId(accountId) .account(admin) .buildSigned(keyPair) .let { query -> - client.sendQuery(query).assets[assetId.asAssetId()]?.value + client.sendQuery(query).find { it.id.definition == assetDefinitionId }?.value }.let { value -> - value?.cast()?.u32 + value?.cast()?.numeric?.mantissa } ?: throw RuntimeException("NOT FOUND") } diff --git a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/SendTransaction.kt b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/SendTransaction.kt index b0bb414ef..34aa58dc5 100644 --- a/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/SendTransaction.kt +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/SendTransaction.kt @@ -1,32 +1,34 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.generated.AccountId +import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.AssetType import jp.co.soramitsu.iroha2.generated.AssetValue -import jp.co.soramitsu.iroha2.generated.AssetValueType import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Mintable import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.PublicKey -import jp.co.soramitsu.iroha2.generated.Value import kotlinx.coroutines.withTimeout import java.security.KeyPair +import java.util.UUID class SendTransaction( private val client: AdminIroha2Client, private val admin: AccountId, private val keyPair: KeyPair, + private val chainUuid: UUID, private val timeout: Long = 10000, ) { suspend fun registerDomain( id: String, - metadata: Map = mapOf(), + metadata: Map = mapOf(), admin: AccountId = this.admin, keyPair: KeyPair = this.keyPair, ) { client.sendTransaction { account(admin) - this.registerDomain(id.asDomainId(), metadata) + chainId(chainUuid) + registerDomain(id.asDomainId(), metadata) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } @@ -35,14 +37,14 @@ class SendTransaction( suspend fun registerAccount( id: String, - signatories: List, - metadata: Map = mapOf(), + metadata: Map = mapOf(), admin: AccountId = this.admin, keyPair: KeyPair = this.keyPair, ) { client.sendTransaction { account(admin) - this.registerAccount(id.asAccountId(), signatories, Metadata(metadata)) + chainId(chainUuid) + registerAccount(id.asAccountId(), Metadata(metadata)) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } @@ -51,15 +53,16 @@ class SendTransaction( suspend fun registerAssetDefinition( id: String, - type: AssetValueType = AssetValueType.Store(), - metadata: Map = mapOf(), + type: AssetType = AssetType.Store(), + metadata: Map = mapOf(), mintable: Mintable = Mintable.Infinitely(), admin: AccountId = this.admin, keyPair: KeyPair = this.keyPair, ) { client.sendTransaction { account(admin) - this.registerAssetDefinition(id.asAssetDefinitionId(), type, Metadata(metadata), mintable) + chainId(chainUuid) + registerAssetDefinition(id.asAssetDefinitionId(), type, Metadata(metadata), mintable) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } @@ -67,14 +70,15 @@ class SendTransaction( } suspend fun registerAsset( - id: String, + id: AssetId, value: AssetValue, admin: AccountId = this.admin, keyPair: KeyPair = this.keyPair, ) { client.sendTransaction { account(admin) - this.registerAsset(id.asAssetId(), value) + chainId(chainUuid) + registerAsset(id, value) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } @@ -82,7 +86,7 @@ class SendTransaction( } suspend fun transferAsset( - from: String, + from: AssetId, value: Int, to: String, admin: AccountId = this.admin, @@ -90,7 +94,8 @@ class SendTransaction( ) { client.sendTransaction { account(admin) - this.transferAsset(from.asAssetId(), value, to.asAccountId()) + chainId(chainUuid) + transferAsset(from, value, to.asAccountId()) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } @@ -98,14 +103,15 @@ class SendTransaction( } suspend fun burnAssets( - assetId: String, + assetId: AssetId, value: Int, admin: AccountId = this.admin, keyPair: KeyPair = this.keyPair, ) { client.sendTransaction { account(admin) - this.burnAsset(assetId.asAssetId(), value) + chainId(chainUuid) + burnAsset(assetId, value) buildSigned(keyPair) }.also { withTimeout(timeout) { it.await() } 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 0f146d6f9..3d53f8b77 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 @@ -32,21 +32,19 @@ open class AdminIroha2Client( constructor( apiUrl: URL, - telemetryUrl: URL, peerUrl: URL, log: Boolean = false, credentials: String? = null, balancingHealthCheck: Boolean = true, - ) : this(IrohaUrls(apiUrl, telemetryUrl, peerUrl), log, credentials, balancingHealthCheck) + ) : this(IrohaUrls(apiUrl, peerUrl), log, credentials, balancingHealthCheck) constructor( apiUrl: String, - telemetryUrl: String, peerUrl: String, log: Boolean = false, credentials: String? = null, balancingHealthCheck: Boolean = true, - ) : this(URL(apiUrl), URL(telemetryUrl), URL(peerUrl), log, credentials, balancingHealthCheck) + ) : this(URL(apiUrl), URL(peerUrl), log, credentials, balancingHealthCheck) /** * Send metrics request @@ -71,7 +69,7 @@ open class AdminIroha2Client( /** * Send schema request */ - suspend fun schema(): String = client.get("${getTelemetryUrl()}$SCHEMA_ENDPOINT").body() + suspend fun schema(): String = client.get("${getApiUrl()}$SCHEMA_ENDPOINT").body() /** * Request current configuration of the peer @@ -88,8 +86,6 @@ open class AdminIroha2Client( return config(mapOf(ConfigurationFieldType.Docs to fieldValue)) } - suspend fun describeConfig(vararg fieldValue: String): String = describeConfig(fieldValue.asList()) - private suspend inline fun config(body: B): T { val response: HttpResponse = client.get("${getApiUrl()}$CONFIGURATION_ENDPOINT") { contentType(ContentType.Application.Json) diff --git a/modules/admin-client/src/test/kotlin/jp/co/soramitsu/iroha2/ClientTest.kt b/modules/admin-client/src/test/kotlin/jp/co/soramitsu/iroha2/ClientTest.kt index eb3209a3f..2f1d78d9f 100644 --- a/modules/admin-client/src/test/kotlin/jp/co/soramitsu/iroha2/ClientTest.kt +++ b/modules/admin-client/src/test/kotlin/jp/co/soramitsu/iroha2/ClientTest.kt @@ -7,11 +7,17 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Test import org.junit.jupiter.api.Timeout import kotlin.test.assertEquals -import kotlin.test.assertFailsWith @Timeout(120) class ClientTest : IrohaTest() { + @Test + @WithIroha + fun schema(): Unit = runBlocking { + val schema = client.schema() + assert(schema.isNotEmpty()) + } + @Test @WithIroha fun health(): Unit = runBlocking { @@ -37,31 +43,7 @@ class ClientTest : IrohaTest() { @WithIroha fun getConfigValues(): Unit = runBlocking { val configs = client.getConfigs() - assert(configs.containsKey("GENESIS")) - } - - @Test - @WithIroha - fun describeConfig(): Unit = runBlocking { - val docsConfig = client.describeConfig("genesis", "account_private_key") - assert(docsConfig.isNotEmpty()) - - // must throw ex if config's property name not provided - assertFailsWith { - client.describeConfig() - } - } - - @Test - @WithIroha(amount = PEER_AMOUNT) - fun `round-robin load balancing test`(): Unit = runBlocking { - val urls = mutableSetOf() - repeat(PEER_AMOUNT * 2 + 1) { - val config = client.getConfigs() - urls.add(config["TORII"]!!.cast>()["API_URL"]!!) - } - - assertEquals(PEER_AMOUNT, urls.size) + assert(configs.isNotEmpty()) } companion object { 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 5976712d2..99fe25b95 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,18 +1,17 @@ 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.InstructionExpr -import jp.co.soramitsu.iroha2.generated.InstructionExpr.Register +import jp.co.soramitsu.iroha2.generated.ChainId +import jp.co.soramitsu.iroha2.generated.InstructionBox 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.RegisterExpr -import jp.co.soramitsu.iroha2.generated.RegistrableBox -import jp.co.soramitsu.iroha2.generated.Value +import jp.co.soramitsu.iroha2.generated.Parameter +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction +import jp.co.soramitsu.iroha2.generated.RegisterBox +import jp.co.soramitsu.iroha2.generated.RegisterOfAccount +import jp.co.soramitsu.iroha2.generated.RegisterOfAssetDefinition +import jp.co.soramitsu.iroha2.generated.RegisterOfDomain import java.nio.file.Files import java.nio.file.Path import java.nio.file.StandardOpenOption @@ -20,7 +19,7 @@ import java.nio.file.StandardOpenOption /** * Genesis block is used to initialise a blockchain */ -open class Genesis(open val block: RawGenesisBlock) { +open class Genesis(open val transaction: RawGenesisTransaction) { /** * Write genesis to file */ @@ -34,59 +33,60 @@ open class Genesis(open val block: RawGenesisBlock) { /** * Represent genesis as JSON */ - fun asJson(): String = JSON_SERDE.writeValueAsString(this.block) + fun asJson(): String = JSON_SERDE.writeValueAsString(this.transaction) companion object { - 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()), executorMode)) + const val EXECUTOR_FILE_NAME = "executor.wasm" /** * List of genesis blocks to single block with unique instructions */ fun List.toSingle(): Genesis { - val uniqueIsi: MutableSet = mutableSetOf() + val uniqueIsi: MutableSet = mutableSetOf() + val uniqueParams: MutableSet = mutableSetOf() + this.forEach { genesis -> - uniqueIsi.addAll(genesis.block.transactions.flatten()) + uniqueIsi.addAll(genesis.transaction.instructions) + uniqueParams.addAll(genesis.transaction.parameters) } - - return Genesis(RawGenesisBlock(listOf(uniqueIsi.mergeMetadata()), executorMode)) + return Genesis( + RawGenesisTransaction( + ChainId("00000000-0000-0000-0000-000000000000"), + EXECUTOR_FILE_NAME, + uniqueParams.toList(), + uniqueIsi.mergeMetadata().toList(), + emptyList(), + ), + ) } - private fun MutableSet.mergeMetadata(): List { + private fun MutableSet.mergeMetadata(): List { // entity id to its metadata val metadataMap = mutableMapOf() - // only for InstructionExpr.Register - this.extractIdentifiableBoxes().forEach { idBox -> + // only for InstructionBox.Register + this.extractRegisterBoxes().forEach { idBox -> metadataMap.putMergedMetadata(idBox) } this.findIsiToReplace(metadataMap).forEach { (idToMetadata, toReplace) -> toReplace.forEach { isi -> this.remove(isi) } - val idBox = toReplace.first().extractIdentifiableBox() - val registrableBox = idBox?.toRegisterBox(idToMetadata.second) - ?: throw RuntimeException("IdentifiableBox shouldn't be null") - this.add(Register(RegisterExpr(registrableBox.evaluatesTo()))) + val idBox = toReplace.first().registerBox + this.add(InstructionBox.Register(idBox.addMetadata(idToMetadata.second))) } return this.sorted() } - private fun MutableSet.sorted() = this.sortedWith( + private fun MutableSet.sorted() = this.sortedWith( compareByDescending { instruction -> when (instruction) { - is Register -> when (instruction.extractIdentifiableBox()) { - is IdentifiableBox.NewDomain -> 5 - is IdentifiableBox.NewAccount -> 4 - is IdentifiableBox.NewAssetDefinition -> 3 - is IdentifiableBox.NewRole -> 2 + is InstructionBox.Register -> when (instruction.cast().registerBox) { + is RegisterBox.Domain -> 5 + is RegisterBox.Account -> 4 + is RegisterBox.AssetDefinition -> 3 + is RegisterBox.Role -> 2 else -> 1 } @@ -95,36 +95,42 @@ open class Genesis(open val block: RawGenesisBlock) { }, ) - private fun IdentifiableBox.toRegisterBox(metadata: Metadata) = when (this) { - is IdentifiableBox.NewAccount -> RegistrableBox.Account( - NewAccount(this.newAccount.id, this.newAccount.signatories, metadata), + private fun RegisterBox.addMetadata(metadata: Metadata) = when (this) { + is RegisterBox.Account -> RegisterBox.Account( + RegisterOfAccount( + NewAccount(this.registerOfAccount.`object`.id, metadata), + ), ) - is IdentifiableBox.NewDomain -> RegistrableBox.Domain( - NewDomain(this.newDomain.id, this.newDomain.logo, metadata), + is RegisterBox.Domain -> RegisterBox.Domain( + RegisterOfDomain( + NewDomain(this.registerOfDomain.`object`.id, this.registerOfDomain.`object`.logo, metadata), + ), ) - is IdentifiableBox.NewAssetDefinition -> RegistrableBox.AssetDefinition( - NewAssetDefinition( - this.newAssetDefinition.id, - this.newAssetDefinition.valueType, - this.newAssetDefinition.mintable, - metadata = metadata, + is RegisterBox.AssetDefinition -> RegisterBox.AssetDefinition( + RegisterOfAssetDefinition( + NewAssetDefinition( + this.registerOfAssetDefinition.`object`.id, + this.registerOfAssetDefinition.`object`.type, + this.registerOfAssetDefinition.`object`.mintable, + metadata = metadata, + ), ), ) else -> throw IrohaSdkException("Unexpected type ${this::class}") } - private fun MutableMap.putMergedMetadata(idBox: IdentifiableBox) { + private fun MutableMap.putMergedMetadata(idBox: RegisterBox) { fun MutableMap.putOrMerge( id: Any, metadata: Metadata, ) = when (val value = this[id]) { null -> this[id] = metadata else -> { - metadata.map.forEach { (k, v) -> - if (value.map.containsKey(k) && value.map[k] != v) { + metadata.sortedMapOfName.forEach { (k, v) -> + if (value.sortedMapOfName.containsKey(k) && value.sortedMapOfName[k] != v) { throw IrohaSdkException("Value for this key is already set in metadata") } } @@ -133,50 +139,37 @@ open class Genesis(open val block: RawGenesisBlock) { } when (idBox) { - is IdentifiableBox.NewAccount -> this.putOrMerge(idBox.newAccount.id, idBox.newAccount.metadata) - is IdentifiableBox.NewDomain -> this.putOrMerge(idBox.newDomain.id, idBox.newDomain.metadata) - is IdentifiableBox.NewAssetDefinition -> this.putOrMerge( - idBox.newAssetDefinition.id, - idBox.newAssetDefinition.metadata, + is RegisterBox.Account -> this.putOrMerge(idBox.registerOfAccount.`object`.id, idBox.registerOfAccount.`object`.metadata) + is RegisterBox.Domain -> this.putOrMerge(idBox.registerOfDomain.`object`.id, idBox.registerOfDomain.`object`.metadata) + is RegisterBox.AssetDefinition -> this.putOrMerge( + idBox.registerOfAssetDefinition.`object`.id, + idBox.registerOfAssetDefinition.`object`.metadata, ) else -> {} } } - private fun MutableSet.findIsiToReplace( + private fun MutableSet.findIsiToReplace( metadata: Map, - ): MutableMap, MutableList> { + ): MutableMap, MutableList> { val isiToReplace = - mutableMapOf, MutableList>() + mutableMapOf, MutableList>() this.forEach { instruction -> runCatching { - instruction.cast() - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox + instruction.cast().registerBox }.onSuccess { idBox -> when (idBox) { - is IdentifiableBox.NewAccount -> { - val id = idBox.newAccount.id - id to metadata[id]!! - } - is IdentifiableBox.NewDomain -> { - val id = idBox.newDomain.id - id to metadata[id]!! - } - is IdentifiableBox.NewAssetDefinition -> { - val id = idBox.newAssetDefinition.id - id to metadata[id]!! - } + is RegisterBox.Account -> idBox.registerOfAccount.`object`.id.let { id -> id to metadata[id]!! } + is RegisterBox.Domain -> idBox.registerOfDomain.`object`.id.let { id -> id to metadata[id]!! } + is RegisterBox.AssetDefinition -> idBox.registerOfAssetDefinition.`object`.id.let { id -> id to metadata[id]!! } else -> null - }?.takeIf { it.second.map.isNotEmpty() } - ?.let { - isiToReplace.merge(it, mutableListOf(instruction.cast())) { old, new -> - old.plus(new).toMutableList() - } + }?.takeIf { it.second.sortedMapOfName.isNotEmpty() }?.let { + isiToReplace.merge(it, mutableListOf(instruction.cast())) { old, new -> + old.plus(new).toMutableList() } + } } } return isiToReplace 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 9470b4909..6e2487cd2 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,103 +12,119 @@ 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.LongNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.databind.node.TextNode 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.ActionOfTriggeringFilterBox +import jp.co.soramitsu.iroha2.generated.Action 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.AssetTransferBox +import jp.co.soramitsu.iroha2.generated.AssetType 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.BurnExpr +import jp.co.soramitsu.iroha2.generated.BlockParameter +import jp.co.soramitsu.iroha2.generated.BurnBox +import jp.co.soramitsu.iroha2.generated.BurnOfNumericAndAsset +import jp.co.soramitsu.iroha2.generated.BurnOfu32AndTrigger +import jp.co.soramitsu.iroha2.generated.ChainId +import jp.co.soramitsu.iroha2.generated.CustomInstruction +import jp.co.soramitsu.iroha2.generated.CustomParameter import jp.co.soramitsu.iroha2.generated.DomainId -import jp.co.soramitsu.iroha2.generated.Duration -import jp.co.soramitsu.iroha2.generated.EvaluatesTo +import jp.co.soramitsu.iroha2.generated.EventFilterBox import jp.co.soramitsu.iroha2.generated.Executable +import jp.co.soramitsu.iroha2.generated.ExecuteTrigger import jp.co.soramitsu.iroha2.generated.ExecuteTriggerEventFilter import jp.co.soramitsu.iroha2.generated.ExecutionTime -import jp.co.soramitsu.iroha2.generated.ExecutorMode -import jp.co.soramitsu.iroha2.generated.Expression -import jp.co.soramitsu.iroha2.generated.Fixed -import jp.co.soramitsu.iroha2.generated.GrantExpr +import jp.co.soramitsu.iroha2.generated.Executor +import jp.co.soramitsu.iroha2.generated.GrantBox +import jp.co.soramitsu.iroha2.generated.GrantOfPermissionAndAccount +import jp.co.soramitsu.iroha2.generated.GrantOfPermissionAndRole +import jp.co.soramitsu.iroha2.generated.GrantOfRoleIdAndAccount 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.InstructionExpr +import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.IpfsPath 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.Log import jp.co.soramitsu.iroha2.generated.Metadata -import jp.co.soramitsu.iroha2.generated.MintExpr +import jp.co.soramitsu.iroha2.generated.MintBox +import jp.co.soramitsu.iroha2.generated.MintOfNumericAndAsset +import jp.co.soramitsu.iroha2.generated.MintOfu32AndTrigger 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.NewParameterExpr -import jp.co.soramitsu.iroha2.generated.NewRole -import jp.co.soramitsu.iroha2.generated.NumericValue +import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 +import jp.co.soramitsu.iroha2.generated.Numeric +import jp.co.soramitsu.iroha2.generated.NumericSpec import jp.co.soramitsu.iroha2.generated.Parameter import jp.co.soramitsu.iroha2.generated.Peer -import jp.co.soramitsu.iroha2.generated.PermissionToken +import jp.co.soramitsu.iroha2.generated.Permission import jp.co.soramitsu.iroha2.generated.PublicKey -import jp.co.soramitsu.iroha2.generated.RawGenesisBlock -import jp.co.soramitsu.iroha2.generated.RegisterExpr -import jp.co.soramitsu.iroha2.generated.RegistrableBox +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction +import jp.co.soramitsu.iroha2.generated.RegisterBox +import jp.co.soramitsu.iroha2.generated.RegisterOfAccount +import jp.co.soramitsu.iroha2.generated.RegisterOfAsset +import jp.co.soramitsu.iroha2.generated.RegisterOfAssetDefinition +import jp.co.soramitsu.iroha2.generated.RegisterOfDomain +import jp.co.soramitsu.iroha2.generated.RegisterOfPeer +import jp.co.soramitsu.iroha2.generated.RegisterOfRole +import jp.co.soramitsu.iroha2.generated.RegisterOfTrigger +import jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox import jp.co.soramitsu.iroha2.generated.Repeats +import jp.co.soramitsu.iroha2.generated.RevokeBox import jp.co.soramitsu.iroha2.generated.Role import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.Schedule -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.SetKeyValueBox +import jp.co.soramitsu.iroha2.generated.SetKeyValueOfAccount +import jp.co.soramitsu.iroha2.generated.SetKeyValueOfAsset +import jp.co.soramitsu.iroha2.generated.SetKeyValueOfAssetDefinition +import jp.co.soramitsu.iroha2.generated.SetKeyValueOfDomain +import jp.co.soramitsu.iroha2.generated.SetKeyValueOfTrigger +import jp.co.soramitsu.iroha2.generated.SetParameter import jp.co.soramitsu.iroha2.generated.SignedBlock +import jp.co.soramitsu.iroha2.generated.SmartContractParameter import jp.co.soramitsu.iroha2.generated.SocketAddr -import jp.co.soramitsu.iroha2.generated.StringWithJson +import jp.co.soramitsu.iroha2.generated.SumeragiParameter import jp.co.soramitsu.iroha2.generated.TimeEventFilter -import jp.co.soramitsu.iroha2.generated.TransactionLimits +import jp.co.soramitsu.iroha2.generated.TransactionParameter import jp.co.soramitsu.iroha2.generated.TransactionQueryOutput -import jp.co.soramitsu.iroha2.generated.TransactionValue +import jp.co.soramitsu.iroha2.generated.TransferBox +import jp.co.soramitsu.iroha2.generated.TransferOfAccountAndAssetDefinitionIdAndAccount +import jp.co.soramitsu.iroha2.generated.TransferOfAccountAndDomainIdAndAccount +import jp.co.soramitsu.iroha2.generated.Trigger import jp.co.soramitsu.iroha2.generated.TriggerId -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.UnregisterBox +import jp.co.soramitsu.iroha2.generated.Upgrade import jp.co.soramitsu.iroha2.generated.WasmSmartContract import java.io.ByteArrayOutputStream import java.math.BigInteger import kotlin.reflect.KClass -import kotlin.reflect.full.createInstance import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor /** - * This JSON mapper is configured to serialise and deserialise `Genesis block` in a format compatible with Iroha 2 peer + * This JSON mapper is configured to serialize and deserialize `Genesis block` in a format compatible with Iroha 2 peer */ public val JSON_SERDE by lazy { ObjectMapper().also { mapper -> val module = SimpleModule() // deserializers - 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) module.addDeserializer(IdBox::class.java, IdBoxDeserializer) - module.addDeserializer(AssetValueType::class.java, AssetValueTypeDeserializer) module.addDeserializer(Name::class.java, NameDeserializer) module.addDeserializer(Mintable::class.java, MintableDeserializer) module.addDeserializer(DomainId::class.java, DomainIdDeserializer) @@ -116,30 +132,50 @@ public 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(RegisterExpr::class.java, RegisterExprDeserializer) - module.addDeserializer(MintExpr::class.java, MintExprDeserializer) - module.addDeserializer(SetKeyValueExpr::class.java, SetKeyValueExprDeserializer) + module.addDeserializer(RegisterBox::class.java, RegisterBoxDeserializer) + module.addDeserializer(MintBox::class.java, MintBoxDeserializer) module.addDeserializer(Metadata::class.java, MetadataDeserializer) - module.addDeserializer(NewRole::class.java, NewRoleDeserializer) - module.addDeserializer(NewParameterExpr::class.java, NewParameterExprDeserializer) - module.addDeserializer(PermissionToken::class.java, PermissionTokenDeserializer) - module.addDeserializer(StringWithJson::class.java, StringWithJsonDeserializer) module.addDeserializer(TriggerId::class.java, TriggerIdDeserializer) - module.addDeserializer(TriggerOfTriggeringFilterBox::class.java, TriggerOfTriggeringFilterBoxDeserializer) + module.addDeserializer(InstructionBox::class.java, InstructionDeserializer) + module.addDeserializer(GrantBox::class.java, GrantBoxDeserializer) + module.addDeserializer(EventFilterBox::class.java, EventFilterBoxDeserializer) + module.addDeserializer(SetKeyValueBox::class.java, SetKeyValueBoxDeserializer) + module.addDeserializer(TransferBox::class.java, TransferBoxDeserializer) + module.addDeserializer(AssetType::class.java, AssetTypeDeserializer) + module.addDeserializer(ChainId::class.java, ChainIdDeserializer) + module.addDeserializer(NewDomain::class.java, NewDomainDeserializer) + module.addDeserializer(NewAssetDefinition::class.java, NewAssetDefinitionDeserializer) + module.addDeserializer(Trigger::class.java, TriggerDeserializer) + module.addDeserializer(ExecuteTriggerEventFilter::class.java, ExecuteTriggerEventFilterDeserializer) + module.addDeserializer(Action::class.java, ActionDeserializer) + module.addDeserializer(Executable::class.java, ExecutableDeserializer) + module.addDeserializer(IpfsPath::class.java, IpfsPathDeserializer) + module.addDeserializer(Repeats::class.java, RepeatsDeserializer) + module.addDeserializer(Parameter::class.java, ParameterDeserializer) + module.addDeserializer(SumeragiParameter::class.java, SumeragiParameterDeserializer) + module.addDeserializer(BlockParameter::class.java, BlockParameterDeserializer) + module.addDeserializer(TransactionParameter::class.java, TransactionParameterDeserializer) + module.addDeserializer(SmartContractParameter::class.java, SmartContractParameterDeserializer) + module.addDeserializer(Schedule::class.java, ScheduleDeserializer) + module.addDeserializer(ExecutionTime::class.java, ExecutionTimeDeserializer) + module.addDeserializer(TimeEventFilter::class.java, TimeEventFilterDeserializer) + module.addDeserializer(NumericSpec::class.java, NumericSpecDeserializer) + module.addDeserializer(Numeric::class.java, NumericDeserializer) + module.addDeserializer(Permission::class.java, PermissionDeserializer) + module.addDeserializer(BurnBox::class.java, BurnBoxDeserializer) + module.addKeyDeserializer(AssetDefinitionId::class.java, AssetDefinitionIdKeyDeserializer) module.addKeyDeserializer(AccountId::class.java, AccountIdKeyDeserializer) module.addKeyDeserializer(AssetId::class.java, AssetIdKeyDeserializer) module.addKeyDeserializer(DomainId::class.java, DomainIdKeyDeserializer) // serializers - module.addSerializer(RawGenesisBlock::class.java, RawGenesisBlockSerializer) - module.addSerializer(PermissionToken::class.java, PermissionTokenSerializer) module.addKeySerializer(Name::class.java, NameAsKeySerializer) + module.addSerializer(RawGenesisTransaction::class.java, RawGenesisTransactionSerializer) module.addSerializer(DomainId::class.java, DomainIdSerializer) module.addSerializer(AssetDefinitionId::class.java, AssetDefinitionIdSerializer) module.addSerializer(AccountId::class.java, AccountIdSerializer) module.addSerializer(AssetId::class.java, AssetIdSerializer) - module.addSerializer(NumericValue::class.java, NumericValueSerializer) module.addSerializer(RoleId::class.java, RoleIdSerializer) module.addSerializer(SocketAddr::class.java, SocketAddrSerializer) module.addSerializer(TriggerId::class.java, TriggerIdSerializer) @@ -147,16 +183,27 @@ public val JSON_SERDE by lazy { module.addSerializer(UInt::class.java, UIntSerializer) module.addSerializer(PublicKey::class.java, PublicKeySerializer) module.addSerializer(ModelEnum::class.java, EnumerationSerializer) - module.addSerializer(EvaluatesTo::class.java, EvaluatesToSerializer) module.addSerializer(Metadata::class.java, MetadataSerializer) module.addSerializer(IdentifiableBox.NewRole::class.java, IdentifiableBoxNewRoleSerializer) module.addSerializer(Parameter::class.java, ParameterSerializer) - module.addSerializer(ExecutorMode::class.java, ExecutorModeSerializer) - module.addSerializer(SequenceExpr::class.java, SequenceExprSerializer) - module.addSerializer(NewParameterExpr::class.java, NewParameterExprSerializer) - module.addSerializer(StringWithJson::class.java, StringWithJsonSerializer) module.addSerializer(TimeEventFilter::class.java, TimeEventFilterSerializer) module.addSerializer(Schedule::class.java, ScheduleSerializer) + module.addSerializer(Executor::class.java, ExecutorSerializer) + module.addSerializer(InstructionBox::class.java, InstructionBoxSerializer) + module.addSerializer(RegisterOfDomain::class.java, RegisterOfDomainSerializer) + module.addSerializer(RegisterOfTrigger::class.java, RegisterOfTriggerSerializer) + module.addSerializer(RegisterOfRole::class.java, RegisterOfRoleSerializer) + module.addSerializer(RegisterOfAsset::class.java, RegisterOfAssetSerializer) + module.addSerializer(RegisterOfAssetDefinition::class.java, RegisterOfAssetDefinitionSerializer) + module.addSerializer(RegisterOfPeer::class.java, RegisterOfPeerSerializer) + module.addSerializer(RegisterOfAccount::class.java, RegisterOfAccountSerializer) + module.addSerializer(AssetTransferBox::class.java, AssetTransferBoxSerializer) + module.addSerializer(NonZeroOfu64::class.java, NonZeroOfu64Serializer) + module.addSerializer(Executable.Instructions::class.java, ExecutableInstructionsSerializer) + module.addSerializer(ExecuteTriggerEventFilter::class.java, ExecuteTriggerEventFilterSerializer) + module.addSerializer(AssetType::class.java, AssetTypeSerializer) + module.addSerializer(Numeric::class.java, NumericSerializer) + module.addSerializer(Permission::class.java, PermissionSerializer) mapper.registerModule(module) mapper.registerModule( @@ -165,51 +212,62 @@ public val JSON_SERDE by lazy { .configure(KotlinFeature.NullToEmptyMap, true) .build(), ) - mapper.propertyNamingStrategy = PropertyNamingStrategies.SNAKE_CASE mapper.enable(SerializationFeature.INDENT_OUTPUT) } } /** - * Deserializer for sequence expr [SequenceExpr] + * Deserializer for [Iroha Special Instructions][InstructionBox] */ -object SequenceExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SequenceExpr { - return sealedDeserializeSequenceExpr(p, JSON_SERDE) +object InstructionDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): InstructionBox { + return deserializeInstruction(p.readValueAsTree(), JSON_SERDE) } -} -/** - * Deserializer for [Iroha Special Instructions][InstructionExpr] - */ -object InstructionDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): InstructionExpr { - return sealedDeserializeInstruction(p.readValueAsTree(), JSON_SERDE) + private fun deserializeInstruction(jsonNode: JsonNode, mapper: ObjectMapper): InstructionBox { + val node = jsonNode.fields().next() + val param = node.key + + val subtype = InstructionBox::class.nestedClasses.find { clazz -> + !clazz.isCompanion && clazz.simpleName == param + } ?: throw DeserializationException("Class with constructor($param) not found") + + val argTypeName = subtype.primaryConstructor?.parameters + ?.firstOrNull()?.type?.toString() + ?: throw DeserializationException("Subtype parameter not found by $param") + + val toConvert: JsonNode = node.value + + val arg = mapper.convertValue(toConvert, argTypeName.asClass()) + return subtype.primaryConstructor?.call(arg) as InstructionBox } } -/** - * Deserializer for [ExecutorMode] - */ -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 { + val node = p.readValueAsTree() + val paramClass = node.fields().next().key.toArg() + + return get(JSON_SERDE.convertValue(node.fields().next().value, paramClass)) } -} -object GrantExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): GrantExpr { - return sealedDeserializeGrantExpr(p, JSON_SERDE) + private fun String.toArg(): Class<*> { + return when (this) { + "Permission" -> GrantOfPermissionAndAccount::class.java + "Role" -> GrantOfRoleIdAndAccount::class.java + "RolePermission" -> GrantOfPermissionAndRole::class.java + else -> throw DeserializationException("Unknown type: $this") + } } -} -/** - * Deserializer for [Value] - */ -object ValueDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Value { - return sealedDeserializeValue(p, JSON_SERDE) + private fun get(arg: Any): GrantBox { + return when (arg) { + is GrantOfPermissionAndAccount -> GrantBox.Permission(arg) + is GrantOfRoleIdAndAccount -> GrantBox.Role(arg) + is GrantOfPermissionAndRole -> GrantBox.RolePermission(arg) + else -> throw DeserializationException("Grant box `$arg` not found") + } } } @@ -232,77 +290,116 @@ object IdBoxDeserializer : JsonDeserializer() { } } -object RegisterExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): RegisterExpr { - return sealedDeserializeRegisterExpr(p, JSON_SERDE) +object RegisterBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): RegisterBox { + val node = p.readValueAsTree().fields().next() + + val paramClass = node.key.toArg() + val value = JSON_SERDE.convertValue(node.value, paramClass) + + return getRegisterBox(value) } -} -object MintExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): MintExpr { - return deserializeMintExpr(p, JSON_SERDE) + private fun String.toArg(): Class<*> { + return when (this) { + "Domain" -> NewDomain::class.java + "Peer" -> Peer::class.java + "Account" -> NewAccount::class.java + "AssetDefinition" -> NewAssetDefinition::class.java + "Asset" -> Asset::class.java + "Trigger" -> Trigger::class.java + "Role" -> Role::class.java + else -> throw DeserializationException("Unknown string type: $this") + } } -} -object NewParameterExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewParameterExpr { - return deserializeNewParameterExpr(p, JSON_SERDE) + private fun getRegisterBox(arg: Any): RegisterBox { + return when (arg) { + is NewDomain -> RegisterBox.Domain(RegisterOfDomain(arg)) + is NewAccount -> RegisterBox.Account(RegisterOfAccount(arg)) + is Peer -> RegisterBox.Peer(RegisterOfPeer(arg)) + is NewAssetDefinition -> RegisterBox.AssetDefinition(RegisterOfAssetDefinition(arg)) + is Asset -> RegisterBox.Asset(RegisterOfAsset(arg)) + is Trigger -> RegisterBox.Trigger(RegisterOfTrigger(arg)) + is Role -> RegisterBox.Role(RegisterOfRole(arg)) + else -> throw DeserializationException("Register box `$arg` not found") + } } } -object StringWithJsonDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): StringWithJson { - val node = p.readValueAsTree().fields().next() +/** + * Deserializer for [BurnBox] + */ +object BurnBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): BurnBox { + val node = p.readValueAsTree() + val paramClass = node.fields().next().key.toArg() - return StringWithJson( - string = "{\"${node.key}\":\"${node.value.asText()}\"}", - ) + return get(JSON_SERDE.convertValue(node.fields().next().value, paramClass)) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "Asset" -> BurnOfNumericAndAsset::class.java + "TriggerRepetitions" -> BurnOfu32AndTrigger::class.java + else -> throw DeserializationException("Unknown type: $this") + } + } + + private fun get(arg: Any): BurnBox { + return when (arg) { + is BurnOfNumericAndAsset -> BurnBox.Asset(arg) + is BurnOfu32AndTrigger -> BurnBox.TriggerRepetitions(arg) + else -> throw DeserializationException("Burn box `$arg` not found") + } } } -object TriggerOfTriggeringFilterBoxDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): TriggerOfTriggeringFilterBox { +object MintBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): MintBox { val node = p.readValueAsTree() - val triggerName = node.get("id").asText() - val triggerAction = node.get("action") - val action = when (triggerAction.get("executable").get("Instructions") == null) { - true -> { - val wasm = triggerAction.get("executable").get("Wasm") - val executable = Executable.Wasm(WasmSmartContract(wasm.asText().toByteArray())) - val repeats = getTriggerRepeats(triggerAction) - val accountId = getTriggerAuthority(triggerAction) - val filter = getTriggerFilter(triggerAction) - ActionOfTriggeringFilterBox( - executable = executable, - repeats = repeats, - authority = accountId, - filter = filter, - metadata = Metadata(mapOf()), - ) - } - false -> { - val instructions = triggerAction.get("executable").get("Instructions").map { - sealedDeserializeInstruction(it, JSON_SERDE) - } - val executable = Executable.Instructions(instructions) - val repeats = getTriggerRepeats(triggerAction) - val accountId = getTriggerAuthority(triggerAction) - val filter = getTriggerFilter(triggerAction) - ActionOfTriggeringFilterBox( - executable = executable, - repeats = repeats, - authority = accountId, - filter = filter, - metadata = Metadata(mapOf()), - ) - } + val paramClass = node.fields().next().key.toArg() + + return get(JSON_SERDE.convertValue(node.fields().next().value, paramClass)) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "Asset" -> MintOfNumericAndAsset::class.java + "TriggerRepetitions" -> MintOfu32AndTrigger::class.java + else -> throw DeserializationException("Unknown type: $this") } + } - val triggerId = getTriggerId(triggerName) - return TriggerOfTriggeringFilterBox( - id = triggerId, - action = action, - ) + private fun get(arg: Any): MintBox { + return when (arg) { + is MintOfNumericAndAsset -> MintBox.Asset(arg) + is MintOfu32AndTrigger -> MintBox.TriggerRepetitions(arg) + else -> throw DeserializationException("Mint box `$arg` not found") + } + } +} + +object EventFilterBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): EventFilterBox { + val node = p.readValueAsTree().fields().next() + return getBox(JSON_SERDE.convertValue(node.value, node.key.toArg())) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "ExecuteTrigger" -> ExecuteTriggerEventFilter::class.java + "Time" -> TimeEventFilter::class.java + else -> throw DeserializationException("Unknown type `$this`") + } + } + + private fun getBox(arg: Any): EventFilterBox { + return when (arg) { + is ExecuteTriggerEventFilter -> EventFilterBox.ExecuteTrigger(arg) + is TimeEventFilter -> EventFilterBox.Time(arg) + else -> throw DeserializationException("Unknown type `$this`") + } } } @@ -313,57 +410,402 @@ object TriggerIdDeserializer : JsonDeserializer() { } } -object PermissionTokenDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): PermissionToken { - val jsonNode = p.readValueAsTree() - val iter = jsonNode.iterator() - val nodes = mutableListOf() - while (iter.hasNext()) { - val node = iter.next() - nodes.add(node) - } +object TransferBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): TransferBox { + val node = p.readValueAsTree() + val paramClass = node.fields().next().key.toArg() + + return get(JSON_SERDE.convertValue(node.fields().next().value, paramClass)) + } - val definitionId = jsonNode.fields().next() - val payload = when (nodes[1].isNull) { - true -> StringWithJson("") - false -> JSON_SERDE.convertValue(nodes[1], StringWithJson::class.java) + private fun String.toArg(): Class<*> { + return when (this) { + "Domain" -> TransferOfAccountAndDomainIdAndAccount::class.java + "Asset" -> AssetTransferBox::class.java + "AssetDefinition" -> TransferOfAccountAndAssetDefinitionIdAndAccount::class.java + else -> throw DeserializationException("Unknown type: $this") } + } - return PermissionToken( - definitionId = definitionId.value.asText().asName(), - payload = payload, - ) + private fun get(arg: Any): TransferBox { + return when (arg) { + is TransferOfAccountAndDomainIdAndAccount -> TransferBox.Domain(arg) + is AssetTransferBox -> TransferBox.Asset(arg) + is TransferOfAccountAndAssetDefinitionIdAndAccount -> TransferBox.AssetDefinition(arg) + else -> throw DeserializationException("SetKeyValue box `$arg` not found") + } } } -object SetKeyValueExprDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SetKeyValueExpr { - return deserializeSetKeyValueExpr(p, JSON_SERDE) +object SetKeyValueBoxDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SetKeyValueBox { + val node = p.readValueAsTree() + val paramClass = node.fields().next().key.toArg() + + return get(JSON_SERDE.convertValue(node.fields().next().value, paramClass)) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "Domain" -> SetKeyValueOfDomain::class.java + "Account" -> SetKeyValueOfAccount::class.java + "Asset" -> SetKeyValueOfAsset::class.java + "AssetDefinition" -> SetKeyValueOfAssetDefinition::class.java + "Trigger" -> SetKeyValueOfTrigger::class.java + else -> throw DeserializationException("Unknown type: $this") + } + } + + private fun get(arg: Any): SetKeyValueBox { + return when (arg) { + is SetKeyValueOfDomain -> SetKeyValueBox.Domain(arg) + is SetKeyValueOfAccount -> SetKeyValueBox.Account(arg) + is SetKeyValueOfAsset -> SetKeyValueBox.Asset(arg) + is SetKeyValueOfAssetDefinition -> SetKeyValueBox.AssetDefinition(arg) + is SetKeyValueOfTrigger -> SetKeyValueBox.Trigger(arg) + else -> throw DeserializationException("SetKeyValue box `$arg` not found") + } } } +/** + * Deserializer for [Metadata] + */ object MetadataDeserializer : JsonDeserializer() { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Metadata { return deserializeMetadata(p, JSON_SERDE) } + + private fun deserializeMetadata(p: JsonParser, mapper: ObjectMapper): Metadata { + val nodeMetadata = p.readValueAsTree().fields() + if (!nodeMetadata.hasNext()) { + return Metadata(mapOf()) + } + val node = nodeMetadata.next() + val key = node.key.asName() + val value = node.value.asStringOrNull() ?: "" + return Metadata(mapOf(Pair(key, value))) + } +} + +/** + * Deserializer for [AssetType] + */ +object AssetTypeDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): AssetType { + return when (p.readValueAsTree().textValue()) { + AssetType.Numeric::class.simpleName -> AssetType.Numeric(NumericSpec()) + AssetType.Store::class.simpleName -> AssetType.Store() + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [NumericSpec] + */ +object NumericSpecDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NumericSpec { + return NumericSpec(p.readValueAsTree().longValue()) + } +} + +/** + * Deserializer for [Numeric] + */ +object NumericDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Numeric { + return p.readValueAs(String::class.java).asNumeric() + } } -object NewRoleDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewRole { - return deserializeNewRole(p, JSON_SERDE) +/** + * Deserializer for [Permission] + */ +object PermissionDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Permission { + val node = p.readValueAsTree() + var payloadValue = node.get("payload").asStringOrNull() + when (payloadValue.isNullOrEmpty()) { + true -> payloadValue = "null" + else -> {} + } + return Permission(node.get("name").asText(), payloadValue) } } /** - * Deserializer for [AssetValueType] + * Deserializer for [ChainId] */ -object AssetValueTypeDeserializer : JsonDeserializer() { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): AssetValueType { - val text = p.readValueAs(String::class.java) - return AssetValueType::class.nestedClasses - .findLast { it.simpleName == text } - ?.createInstance() as AssetValueType? - ?: throw DeserializationException("AssetValueType $text not found") +object ChainIdDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ChainId { + return ChainId(p.readValueAs(String::class.java)) + } +} + +/** + * Deserializer for [NewAssetDefinition] + */ +object NewAssetDefinitionDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewAssetDefinition { + val node = p.readValueAsTree() + val domainId = node["id"].asText().asAssetDefinitionId() + val mintable = JSON_SERDE.convertValue(node["mintable"], Mintable::class.java) + val type = JSON_SERDE.convertValue(node["type"], AssetType::class.java) + val logo = JSON_SERDE.convertValue(node["logo"], IpfsPath::class.java) + val metadata = JSON_SERDE.convertValue(node["metadata"], Metadata::class.java) + + return NewAssetDefinition(domainId, type, mintable, logo, metadata) + } +} + +/** + * Deserializer for [NewDomain] + */ +object NewDomainDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NewDomain { + val node = p.readValueAsTree() + val domainId = node["id"].asText().asDomainId() + val logo = JSON_SERDE.convertValue(node["logo"], IpfsPath::class.java) + val metadata = JSON_SERDE.convertValue(node["metadata"], Metadata::class.java) + + return NewDomain(domainId, logo, metadata) + } +} + +/** + * Deserializer for [Trigger] + */ +object TriggerDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Trigger { + val node = p.readValueAsTree() + val triggerId = TriggerId(node["id"].asText().asName()) + val action = JSON_SERDE.convertValue(node["action"], Action::class.java) + + return Trigger(triggerId, action) + } +} + +/** + * Deserializer for [ExecuteTriggerEventFilter] + */ +object ExecuteTriggerEventFilterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ExecuteTriggerEventFilter { + val node = p.readValueAsTree() + val triggerId = TriggerId(node["trigger"].asText().asName()) + val authority = JSON_SERDE.convertValue(node["authority"], AccountId::class.java) + + return ExecuteTriggerEventFilter(triggerId, authority) + } +} + +/** + * Deserializer for [Action] + */ +object ActionDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Action { + val node = p.readValueAsTree() + val executable = JSON_SERDE.convertValue(node["executable"], Executable::class.java) + val repeats = JSON_SERDE.convertValue(node["repeats"], Repeats::class.java) + val authority = JSON_SERDE.convertValue(node["authority"], AccountId::class.java) + val filter = JSON_SERDE.convertValue(node["filter"], EventFilterBox::class.java) + val metadata = JSON_SERDE.convertValue(node["metadata"], Metadata::class.java) + + return Action(executable, repeats, authority, filter, metadata) + } +} + +/** + * Deserializer for [Executable] + */ +object ExecutableDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Executable { + val node = p.readValueAsTree().fields().next() + + val paramClass = node.key.toArg() + val value = JSON_SERDE.convertValue(node.value, paramClass) + + return getExecutable(value) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "Wasm" -> WasmSmartContract::class.java + "Instructions" -> List::class.java + else -> throw DeserializationException("Unknown type: $this") + } + } + + private fun getExecutable(arg: Any): Executable { + return when (arg) { + is WasmSmartContract -> Executable.Wasm(arg) + is List<*> -> Executable.Instructions(arg as List) + else -> throw DeserializationException("Executable `$arg` not found") + } + } +} + +/** + * Deserializer for [IpfsPath] + */ +object IpfsPathDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): IpfsPath { + return IpfsPath(p.readValueAs(String::class.java)) + } +} + +/** + * Deserializer for [Repeats] + */ +object RepeatsDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Repeats { + return when (val node = p.readValueAsTree()) { + is TextNode -> Repeats.Indefinitely() + is ObjectNode -> { + val field = node.fields().next() + Repeats.Exactly(JSON_SERDE.convertValue(field.value, Long::class.java)) + } + + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [Parameter] + */ +object ParameterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Parameter { + val node = p.readValueAsTree().fields().next() + return get(JSON_SERDE.convertValue(node.value, node.key.toArg()), node.key) + } + + private fun String.toArg(): Class<*> { + return when (this) { + "Sumeragi" -> SumeragiParameter::class.java + "Block" -> BlockParameter::class.java + "Transaction" -> TransactionParameter::class.java + "SmartContract" -> SmartContractParameter::class.java + "Executor" -> SmartContractParameter::class.java + "Custom" -> CustomParameter::class.java + else -> throw DeserializationException("Unknown type: $this") + } + } + + private fun get(arg: Any, type: String): Parameter { + return when (type) { + "Sumeragi" -> Parameter.Sumeragi(arg as SumeragiParameter) + "Block" -> Parameter.Block(arg as BlockParameter) + "Transaction" -> Parameter.Transaction(arg as TransactionParameter) + "Executor" -> Parameter.Executor(arg as SmartContractParameter) + "SmartContract" -> Parameter.SmartContract(arg as SmartContractParameter) + "CustomParameter" -> Parameter.Custom(arg as CustomParameter) + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [SumeragiParameter] + */ +object SumeragiParameterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SumeragiParameter { + val node = p.readValueAsTree().fields().next() + val arg = JSON_SERDE.convertValue(node.value, BigInteger::class.java) + return get(arg, node.key) + } + + private fun get(arg: BigInteger, type: String): SumeragiParameter { + return when (type) { + "BlockTimeMs" -> SumeragiParameter.BlockTimeMs(arg) + "CommitTimeMs" -> SumeragiParameter.CommitTimeMs(arg) + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [BlockParameter] + */ +object BlockParameterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): BlockParameter { + val node = p.readValueAsTree().fields().next() + val arg = JSON_SERDE.convertValue(node.value, BigInteger::class.java) + return BlockParameter.MaxTransactions(NonZeroOfu64(arg)) + } +} + +/** + * Deserializer for [TransactionParameter] + */ +object TransactionParameterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): TransactionParameter { + val node = p.readValueAsTree().fields().next() + val arg = JSON_SERDE.convertValue(node.value, BigInteger::class.java) + return get(arg, node.key) + } + + private fun get(arg: BigInteger, type: String): TransactionParameter { + return when (type) { + "MaxInstructions" -> TransactionParameter.MaxInstructions(NonZeroOfu64(arg)) + "SmartContractSize" -> TransactionParameter.SmartContractSize(NonZeroOfu64(arg)) + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [SmartContractParameter] + */ +object SmartContractParameterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SmartContractParameter { + val node = p.readValueAsTree().fields().next() + val arg = JSON_SERDE.convertValue(node.value, BigInteger::class.java) + return get(arg, node.key) + } + + private fun get(arg: BigInteger, type: String): SmartContractParameter { + return when (type) { + "Fuel" -> SmartContractParameter.Fuel(NonZeroOfu64(arg)) + "Memory" -> SmartContractParameter.Memory(NonZeroOfu64(arg)) + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [Schedule] + */ +object ScheduleDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Schedule { + val node = p.readValueAsTree() + return Schedule( + startMs = JSON_SERDE.convertValue(node["start_ms"], BigInteger::class.java), + periodMs = JSON_SERDE.convertValue(node["period_ms"], BigInteger::class.java), + ) + } +} + +/** + * Deserializer for [ExecutionTime] + */ +object ExecutionTimeDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ExecutionTime { + return when (val node = p.readValueAsTree()) { + is TextNode -> ExecutionTime.PreCommit() + is ObjectNode -> ExecutionTime.Schedule(JSON_SERDE.convertValue(node, Schedule::class.java)) + else -> throw DeserializationException("Unknown type: $this") + } + } +} + +/** + * Deserializer for [TimeEventFilter] + */ +object TimeEventFilterDeserializer : JsonDeserializer() { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): TimeEventFilter { + val node = p.readValueAsTree().fields().next() + return TimeEventFilter(JSON_SERDE.convertValue(node.value, ExecutionTime::class.java)) } } @@ -382,8 +824,7 @@ object PublicKeyDeserializer : JsonDeserializer() { */ object NameDeserializer : JsonDeserializer() { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Name { - val key = p.readValueAs(String::class.java) - return Name(key) + return Name(p.readValueAs(String::class.java)) } } @@ -485,16 +926,19 @@ object DomainIdKeyDeserializer : KeyDeserializer() { // ================================================== /** - * Serializer for [RawGenesisBlock] + * Serializer for [RawGenesisTransaction] */ -object RawGenesisBlockSerializer : JsonSerializer() { - override fun serialize(block: RawGenesisBlock, gen: JsonGenerator, serializers: SerializerProvider) { +object RawGenesisTransactionSerializer : JsonSerializer() { + override fun serialize(tx: RawGenesisTransaction, gen: JsonGenerator, serializers: SerializerProvider) { gen.writeStartObject() - when (block.transactions[0].isEmpty()) { - true -> gen.writeObjectField("transactions", listOf()) - false -> gen.writeObjectField("transactions", block.transactions) + gen.writeObjectField("chain", tx.chain.string) + gen.writeObjectField("executor", tx.executor) + gen.writeObjectField("parameters", tx.parameters) + when (tx.instructions.isEmpty()) { + true -> gen.writeObjectField("instructions", listOf()) + false -> gen.writeObjectField("instructions", tx.instructions) } - gen.writeObjectField("executor", block.executor) + gen.writeObjectField("topology", tx.topology) gen.writeEndObject() } } @@ -513,7 +957,7 @@ object AssetDefinitionIdSerializer : JsonSerializer() { */ object AssetIdSerializer : JsonSerializer() { override fun serialize(value: AssetId, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeString(value.asString()) + gen.writeString(value.asString(true)) } } @@ -522,24 +966,7 @@ object AssetIdSerializer : JsonSerializer() { */ object AccountIdSerializer : JsonSerializer() { override fun serialize(value: AccountId, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeString(value.asString()) - } -} - -/** - * Serializer for [PermissionToken] - */ -object PermissionTokenSerializer : JsonSerializer() { - override fun serialize(token: PermissionToken, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeStartObject() - gen.writeObjectField(PermissionToken::definitionId.name.toSnakeCase(), token.definitionId) - - val payload = when (token.payload.string.isEmpty()) { - true -> null - false -> token.payload - } - gen.writeObjectField(PermissionToken::payload.name, payload) - gen.writeEndObject() + gen.writeString(value.asString(true)) } } @@ -576,52 +1003,6 @@ object TriggerIdSerializer : JsonSerializer() { } } -/** - * Serializer for [SequenceExpr] - */ -object SequenceExprSerializer : JsonSerializer() { - override fun serialize(value: SequenceExpr, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeStartArray() - value.instructions.forEach { parameter -> - when (parameter) { - is InstructionExpr.Grant -> parameter.serialize(gen) - is InstructionExpr.Burn -> parameter.serialize(gen) - is InstructionExpr.Mint -> parameter.serialize(gen) - is InstructionExpr.SetKeyValue -> parameter.serialize(gen) - is InstructionExpr.Register -> parameter.serialize(gen) - else -> serializeSingleMember(gen, parameter) - } - } - gen.writeEndArray() - } -} - -/** - * Serializer for [NewParameterExpr] - */ -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() - gen.writeObjectField(Parameter::class.simpleName, parameter) - gen.writeEndObject() - } -} - -/** - * Serializer for [StringWithJson] - */ -object StringWithJsonSerializer : JsonSerializer() { - override fun serialize(value: StringWithJson, gen: JsonGenerator, serializers: SerializerProvider) { - val tree = ObjectMapper().readTree(value.string) - val node = tree.fields().next() - gen.writeStartObject() - gen.writeObjectField(node.key, node.value.asText()) - gen.writeEndObject() - } -} - /** * Serializer for [TimeEventFilter] */ @@ -636,9 +1017,7 @@ object TimeEventFilterSerializer : JsonSerializer() { */ object ScheduleSerializer : JsonSerializer() { override fun serialize(value: Schedule, gen: JsonGenerator, serializers: SerializerProvider) { - val start = value.start.let { mapOf(Pair("secs", it.u64), Pair("nanos", it.u32)) } - val period = value.period?.let { mapOf(Pair("secs", it.u64), Pair("nanos", it.u32)) } - val schedule = mapOf(Pair("start", start), Pair("period", period)) + val schedule = mapOf(Pair("start_ms", value.startMs), Pair("period_ms", value.periodMs)) gen.writeObject(schedule) } } @@ -662,32 +1041,179 @@ object NameSerializer : JsonSerializer() { } /** - * Serializer for [ExecutorMode] + * Serializer for [Executor] */ -object ExecutorModeSerializer : JsonSerializer() { - override fun serialize(value: ExecutorMode, gen: JsonGenerator, serializers: SerializerProvider) { +object ExecutorSerializer : JsonSerializer() { + override fun serialize(value: Executor, gen: JsonGenerator, serializers: SerializerProvider) { when (value) { - is ExecutorMode.Path -> gen.writeString(value.string) +// is Executor -> gen.writeString(value.wasm) else -> throw IrohaSdkException("Unsupported type ${this::class}") } } } /** - * Custom serializer for [UInt] + * Serializer for [InstructionBox] */ -object UIntSerializer : JsonSerializer() { - override fun serialize(value: UInt, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeNumber(value.toLong()) +object InstructionBoxSerializer : JsonSerializer() { + override fun serialize(value: InstructionBox, gen: JsonGenerator, serializers: SerializerProvider) { + when (value) { + is InstructionBox.Register -> value.serializeBox(gen) + is InstructionBox.SetKeyValue -> value.serializeBox(gen) + is InstructionBox.Mint -> value.serializeBox(gen) + is InstructionBox.Burn -> value.serializeBox(gen) + is InstructionBox.Transfer -> value.serializeBox(gen) + is InstructionBox.Grant -> value.serializeBox(gen) + else -> throw IrohaSdkException("Unsupported type ${this::class}") + } + } +} + +/** + * Serializer for [RegisterOfDomain] + */ +object RegisterOfDomainSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfDomain, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) } } /** - * Custom serializer for [NumericValue] + * Serializer for [RegisterOfTrigger] */ -object NumericValueSerializer : JsonSerializer() { - override fun serialize(value: NumericValue, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeString(value.format().second) +object RegisterOfTriggerSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfTrigger, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [RegisterOfRole] + */ +object RegisterOfRoleSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfRole, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [RegisterOfAsset] + */ +object RegisterOfAssetSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfAsset, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [RegisterOfAssetDefinition] + */ +object RegisterOfAssetDefinitionSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfAssetDefinition, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [RegisterOfPeer] + */ +object RegisterOfPeerSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfPeer, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [RegisterOfAccount] + */ +object RegisterOfAccountSerializer : JsonSerializer() { + override fun serialize(value: RegisterOfAccount, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.`object`) + } +} + +/** + * Serializer for [AssetTransferBox] + */ +object AssetTransferBoxSerializer : JsonSerializer() { + override fun serialize(value: AssetTransferBox, gen: JsonGenerator, serializers: SerializerProvider) { + when (value) { + is AssetTransferBox.Numeric -> gen.writeObject(value.transferOfAssetAndNumericAndAccount) + is AssetTransferBox.Store -> gen.writeObject(value.transferOfAssetAndMetadataAndAccount) + else -> throw IrohaSdkException("Unexpected type ${value::class}") + } + } +} + +/** + * Serializer for [NonZeroOfu64] + */ +object NonZeroOfu64Serializer : JsonSerializer() { + override fun serialize(value: NonZeroOfu64, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.u64) + } +} + +/** + * Serializer for [Executable.Instructions] + */ +object ExecutableInstructionsSerializer : JsonSerializer() { + override fun serialize(value: Executable.Instructions, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeStartObject() + gen.writeObjectField(Executable.Instructions::class.simpleName, value.vec) + gen.writeEndObject() + } +} + +/** + * Serializer for [ExecuteTriggerEventFilter] + */ +object ExecuteTriggerEventFilterSerializer : JsonSerializer() { + override fun serialize(value: ExecuteTriggerEventFilter, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeStartObject() + gen.writeObjectField("trigger", value.triggerId) + gen.writeObjectField("authority", value.authority) + gen.writeEndObject() + } +} + +/** + * Serializer for [AssetType] + */ +object AssetTypeSerializer : JsonSerializer() { + override fun serialize(value: AssetType, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value::class.simpleName) + } +} + +/** + * Serializer for [Numeric] + */ +object NumericSerializer : JsonSerializer() { + override fun serialize(value: Numeric, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeObject(value.asString()) + } +} + +/** + * Serializer for [Permission] + */ +object PermissionSerializer : JsonSerializer() { + override fun serialize(value: Permission, gen: JsonGenerator, serializers: SerializerProvider) { + val payload = JSON_SERDE.readTree(value.payload) + gen.writeStartObject() + gen.writeObjectField(Permission::name.name, value.name) + gen.writeObjectField(Permission::payload.name, payload) + gen.writeEndObject() + } +} + +/** + * Custom serializer for [UInt] + */ +object UIntSerializer : JsonSerializer() { + override fun serialize(value: UInt, gen: JsonGenerator, serializers: SerializerProvider) { + gen.writeNumber(value.toLong()) } } @@ -709,16 +1235,11 @@ object PublicKeySerializer : JsonSerializer() { */ object MetadataSerializer : JsonSerializer() { override fun serialize(value: Metadata, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeObject(value.map) - } -} - -/** - * Custom serializer for [EvaluatesTo] - */ -object EvaluatesToSerializer : JsonSerializer>() { - override fun serialize(value: EvaluatesTo<*>, gen: JsonGenerator, serializers: SerializerProvider) { - value.serialize(gen) + gen.writeStartObject() + value.sortedMapOfName.forEach { (k, v) -> + gen.writeStringField(k.string, v) + } + gen.writeEndObject() } } @@ -727,7 +1248,7 @@ object EvaluatesToSerializer : JsonSerializer>() { */ object IdentifiableBoxNewRoleSerializer : JsonSerializer() { override fun serialize(value: IdentifiableBox.NewRole, gen: JsonGenerator, serializers: SerializerProvider) { - serializeSingleMember(gen, value.newRole) + serializeSingleMember(gen, value.role) } } @@ -736,7 +1257,21 @@ object IdentifiableBoxNewRoleSerializer : JsonSerializer() { override fun serialize(value: Parameter, gen: JsonGenerator, serializers: SerializerProvider) { - gen.writeString(value.asString()) + gen.writeStartObject() + when (value) { + is Parameter.Block -> gen.writeObjectField(Parameter.Block::class.simpleName, value.blockParameter) + is Parameter.Custom -> gen.writeObjectField(Parameter.Custom::class.simpleName, value.customParameter) + is Parameter.Executor -> gen.writeObjectField(Parameter.Executor::class.simpleName, value.smartContractParameter) + is Parameter.SmartContract -> gen.writeObjectField( + Parameter.SmartContract::class.simpleName, + value.smartContractParameter, + ) + + is Parameter.Sumeragi -> gen.writeObjectField(Parameter.Sumeragi::class.simpleName, value.sumeragiParameter) + is Parameter.Transaction -> gen.writeObjectField(Parameter.Transaction::class.simpleName, value.transactionParameter) + else -> throw IrohaSdkException("Unexpected type ${value::class}") + } + gen.writeEndObject() } } @@ -746,61 +1281,30 @@ object ParameterSerializer : JsonSerializer() { object EnumerationSerializer : JsonSerializer() { override fun serialize(value: ModelEnum, gen: JsonGenerator, serializers: SerializerProvider) { when (value) { - 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) + 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) else -> serializeSingleMember(gen, value) } } } -private fun Value.Identifiable.serialize(gen: JsonGenerator) = this.serializeEnum(gen) - -private fun Value.Id.serialize(gen: JsonGenerator) = this.serializeEnum(gen) +private fun InstructionBox.SetKeyValue.serialize(gen: JsonGenerator) = this.serializeBox(gen) -private fun Expression.Raw.serialize(gen: JsonGenerator) = this.serializeEnum(gen) +private fun InstructionBox.Grant.serialize(gen: JsonGenerator) = this.serializeBox(gen) -private fun EvaluatesTo<*>.serialize(gen: JsonGenerator) = this.serializeEnum(gen) +private fun InstructionBox.Burn.serialize(gen: JsonGenerator) = this.serializeBox(gen) -private fun InstructionExpr.SetKeyValue.serialize(gen: JsonGenerator) = this.serializeExpr(gen) - -private fun InstructionExpr.Grant.serialize(gen: JsonGenerator) { - return this.serializeExpr(gen) -} +private fun InstructionBox.Mint.serialize(gen: JsonGenerator) = this.serializeBox(gen) -private fun InstructionExpr.Burn.serialize(gen: JsonGenerator) = this.serializeExpr(gen) - -private fun InstructionExpr.Mint.serialize(gen: JsonGenerator) = this.serializeExpr(gen) - -private fun InstructionExpr.Register.serialize(gen: JsonGenerator) { - val clazz = this::class - val memberProperties = clazz.memberProperties - when (memberProperties.size) { - 0 -> gen.writeString(clazz.simpleName) - 1 -> { - gen.writeStartObject() - gen.writeObjectField( - clazz.simpleName, - memberProperties.first().call(this) - ?.cast() - ?.`object`?.expression, - ) - gen.writeEndObject() - } - - else -> throw SerializationException("Expected enum that accepts exactly 0 or 1 members as tuple") - } -} +private fun InstructionBox.Register.serialize(gen: JsonGenerator) = this.serializeBox(gen) /** - * Serializes BurnExpr, MintExpr, GrantExpr etc... + * Serializes BurnBox, MintBox, GrantBox etc... */ -private inline fun InstructionExpr.serializeExpr(gen: JsonGenerator) { +private inline fun InstructionBox.serializeBox(gen: JsonGenerator) { val clazz = this::class val memberProperties = clazz.memberProperties when (memberProperties.size) { @@ -808,7 +1312,7 @@ private inline fun InstructionExpr.serializeExpr(gen: JsonGenerator) 1 -> { gen.writeStartObject() gen.writeObjectFieldStart(clazz.simpleName) - memberProperties.first().call(this)?.cast()?.serializeExpr(gen) + memberProperties.first().call(this)?.cast()?.serializeBox(gen) gen.writeEndObject() gen.writeEndObject() } @@ -817,74 +1321,38 @@ private inline fun InstructionExpr.serializeExpr(gen: JsonGenerator) } } -private inline fun B.serializeExpr( +private inline fun B.serializeBox( gen: JsonGenerator, ) = when (B::class) { - BurnExpr::class -> this?.cast()?.serializeExpr(gen) - MintExpr::class -> this?.cast()?.serializeExpr(gen) - GrantExpr::class -> this?.cast()?.serializeExpr(gen) - SetKeyValueExpr::class -> this?.cast()?.serializeExpr(gen) + BurnBox::class -> this?.cast()?.serializeBox(gen) + MintBox::class -> this?.cast()?.serializeBox(gen) + GrantBox::class -> this?.cast()?.serializeBox(gen) + TransferBox::class -> this?.cast()?.serializeBox(gen) + SetKeyValueBox::class -> this?.cast()?.serializeBox(gen) + RegisterBox::class -> this?.cast()?.serializeBox(gen) else -> throw IrohaSdkException("Unexpected type ${B::class}") } -private fun BurnExpr.serializeExpr( - gen: JsonGenerator, -) = mintBurnSerialize(gen, this.`object`.expression, this.destinationId) +private fun BurnBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) -private fun MintExpr.serializeExpr( - gen: JsonGenerator, -) = mintBurnSerialize(gen, this.`object`.expression, this.destinationId) +private fun MintBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) -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 InstructionExpr serialization error") - } - gen.writeObjectFieldStart("object") - gen.writeObjectField(fieldData.first, fieldData.second) - gen.writeEndObject() - gen.writeObjectField("destination_id", this.destinationId) -} +private fun GrantBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) -private fun SetKeyValueExpr.serializeExpr(gen: JsonGenerator) { - val id = this.objectId.expression - .cast().value - .cast().idBox - .extractId() - gen.writeObjectField(id::class.simpleName, id) - gen.writeObjectField("key", this.key) +private fun TransferBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) - val fieldValue = when (val value = this.value.expression.cast().value) { - is Value.Numeric -> value.cast().numericValue.formatAsString() - else -> value - } - gen.writeObjectField("value", fieldValue) -} +private fun RegisterBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) -private fun mintBurnSerialize( - gen: JsonGenerator, - expression: Expression, - destinationId: EvaluatesTo, -) { - val rawValue = expression.cast().value.cast().numericValue - gen.writeObjectField("object", rawValue) - gen.writeObjectField("destination_id", destinationId) -} +private fun SetKeyValueBox.serializeBox(gen: JsonGenerator) = serializeBox(this, gen) -private fun NumericValue.formatAsString() = when (this) { - is NumericValue.U32 -> "${this.u32}_u32" - is NumericValue.U64 -> "${this.u64}_u64" - is NumericValue.U128 -> "${this.u128}_u128" - is NumericValue.Fixed -> "${this.fixed.fixedPointOfI64}_fx" -}.toString() +private fun serializeBox(obj: Any, gen: JsonGenerator) { + val memberProperties = obj::class.memberProperties + when (memberProperties.size) { + 0 -> gen.writeString(obj::class.simpleName) + 1 -> gen.writeObjectField(obj::class.simpleName, memberProperties.first().call(obj)) -private fun NumericValue.format() = when (this) { - is NumericValue.U32 -> NumericValue.U32::class.simpleName to "${this.u32}_${NumericValue.U32::class.simpleName?.lowercase()}" - is NumericValue.U64 -> NumericValue.U64::class.simpleName to "${this.u64}_${NumericValue.U64::class.simpleName?.lowercase()}" - is NumericValue.U128 -> NumericValue.U128::class.simpleName to "${this.u128}_${NumericValue.U128::class.simpleName?.lowercase()}" - is NumericValue.Fixed -> NumericValue.Fixed::class.simpleName to this.fixed.fixedPointOfI64.toString() - else -> throw IrohaSdkException("Invalid numeric value") + else -> throw SerializationException("Expected enum that accepts exactly 0 or 1 members as tuple") + } } /** @@ -928,169 +1396,26 @@ private fun String.asClass() = runCatching { } } ?: throw DeserializationException("Class $this not found") -private fun sealedDeserializeSequenceExpr(p: JsonParser, mapper: ObjectMapper): SequenceExpr { - val jsonNodes = p.readValueAsTree() - val instructions = jsonNodes.map { - mapper.convertValue(it, InstructionExpr::class.java) as InstructionExpr - } - return SequenceExpr(instructions) -} - -private fun sealedDeserializeInstruction(jsonNode: JsonNode, mapper: ObjectMapper): InstructionExpr { - val node = jsonNode.fields().next() - val param = node.key - - val subtype = InstructionExpr::class.nestedClasses.find { clazz -> - !clazz.isCompanion && clazz.simpleName == param - } ?: throw DeserializationException("Class with constructor($param) not found") - - val argTypeName = subtype.primaryConstructor?.parameters - ?.firstOrNull()?.type?.toString() - ?: throw DeserializationException("Subtype parameter not found by $param") - - val toConvert: JsonNode = node.value - - val arg = mapper.convertValue(toConvert, argTypeName.asClass()) - return subtype.primaryConstructor?.call(arg) as InstructionExpr -} - -private fun sealedDeserializeValidator(p: JsonParser, mapper: ObjectMapper): ExecutorMode { - return ExecutorMode.Path(p.readValueAsTree().asText()) -} - -private fun sealedDeserializeGrantExpr(p: JsonParser, mapper: ObjectMapper): GrantExpr { - val jsonNode = p.readValueAsTree() - - val iter = jsonNode.iterator() - val nodes = mutableListOf() - while (iter.hasNext()) { - val node = iter.next() - nodes.add(node) - } - - val node = jsonNode.fields().next().value.fields().next() - val destination = nodes[1] - val paramAndValueToConvert = if (RoleId::class.java.simpleName == node.key) { - Pair( - "Id", - mapper.createObjectNode().set( - jsonNode.fields().next().key, - jsonNode.fields().next().value, - ), - ) - } else { - Pair(node.key, node.value) - } - - val subtype = Value::class.nestedClasses.find { clazz -> - !clazz.isCompanion && clazz.simpleName?.contains(paramAndValueToConvert.first) ?: false - } ?: throw DeserializationException("Class with constructor(${paramAndValueToConvert.first}) not found") - - val argTypeName = subtype.primaryConstructor?.parameters - ?.firstOrNull()?.type?.toString() - ?: throw DeserializationException("Subtype parameter not found by ${paramAndValueToConvert.first}") - - val grantObject = mapper.convertValue(paramAndValueToConvert.second, argTypeName.asClass()) - val destinationId = mapper.convertValue(destination, IdBox::class.java) - return GrantExpr( - `object` = grantObject.evaluatesTo().cast(), - destinationId = destinationId.evaluatesTo().cast(), - ) -} - -private fun sealedDeserializeValue(p: JsonParser, mapper: ObjectMapper): Value { - val node = p.readValueAsTree() - if (node is TextNode) { - return Value.Numeric(node.textValue().toNumericValue()) - } - - val field = node.fields().next() - val param = when { - field.key.contains("Id") -> "Id" - "Numeric" == field.key -> field.value.fields().next().key - else -> field.key - } - val clazz = getClazzByParam(param) - - return when (param) { - "Bool" -> Value.Bool(field.value.booleanValue()) - "String" -> Value.String(field.value.asText()) - else -> { - val name = if (field.key == "Id" || field.key == "Numeric") field.value.fields().next().key else field.key - val value = - if (field.key == "Id" || field.key == "Numeric") field.value.fields().next().value else field.value - val subtype = clazz.nestedClasses.find { - !it.isCompanion && it.simpleName == name - } ?: throw DeserializationException("Class with constructor($param) not found") - - val argTypeName = subtype.primaryConstructor?.parameters - ?.firstOrNull()?.type?.toString() - ?: throw DeserializationException("Subtype parameter not found by $param") - - val arg = mapper.convertValue(value, argTypeName.asClass()) - return getValueByClazz(clazz, subtype, arg, name, param) - } - } -} - -private fun getValueByClazz(clazz: KClass, subtype: KClass<*>, arg: Any, name: String, param: String): Value { - return when (clazz) { - Name::class -> Value.Name(subtype.primaryConstructor?.call(arg) as Name) - Value::class -> throw DeserializationException("Value type $clazz not supported") - Metadata::class -> Value.LimitedMetadata(subtype.primaryConstructor?.call(arg) as Metadata) - Limits::class -> Value.MetadataLimits(subtype.primaryConstructor?.call(arg) as Limits) - TransactionLimits::class -> Value.TransactionLimits(subtype.primaryConstructor?.call(arg) as TransactionLimits) - LengthLimits::class -> Value.LengthLimits(subtype.primaryConstructor?.call(arg) as LengthLimits) - IdBox::class -> Value.Id(subtype.primaryConstructor?.call(arg) as IdBox) - IdentifiableBox::class -> Value.Identifiable(subtype.primaryConstructor?.call(arg) as IdentifiableBox) - PublicKey::class -> Value.PublicKey(subtype.primaryConstructor?.call(arg) as PublicKey) - 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) - 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) - NumericValue::class -> { - when (name) { - "U32" -> Value.Numeric(subtype.primaryConstructor?.call(arg) as NumericValue.U32) - "U64" -> Value.Numeric(subtype.primaryConstructor?.call(arg) as NumericValue.U64) - "U128" -> Value.Numeric(subtype.primaryConstructor?.call(arg) as NumericValue.U128) - "Fixed" -> Value.Numeric(subtype.primaryConstructor?.call(arg) as NumericValue.Fixed) - else -> throw DeserializationException("Numeric value $param not found") - } - } - - else -> throw DeserializationException("Value type $clazz not found") - } -} - private fun getClazzByParam(param: String): KClass { return when (param) { + "SetKeyValue" -> SetKeyValueBox::class "Bool" -> Boolean::class "String" -> String::class "Name" -> Name::class - "Vec" -> Value::class "LimitedMetadata" -> Metadata::class - "MetadataLimits" -> Limits::class - "TransactionLimits" -> TransactionLimits::class - "LengthLimits" -> LengthLimits::class "Id" -> IdBox::class "Identifiable" -> IdentifiableBox::class "PublicKey" -> PublicKey::class - "SignatureCheckCondition" -> SignatureCheckCondition::class - "TransactionValue" -> TransactionValue::class "TransactionQueryOutput" -> TransactionQueryOutput::class - "PermissionToken" -> PermissionToken::class "Hash" -> Hash::class "Block" -> SignedBlock::class "BlockHeader" -> BlockHeader::class "Ipv4Addr" -> Ipv4Addr::class "Ipv6Addr" -> Ipv6Addr::class - "U32" -> NumericValue::class - "U64" -> NumericValue::class - "U128" -> NumericValue::class - "Fixed" -> NumericValue::class + "U32" -> Numeric::class + "U64" -> Numeric::class + "U128" -> Numeric::class + "Fixed" -> Numeric::class else -> throw DeserializationException("Value key $param not found") } } @@ -1111,192 +1436,29 @@ private fun sealedDeserializeIdBox(p: JsonParser, mapper: ObjectMapper): IdBox { return subtype.primaryConstructor?.call(arg) as IdBox } -private fun sealedDeserializeRegisterExpr(p: JsonParser, mapper: ObjectMapper): RegisterExpr { - val node = p.readValueAsTree().fields().next() - - val param = node.key.removePrefix("New") - val subtype = RegistrableBox::class.nestedClasses.find { clazz -> - !clazz.isCompanion && clazz.simpleName == param - } - val argTypeName = subtype?.primaryConstructor?.parameters - ?.firstOrNull()?.type?.toString() - ?: throw DeserializationException("Subtype parameter not found by $param") - - val arg = mapper.convertValue(node.value, argTypeName.asClass()) - return getRegisterExpr(arg) -} - -private fun getRegisterExpr(arg: Any): RegisterExpr { - return when (arg) { - 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 deserializeMintExpr(p: JsonParser, mapper: ObjectMapper): MintExpr { - val jsonNode = p.readValueAsTree() - val iter = jsonNode.iterator() - val nodes = mutableListOf() - while (iter.hasNext()) { - val node = iter.next() - nodes.add(node) - } - val numericTypeAndValue = jsonNode.fields().next().value.asText().split("_") - val newNode = mapper.createObjectNode().set( - numericTypeAndValue[1].toUpperCasePreservingASCIIRules(), - IntNode(numericTypeAndValue[0].toInt()), - ) - val objectId = mapper.convertValue( - newNode, - Value::class.java, - ) as Value - val destination = mapper.convertValue( - nodes[1], - IdBox::class.java, - ) as IdBox - return MintExpr( - `object` = objectId.evaluatesTo().cast(), - destinationId = destination.evaluatesTo().cast(), - ) -} - -private fun deserializeNewParameterExpr(p: JsonParser, mapper: ObjectMapper): NewParameterExpr { - val jsonNode = p.readValueAsTree().fields().next() - val parameter = jsonNode.value.asText().asParameter() - - return NewParameterExpr( - parameter = parameter.evaluatesTo().cast(), - ) -} - -private fun deserializeSetKeyValueExpr(p: JsonParser, mapper: ObjectMapper): SetKeyValueExpr { - val jsonNode = p.readValueAsTree() - val iter = jsonNode.iterator() - val nodes = mutableListOf() - while (iter.hasNext()) { - val node = iter.next() - nodes.add(node) - } - - val objectId = jsonNode.fields().next() - val key = nodes[1].fields().next() - val subtype = IdBox::class.nestedClasses.find { clazz -> - !clazz.isCompanion && clazz.simpleName == objectId.key - } - val argTypeName = subtype?.primaryConstructor?.parameters - ?.firstOrNull()?.type?.toString() - ?: throw DeserializationException("Subtype parameter not found by $objectId") - - 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 SetKeyValueExpr( - objectId = objectIdArg.evaluatesTo().cast(), - key = keyArg.evaluatesTo().cast(), - value = valueArg.evaluatesTo().cast(), - ) -} - -private fun deserializeNewRole(p: JsonParser, mapper: ObjectMapper): NewRole { - val iter = p.readValueAsTree().iterator() - val nodes = mutableListOf() - while (iter.hasNext()) { - val node = iter.next() - nodes.add(node) - } - - val tokens = nodes[1].map { - mapper.convertValue(it, PermissionToken::class.java) as PermissionToken - } - val roleId = RoleId(nodes[0].asText().asName()) - return NewRole(Role(id = roleId, permissions = tokens)) -} - -private fun deserializeMetadata(p: JsonParser, mapper: ObjectMapper): Metadata { - val nodeMetadata = p.readValueAsTree().fields() - if (!nodeMetadata.hasNext()) { - return Metadata(mapOf()) - } - val node = nodeMetadata.next() - val key = node.key.asName() - val valueNode = node.value.fields().next() - val value = valueNode.value.asText().asValue() - return Metadata(mapOf(Pair(key, value))) -} - -private fun String.toNumericValue(): NumericValue { - val (number, type) = this.split('_') - return when (type) { - NumericValue.U32::class.simpleName?.lowercase() -> NumericValue.U32(number.toLong()) - NumericValue.U64::class.simpleName?.lowercase() -> NumericValue.U64(number.toBigInteger()) - NumericValue.U128::class.simpleName?.lowercase() -> NumericValue.U128(number.toBigInteger()) - "fx" -> NumericValue.Fixed(Fixed(number.toBigDecimal())) - else -> throw IllegalArgumentException("Number out of range") - } -} - -private fun getTriggerAuthority(triggerAction: JsonNode): AccountId { - return triggerAction.get("authority").asText().asAccountId() -} - private fun getTriggerId(triggerName: String): TriggerId { return when (triggerName.contains("$")) { - true -> { - val triggerNameWithDomain = triggerName.split("$") - TriggerId(name = triggerNameWithDomain[0].asName(), domainId = triggerNameWithDomain[1].asDomainId()) - } + true -> TriggerId(name = triggerName.split("$")[0].asName()) false -> TriggerId(name = triggerName.asName()) } } -private fun getTriggerRepeats(triggerAction: JsonNode): Repeats { - val repeatsNodeFields = triggerAction.get("repeats").fields() - return when (repeatsNodeFields.hasNext()) { - true -> Repeats.Exactly(repeatsNodeFields.next().value.asLong()) - false -> Repeats.Indefinitely() - } -} - -private fun getTriggerFilter(triggerAction: JsonNode): TriggeringFilterBox { - val filterNode = triggerAction.get("filter").fields().next() - return when (filterNode.key) { - "Data" -> { - throw IrohaSdkException("${filterNode.key} is not supported") - } - "Time" -> { - val scheduleNode = filterNode.value.get("Schedule") - val start = scheduleNode.get("start") - val period = scheduleNode.get("period") - val periodDuration = when (period.isNull) { - true -> null - false -> Duration(u64 = BigInteger.valueOf(period.get("secs").asLong()), u32 = period.get("nanos").asLong()) - } - TriggeringFilterBox.Time( - TimeEventFilter( - ExecutionTime.Schedule( - Schedule( - Duration(u64 = BigInteger.valueOf(start.get("secs").asLong()), u32 = start.get("nanos").asLong()), - periodDuration, - ), - ), - ), - ) - } - "ExecuteTrigger" -> { - val executeTrigger = JSON_SERDE.convertValue(filterNode.value, ExecuteTriggerEventFilter::class.java) - TriggeringFilterBox.ExecuteTrigger(executeTrigger) - } - "Pipeline" -> { - throw IrohaSdkException("${filterNode.key} is not supported") - } - else -> { - throw IrohaSdkException("${filterNode.key} is not supported") - } +private fun Any.toInstructionBox(): InstructionBox { + return when (this) { + is GrantBox -> InstructionBox.Grant(this) + is RevokeBox -> InstructionBox.Revoke(this) + is ExecuteTrigger -> InstructionBox.ExecuteTrigger(this) + is SetParameter -> InstructionBox.SetParameter(this) + is Upgrade -> InstructionBox.Upgrade(this) + is Log -> InstructionBox.Log(this) + is CustomInstruction -> InstructionBox.Custom(this) + is SetKeyValueBox -> InstructionBox.SetKeyValue(this) + is RemoveKeyValueBox -> InstructionBox.RemoveKeyValue(this) + is TransferBox -> InstructionBox.Transfer(this) + is BurnBox -> InstructionBox.Burn(this) + is MintBox -> InstructionBox.Mint(this) + is RegisterBox -> InstructionBox.Register(this) + is UnregisterBox -> InstructionBox.Unregister(this) + else -> throw DeserializationException("Unknown type: $this") } } diff --git a/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/DeserializerTest.kt b/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/DeserializerTest.kt index 140af9d23..b962eadfa 100644 --- a/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/DeserializerTest.kt +++ b/modules/block/src/test/kotlin/jp/co/soramitsu/iroha2/DeserializerTest.kt @@ -1,6 +1,6 @@ package jp.co.soramitsu.iroha2 -import jp.co.soramitsu.iroha2.generated.RawGenesisBlock +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction import org.junit.jupiter.api.Test import java.io.File import kotlin.test.assertEquals @@ -10,88 +10,45 @@ class DeserializerTest { fun `should deserialize genesis block`() { val json = File("../test-tools/src/main/resources/genesis.json") val node = JSON_SERDE.readTree(json) - val block = JSON_SERDE.convertValue(node, RawGenesisBlock::class.java) + val transaction = JSON_SERDE.convertValue(node, RawGenesisTransaction::class.java) - assert(block.transactions.isNotEmpty()) - // genesis.json has 10 instructions ("isi") - // Register -> NewDomain - // Register -> NewAccount (2) - // Register -> NewAssetDefinition - // Grant -> PermissionToken (2) - // Mint -> AssetId (2) - // Register -> Trigger (2) - assert(block.transactions.flatten().size == 10) + assert(transaction.instructions.isNotEmpty()) - val genesis = Genesis(block) - val newJson = removeWhiteSpaceAndReplacePubKey(genesis.asJson()) - val initialJson = removeWhiteSpaceAndReplacePubKey(json.readText()) - assertEquals(initialJson, newJson) + val genesis = Genesis(transaction) + val newJson = removeWhiteSpacesAndReplacePubKey(genesis.asJson()) + val initialJson = removeWhiteSpacesAndReplacePubKey(json.readText()) + assertEquals(initialJson.lowercase(), newJson.lowercase()) } @Test fun `should deserialize genesis block2`() { val json = File("../test-tools/src/main/resources/genesis2.json") val node = JSON_SERDE.readTree(json) - val block = JSON_SERDE.convertValue(node, RawGenesisBlock::class.java) + val transaction = JSON_SERDE.convertValue(node, RawGenesisTransaction::class.java) - assert(block.transactions.isNotEmpty()) - // genesis.json has 23 instructions ("isi") - // Register -> NewDomain - // Register -> NewDomain - // Register -> NewDomain - // Register -> NewDomain - // Register -> NewAccount - // Register -> NewAccount - // Register -> NewAccount - // Register -> NewAccount - // Register -> NewAccount - // Register -> NewAssetDefinition - // Register -> NewAssetDefinition - // Register -> NewAssetDefinition - // Register -> Asset - // Register -> Asset - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // SetKeyValue -> AssetId - // Grant -> PermissionToken - assert(block.transactions.flatten().size == 23) + assert(transaction.instructions.isNotEmpty()) - val genesis = Genesis(block) - val newJson = removeWhiteSpaceAndReplacePubKey(genesis.asJson()) - val initialJson = removeWhiteSpaceAndReplacePubKey(json.readText()) - assertEquals(initialJson, newJson) + val genesis = Genesis(transaction) + val newJson = removeWhiteSpacesAndReplacePubKey(genesis.asJson()) + val initialJson = removeWhiteSpacesAndReplacePubKey(json.readText()) + assertEquals(initialJson.lowercase(), newJson.lowercase()) } @Test fun `should deserialize genesis block3`() { val json = File("../test-tools/src/main/resources/genesis3.json") val node = JSON_SERDE.readTree(json) - val block = JSON_SERDE.convertValue(node, RawGenesisBlock::class.java) + val transaction = JSON_SERDE.convertValue(node, RawGenesisTransaction::class.java) - assert(block.transactions.isNotEmpty()) - // genesis.json has 17 instructions ("isi") - // Register -> NewDomain - // Register -> NewAccount (3) - // Register -> NewAssetDefinition (5) - // Register -> NewRole - // Mint -> AssetId - // Grant -> PermissionToken - // SetKeyValue -> AssetId (2) - // Mint -> AssetId (3) - assert(block.transactions.flatten().size == 17) + assert(transaction.instructions.isNotEmpty()) - val genesis = Genesis(block) - val newJson = removeWhiteSpaceAndReplacePubKey(genesis.asJson()) - val initialJson = removeWhiteSpaceAndReplacePubKey(json.readText()) - assertEquals(initialJson, newJson) + val genesis = Genesis(transaction) + val newJson = removeWhiteSpacesAndReplacePubKey(genesis.asJson()) + val initialJson = removeWhiteSpacesAndReplacePubKey(json.readText()) + assertEquals(initialJson.lowercase(), newJson.lowercase()) } - private fun removeWhiteSpaceAndReplacePubKey(json: String): String { + private fun removeWhiteSpacesAndReplacePubKey(json: String): String { val regex = "(\"ed01)+\\w+\"".toRegex() return json.replace(System.getProperty("line.separator"), "") .replace(" ", "") 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 9da6551f9..e0f1b6e1a 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 @@ -2,13 +2,11 @@ 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.Duration -import jp.co.soramitsu.iroha2.generated.InstructionExpr +import jp.co.soramitsu.iroha2.generated.ChainId import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.RawGenesisBlock +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction import jp.co.soramitsu.iroha2.generated.Repeats -import jp.co.soramitsu.iroha2.generated.SequenceExpr import jp.co.soramitsu.iroha2.generated.TriggerId import jp.co.soramitsu.iroha2.transaction.EventFilters import jp.co.soramitsu.iroha2.transaction.Instructions @@ -20,152 +18,137 @@ 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(), - ), + RawGenesisTransaction( + ChainId("00000000-0000-0000-0000-000000000000"), + Genesis.EXECUTOR_FILE_NAME, + emptyList(), + Instructions.grantPermissionToken( + Permissions.CanUnregisterAccount, + "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016${ACCOUNT_ID_DELIMITER}wonderland".asAccountId() + .asJsonString(withPrefix = true), + "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03${ACCOUNT_ID_DELIMITER}wonderland".asAccountId(), ).let { listOf(it) }, - Genesis.executorMode, + emptyList(), ), ) val expectedJson = """ { - "block" : { - "transactions" : [ [ { - "Grant" : { - "object" : { - "PermissionToken" : { - "definition_id" : "CanUnregisterAccount", - "payload" : { - "account_id" : "bob@wonderland" + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "executor.wasm", + "parameters": [], + "instructions": [ + { + "Grant": { + "Permission": { + "object": { + "name": "CanUnregisterAccount", + "payload": { + "account": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland" } - } - }, - "destination_id" : { - "AccountId" : "alice@wonderland" + }, + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } - } ] ], - "executor" : "executor.wasm" - } + } + ], + "topology": [] } """.trimIndent() - val json = JSON_SERDE.writeValueAsString(genesis).trimIndent() - assertEquals(expectedJson, json) + + val json = JSON_SERDE.writeValueAsString(genesis.transaction).trimIndent() + assertEquals(expectedJson.lowercase(), json.asPrettyJson().lowercase()) } @Test fun `should serialize mint asset genesis block`() { val triggerId = TriggerId(name = Name("time_trigger")) - val aliceAccountId = "alice${ACCOUNT_ID_DELIMITER}wonderland".asAccountId() + val aliceAccountId = + "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03${ACCOUNT_ID_DELIMITER}wonderland".asAccountId() val assetId = AssetId( - AssetDefinitionId("xor".asName(), "wonderland".asDomainId()), aliceAccountId, + AssetDefinitionId("wonderland".asDomainId(), "xor".asName()), ) val genesis = Genesis( - RawGenesisBlock( + RawGenesisTransaction( + ChainId("00000000-0000-0000-0000-000000000000"), + Genesis.EXECUTOR_FILE_NAME, + emptyList(), listOf( - Instructions.mintAsset( - assetId, - 100, - ), - InstructionExpr.Sequence( - SequenceExpr( - listOf( - Instructions.setKeyValue( - assetId, - "key".asName(), - "value".asValue(), - ), - ), - ), - ), - Instructions.registerTimeTrigger( + Instructions.mintAsset(assetId, 100), + Instructions.setKeyValue(assetId, "key".asName(), "value"), + Instructions.registerTrigger( triggerId, - listOf( - Instructions.mintAsset( - assetId, - 1, - ), - ), + listOf(Instructions.mintAsset(assetId, 1)), Repeats.Indefinitely(), aliceAccountId, + Metadata(mapOf()), EventFilters.timeEventFilter( - Duration(BigInteger.valueOf(1715676978L), 0L), - Duration(BigInteger.valueOf(1L), 0L), + BigInteger.valueOf(1715676978L), + BigInteger.valueOf(1L), ), - Metadata(mapOf()), ), - ).let { listOf(it) }, - Genesis.executorMode, + ), + emptyList(), ), ) val expectedJson = """ { - "block" : { - "transactions" : [ [ { - "Mint" : { - "object" : "100_u32", - "destination_id" : { - "AssetId" : "xor#wonderland#alice@wonderland" + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "executor.wasm", + "parameters": [], + "instructions": [ + { + "Mint": { + "Asset": { + "object": "100", + "destination": "xor#wonderland#ed0120ce7fa46c9dce7ea4b125e2e36bdb63ea33073e7590ac92816ae1e861b7048b03@wonderland" } } - }, { - "Sequence" : [ { - "SetKeyValue" : { - "AssetId" : "xor#wonderland#alice@wonderland", - "key" : { - "Name" : "key" - }, - "value" : { - "String" : "value" - } + }, + { + "SetKeyValue": { + "Asset": { + "object": "xor#wonderland#ed0120ce7fa46c9dce7ea4b125e2e36bdb63ea33073e7590ac92816ae1e861b7048b03@wonderland", + "key": "key", + "value": "value" } - } ] - }, { - "Register" : { - "Trigger" : { - "id" : "time_trigger", - "action" : { - "executable" : { - "Instructions" : [ { - "Mint" : { - "object" : "1_u32", - "destination_id" : { - "AssetId" : "xor#wonderland#alice@wonderland" + } + }, + { + "Register": { + "Trigger": { + "id": "time_trigger", + "action": { + "executable": { + "Instructions": [{ + "Mint": { + "Asset": { + "object": "1", + "destination": "xor#wonderland#ed0120ce7fa46c9dce7ea4b125e2e36bdb63ea33073e7590ac92816ae1e861b7048b03@wonderland" } } - } ] + }] }, - "repeats" : "Indefinitely", - "authority" : "alice@wonderland", - "filter" : { - "Time" : { - "Schedule" : { - "start" : { - "secs" : 1715676978, - "nanos" : 0 - }, - "period" : { - "secs" : 1, - "nanos" : 0 - } + "repeats": "Indefinitely", + "authority": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "filter": { + "Time": { + "Schedule": { + "start_ms": 1715676978, + "period_ms": 1 } } }, - "metadata" : { } + "metadata": {} } } } - } ] ], - "executor" : "executor.wasm" - } + } + ], + "topology": [] } """.trimIndent() - val json = JSON_SERDE.writeValueAsString(genesis).trimIndent() - assertEquals(expectedJson, json) + val json = JSON_SERDE.writeValueAsString(genesis.transaction).trimIndent() + assertEquals(expectedJson.asPrettyJson().lowercase(), json.asPrettyJson().lowercase()) } } diff --git a/modules/block/src/test/resources/executor.wasm b/modules/block/src/test/resources/executor.wasm old mode 100755 new mode 100644 index 265a5d68b..f51b51123 Binary files a/modules/block/src/test/resources/executor.wasm and b/modules/block/src/test/resources/executor.wasm differ diff --git a/modules/client/build.gradle b/modules/client/build.gradle index 941c290d3..ba3d85ba4 100644 --- a/modules/client/build.gradle +++ b/modules/client/build.gradle @@ -5,20 +5,21 @@ plugins { dependencies { api project(":model") - // https://mvnrepository.com/artifact/com.github.docker-java/docker-java + implementation('com.google.code.gson:gson:2.8.9') + implementation("com.github.docker-java:docker-java:3.3.0") - //kotlin support + // kotlin support implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVer" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVer" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVer" - //crypto + // crypto api "org.bouncycastle:bcprov-jdk15on:$bouncyCastleVer" api "net.i2p.crypto:eddsa:$i2pCryptoEddsa" api "com.github.multiformats:java-multihash:$multihashVersion" - //http client + // http client api "io.ktor:ktor-client-core:$ktorVer" api "io.ktor:ktor-client-cio:$ktorVer" api "io.ktor:ktor-client-websockets:$ktorVer" diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Constants.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Constants.kt index 62e06616c..b9dc3c608 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Constants.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Constants.kt @@ -2,7 +2,6 @@ package jp.co.soramitsu.iroha2 const val DEFAULT_P2P_PORT = 1337 const val DEFAULT_API_PORT = 8080 -const val DEFAULT_TELEMETRY_PORT = 8180 const val ASSET_ID_DELIMITER = "#" const val ACCOUNT_ID_DELIMITER = "@" diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Crypto.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Crypto.kt index 72348a4cc..00d5af4ea 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Crypto.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/Crypto.kt @@ -2,6 +2,7 @@ package jp.co.soramitsu.iroha2 +import jp.co.soramitsu.iroha2.generated.PublicKey import net.i2p.crypto.eddsa.EdDSAPrivateKey import net.i2p.crypto.eddsa.EdDSAPublicKey import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec @@ -42,6 +43,11 @@ fun generateKeyPair(spec: EdDSAParameterSpec = DEFAULT_SPEC): KeyPair { } } +@JvmOverloads +fun generatePublicKey( + spec: EdDSAParameterSpec = DEFAULT_SPEC, +): PublicKey = generateKeyPair(spec).public.toIrohaPublicKey() + /** * Create ED25519 key-pair from given hex of the public and private key * @@ -72,7 +78,10 @@ fun privateKeyFromHex(privateKeyHex: String, spec: EdDSAParameterSpec = DEFAULT_ @JvmOverloads fun publicKeyFromHex(publicKeyHex: String, spec: EdDSAParameterSpec = DEFAULT_SPEC) = try { - EdDSAPublicKey(EdDSAPublicKeySpec(publicKeyHex.fromHex(), spec)) + when (publicKeyHex.startsWith("ed0120")) { + true -> EdDSAPublicKey(EdDSAPublicKeySpec(publicKeyHex.drop(6).fromHex(), spec)) + false -> EdDSAPublicKey(EdDSAPublicKeySpec(publicKeyHex.fromHex(), spec)) + } } catch (ex: Exception) { throw CryptoException("Cannot create a public key from hex `$publicKeyHex`", ex) } 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 5136adf15..b30ad3963 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 @@ -1,50 +1,48 @@ package jp.co.soramitsu.iroha2 -import jp.co.soramitsu.iroha2.generated.Name - -enum class Permissions(val type: Name) { - CanBurnUserTrigger("CanBurnUserTrigger".asName()), - CanUnregisterAccount("CanUnregisterAccount".asName()), - CanMintUserPublicKeys("CanMintUserPublicKeys".asName()), - CanBurnUserPublicKeys("CanBurnUserPublicKeys".asName()), - CanMintUserSignatureCheckConditions("CanMintUserSignatureCheckConditions".asName()), - CanSetKeyValueInUserAccount("CanSetKeyValueInUserAccount".asName()), - CanRemoveKeyValueInUserAccount("CanRemoveKeyValueInUserAccount".asName()), - CanRegisterAssetsWithDefinition("CanRegisterAssetsWithDefinition".asName()), - CanUnregisterAssetsWithDefinition("CanUnregisterAssetsWithDefinition".asName()), - CanUnregisterUserAsset("CanUnregisterUserAsset".asName()), - CanBurnAssetWithDefinition("CanBurnAssetsWithDefinition".asName()), - CanBurnUserAssetToken("CanBurnUserAsset".asName()), - CanMintUserAssetDefinitionsToken("CanMintAssetsWithDefinition".asName()), - CanTransferAssetsWithDefinition("CanTransferAssetsWithDefinition".asName()), - CanTransferUserAssetsToken("CanTransferUserAsset".asName()), - CanSetKeyValueUserAssetsToken("CanSetKeyValueInUserAsset".asName()), - CanRemoveKeyValueInUserAssets("CanRemoveKeyValueInUserAsset".asName()), - CanUnregisterAssetDefinition("CanUnregisterAssetDefinition".asName()), - CanSetKeyValueInAssetDefinition("CanSetKeyValueInAssetDefinition".asName()), - CanRemoveKeyValueInAssetDefinition("CanRemoveKeyValueInAssetDefinition".asName()), - CanUnregisterDomain("CanUnregisterDomain".asName()), - CanSetKeyValueInDomain("CanSetKeyValueInDomain".asName()), - CanRemoveKeyValueInDomain("CanRemoveKeyValueInDomain".asName()), - CanGrantPermissionToCreateParameters("CanGrantPermissionToCreateParameters".asName()), - CanRevokePermissionToCreateParameters("CanRevokePermissionToCreateParameters".asName()), - CanCreateParameters("CanCreateParameters".asName()), - CanGrantPermissionToSetParameters("CanGrantPermissionToSetParameters".asName()), - CanRevokePermissionToSetParameters("CanRevokePermissionToSetParameters".asName()), - CanSetParameters("CanSetParameters".asName()), - CanUnregisterAnyPeer("CanUnregisterAnyPeer".asName()), - CanUnregisterAnyRole("CanUnregisterAnyRole".asName()), - CanExecuteUserTrigger("CanExecuteUserTrigger".asName()), - CanUnregisterUserTrigger("CanUnregisterUserTrigger".asName()), - CanMintUserTrigger("CanMintUserTrigger".asName()), - CanUpgradeExecutor("CanUpgradeExecutor".asName()), - CanRemoveKeyValueInTrigger("CanRemoveKeyValueInTrigger".asName()), - CanSetKeyValueInTrigger("CanSetKeyValueInTrigger".asName()), +enum class Permissions(val type: String) { + CanBurnUserTrigger("CanBurnUserTrigger"), + CanUnregisterAccount("CanUnregisterAccount"), + CanMintUserPublicKeys("CanMintUserPublicKeys"), + CanBurnUserPublicKeys("CanBurnUserPublicKeys"), + CanMintUserSignatureCheckConditions("CanMintUserSignatureCheckConditions"), + CanSetKeyValueInAccount("CanSetKeyValueInAccount"), + CanRemoveKeyValueInAccount("CanRemoveKeyValueInAccount"), + CanRegisterAssetsWithDefinition("CanRegisterAssetsWithDefinition"), + CanUnregisterAssetsWithDefinition("CanUnregisterAssetsWithDefinition"), + CanUnregisterUserAsset("CanUnregisterUserAsset"), + CanBurnAssetWithDefinition("CanBurnAssetWithDefinition"), + CanBurnUserAssetToken("CanBurnUserAsset"), + CanMintAssetWithDefinition("CanMintAssetWithDefinition"), + CanTransferAssetWithDefinition("CanTransferAssetWithDefinition"), + CanTransferUserAssetsToken("CanTransferUserAsset"), + CanSetKeyValueInUserAsset("CanSetKeyValueInUserAsset"), + CanRemoveKeyValueInUserAsset("CanRemoveKeyValueInUserAsset"), + CanUnregisterAssetDefinition("CanUnregisterAssetDefinition"), + CanSetKeyValueInAssetDefinition("CanSetKeyValueInAssetDefinition"), + CanRemoveKeyValueInAssetDefinition("CanRemoveKeyValueInAssetDefinition"), + CanUnregisterDomain("CanUnregisterDomain"), + CanSetKeyValueInDomain("CanSetKeyValueInDomain"), + CanRemoveKeyValueInDomain("CanRemoveKeyValueInDomain"), + CanGrantPermissionToCreateParameters("CanGrantPermissionToCreateParameters"), + CanRevokePermissionToCreateParameters("CanRevokePermissionToCreateParameters"), + CanCreateParameters("CanCreateParameters"), + CanGrantPermissionToSetParameters("CanGrantPermissionToSetParameters"), + CanRevokePermissionToSetParameters("CanRevokePermissionToSetParameters"), + CanSetParameters("CanSetParameters"), + CanUnregisterAnyPeer("CanUnregisterAnyPeer"), + CanUnregisterAnyRole("CanUnregisterAnyRole"), + CanExecuteUserTrigger("CanExecuteUserTrigger"), + CanUnregisterUserTrigger("CanUnregisterUserTrigger"), + CanMintUserTrigger("CanMintUserTrigger"), + CanUpgradeExecutor("CanUpgradeExecutor"), + CanRemoveKeyValueInTrigger("CanRemoveKeyValueInTrigger"), + CanSetKeyValueInTrigger("CanSetKeyValueInTrigger"), } enum class IdKey(val type: String) { - AccountId("account_id"), - AssetId("asset_id"), - AssetDefinitionId("asset_definition_id"), - DomainId("domain_id"), + AccountId("account"), + AssetId("asset"), + AssetDefinitionId("asset_definition"), + DomainId("domain"), } 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 0d8dd148c..947874311 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 @@ -1,61 +1,17 @@ package jp.co.soramitsu.iroha2 +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.TextNode +import com.google.gson.GsonBuilder import io.ktor.websocket.Frame -import jp.co.soramitsu.iroha2.generated.AccountId -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.BlockMessage -import jp.co.soramitsu.iroha2.generated.BlockPayload -import jp.co.soramitsu.iroha2.generated.BlockSubscriptionRequest -import jp.co.soramitsu.iroha2.generated.DomainId -import jp.co.soramitsu.iroha2.generated.EvaluatesTo -import jp.co.soramitsu.iroha2.generated.Executable -import jp.co.soramitsu.iroha2.generated.ExecutionTime -import jp.co.soramitsu.iroha2.generated.Expression -import jp.co.soramitsu.iroha2.generated.FilterBox -import jp.co.soramitsu.iroha2.generated.FindError -import jp.co.soramitsu.iroha2.generated.Fixed -import jp.co.soramitsu.iroha2.generated.Hash -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.InstructionExpr -import jp.co.soramitsu.iroha2.generated.Metadata -import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 -import jp.co.soramitsu.iroha2.generated.NumericValue -import jp.co.soramitsu.iroha2.generated.Parameter -import jp.co.soramitsu.iroha2.generated.ParameterId -import jp.co.soramitsu.iroha2.generated.PermissionToken -import jp.co.soramitsu.iroha2.generated.RegistrableBox -import jp.co.soramitsu.iroha2.generated.RoleId -import jp.co.soramitsu.iroha2.generated.Signature -import jp.co.soramitsu.iroha2.generated.SignatureCheckCondition -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.TriggerId -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.* // ktlint-disable no-wildcard-imports import jp.co.soramitsu.iroha2.transaction.TransactionBuilder import net.i2p.crypto.eddsa.EdDSAEngine import org.bouncycastle.jcajce.provider.digest.Blake2b import org.bouncycastle.util.encoders.Hex import java.math.BigDecimal import java.math.BigInteger -import java.security.KeyPair import java.security.MessageDigest import java.security.PrivateKey import java.security.PublicKey @@ -71,13 +27,13 @@ fun Signature.asSignatureOf() = SignatureOf(this) fun String.asAccountId() = this.split(ACCOUNT_ID_DELIMITER).takeIf { it.size == 2 }?.let { parts -> - AccountId(parts[1].asDomainId(), parts[0].asName()) + AccountId(parts[1].asDomainId(), publicKeyFromHex(parts[0]).toIrohaPublicKey()) } ?: throw IllegalArgumentException("Incorrect account ID: $this") fun String.asAssetDefinitionId() = this.split(ASSET_ID_DELIMITER).takeIf { it.size == 2 }?.let { parts -> - AssetDefinitionId(parts[0].asName(), parts[1].asDomainId()) + AssetDefinitionId(parts[1].asDomainId(), parts[0].asName()) } ?: throw IllegalArgumentException("Incorrect asset definition ID: $this") fun String.asAssetId() = this.split(ASSET_ID_DELIMITER).takeIf { @@ -85,12 +41,13 @@ fun String.asAssetId() = this.split(ASSET_ID_DELIMITER).takeIf { }?.let { parts -> parts[2].asAccountId().let { accountId -> val domainId = parts[1].takeIf { it.isNotBlank() }?.asDomainId() + AssetId( + accountId, AssetDefinitionId( + domainId ?: accountId.domain, parts[0].asName(), - domainId ?: accountId.domainId, ), - accountId, ) } } ?: throw IllegalArgumentException("Incorrect asset ID: $this") @@ -99,45 +56,16 @@ fun String.asDomainId() = DomainId(Name(this)) fun String.asRoleId() = RoleId(Name(this)) -fun String.asParameter() = this.split(PARAMETER_DELIMITER).takeIf { - it.size == 2 -}?.let { parts -> - Parameter( - ParameterId(Name(parts[0])), - parts[1].asValue(), - ) -} - fun String.asName() = Name(this) -fun String.asValue() = Value.String(this) - -fun Int.asValue() = Value.Numeric(NumericValue.U32(this.toLong())) - -fun Double.asValue() = Value.Numeric(NumericValue.Fixed(Fixed(this.toBigDecimal()))) - -fun BigDecimal.asValue() = Value.Numeric(NumericValue.Fixed(Fixed(this))) - -fun Long.asValue() = Value.Numeric(NumericValue.U64(BigInteger.valueOf(this))) - -fun BigInteger.asValue() = Value.Numeric(NumericValue.U128(this)) - -fun Boolean.asValue() = Value.Bool(this) - -fun AccountId.asValue() = Value.Id(IdBox.AccountId(this)) - -fun AssetId.asValue() = Value.Id(IdBox.AssetId(this)) - -fun PermissionToken.asValue() = Value.PermissionToken(this) - -fun AssetDefinitionId.asValue() = Value.Id(IdBox.AssetDefinitionId(this)) - -fun DomainId.asValue() = Value.Id(IdBox.DomainId(this)) - fun ByteArray.toFrame(fin: Boolean = true) = Frame.Binary(fin, this) -fun ByteArray.toHex(): String = try { - Hex.toHexString(this) +fun ByteArray.toHex(withPrefix: Boolean = false): String = try { + val prefix = when (withPrefix) { + true -> "ed0120" + false -> "" + } + "${prefix}${Hex.toHexString(this)}" } catch (ex: Exception) { throw HexCodecException("Cannot encode to hex string", ex) } @@ -190,58 +118,18 @@ fun ByteArray.toIrohaHash(): Hash { return Hash(this) } +fun ByteArray.asHashOf() = HashOf(this.toIrohaHash()) + fun ByteArray.hash(): ByteArray { val bytes = Blake2b.Blake2b256().digest(this) bytes[bytes.size - 1] = bytes[bytes.size - 1] or 1 return bytes } -/** - * Hash the given versioned transaction (`VersionedTransaction.V1`) - */ -fun SignedTransaction.V1.hash(): ByteArray { - return this.signedTransactionV1 - .payload - .let { TransactionPayload.encode(it) } - .hash() -} - /** * Hash the given versioned transaction. Maintains only `VersionedTransaction.V1` */ -fun SignedTransaction.hash() = when (this) { - is SignedTransaction.V1 -> this.hash() -} - -/** - * Append signatures to a transaction. Maintains only `VersionedTransaction.V1` - */ -fun SignedTransaction.appendSignatures(vararg keypairs: KeyPair): SignedTransaction { - return when (this) { - is SignedTransaction.V1 -> { - val encodedPayload = signedTransactionV1 - .payload - .let { TransactionPayload.encode(it) } - val signatures = keypairs.map { - Signature( - it.public.toIrohaPublicKey(), - it.private.sign(encodedPayload), - ).asSignatureOf() - }.toSet() - - SignedTransaction.V1( - SignedTransactionV1( - signedTransactionV1.signatures.plus(signatures), - signedTransactionV1.payload, - ), - ) - } - } -} - -fun SignaturesOfOfTransactionPayload.plus( - signatures: Set>, -) = SignaturesOfOfTransactionPayload(this.signatures.plus(signatures)) +fun SignedTransaction.hash() = SignedTransaction.encode(this).hash() /** * Cast to another type @@ -251,88 +139,33 @@ inline fun Any.cast(): B { ?: throw ClassCastException("Could not cast `${this::class.qualifiedName}` to `${B::class.qualifiedName}`") } -/** - * Wrap an object in `EvaluatesTo` - */ -inline fun T.evaluatesTo(): EvaluatesTo { - return when (this) { - is String -> Value.String(this) - is Boolean -> Value.Bool(this) - is AssetId -> Value.Id(IdBox.AssetId(this)) - is AssetDefinitionId -> Value.Id(IdBox.AssetDefinitionId(this)) - is AccountId -> Value.Id(IdBox.AccountId(this)) - is DomainId -> Value.Id(IdBox.DomainId(this)) - is RoleId -> Value.Id(IdBox.RoleId(this)) - is TriggerId -> Value.Id(IdBox.TriggerId(this)) - is IdBox -> Value.Id(this) - is HashValue -> Value.Hash(this) - is HashOf<*> -> Value.Hash(HashValue.Transaction(HashOf(this.hash))) - is Name -> Value.Name(this) - is PermissionToken -> Value.PermissionToken(this) - is IdentifiableBox -> Value.Identifiable(this) - is RegistrableBox -> Value.Identifiable(this.toIdentifiableBox()) - is Parameter -> Value.Identifiable(IdentifiableBox.Parameter(this)) - is SignatureCheckCondition -> Value.SignatureCheckCondition(this) - is Value -> this - else -> throw IllegalArgumentException("Unsupported value type `${T::class.qualifiedName}`") - }.let { value -> - EvaluatesTo(Expression.Raw(value)) - } -} - -fun AccountId.toValueId() = Value.Id(IdBox.AccountId(this)) +fun AssetId.asString(withPrefix: Boolean = true) = this.definition.asString() + ASSET_ID_DELIMITER + this.account.asString(withPrefix) -fun AssetId.toValueId() = Value.Id(IdBox.AssetId(this)) +fun AssetId.asJsonString(withPrefix: Boolean = true) = "{\"asset\": " + + "\"${this.definition.asString() + ASSET_ID_DELIMITER + this.account.asString(withPrefix)}\"}" -fun AssetDefinitionId.toValueId() = Value.Id(IdBox.AssetDefinitionId(this)) +fun AssetDefinitionId.asString() = this.name.string + ASSET_ID_DELIMITER + this.domain.name.string -fun RegistrableBox.toIdentifiableBox() = when (this) { - is RegistrableBox.Account -> IdentifiableBox.NewAccount(this.newAccount) - is RegistrableBox.Peer -> IdentifiableBox.Peer(this.peer) - is RegistrableBox.Asset -> IdentifiableBox.Asset(this.asset) - 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(this.triggerOfTriggeringFilterBox) -} - -inline fun T.asValue() = when (this) { - is String -> this.asValue() - is Long -> this.asValue() - is Int -> this.asValue() - is Double -> this.asValue() - is BigInteger -> this.asValue() - is BigDecimal -> this.asValue() - is Boolean -> this.asValue() - is AccountId -> this.asValue() - is AssetDefinitionId -> this.asValue() - is AssetId -> this.asValue() - is PermissionToken -> this.asValue() - else -> throw RuntimeException("Unsupported type ${T::class}") -} +fun AssetDefinitionId.asJsonString() = "{\"asset_definition\": " + + "\"${this.name.string + ASSET_ID_DELIMITER + this.domain.name.string}\"}" -fun AssetId.asString() = this.definitionId.asString() + ASSET_ID_DELIMITER + this.accountId.asString() +fun AccountId.asString(withPrefix: Boolean = true) = this.signatory.payload.toHex(withPrefix) + + ACCOUNT_ID_DELIMITER + this.domain.name.string -fun AssetId.asJsonString() = "{\"${AssetId::class.java.simpleName.toSnakeCase()}\": " + - "\"${this.definitionId.asString() + ASSET_ID_DELIMITER + this.accountId.asString()}\"}" - -fun AssetDefinitionId.asString() = this.name.string + ASSET_ID_DELIMITER + this.domainId.name.string - -fun AssetDefinitionId.asJsonString() = "{\"${AssetDefinitionId::class.java.simpleName.toSnakeCase()}\": " + - "\"${this.name.string + ASSET_ID_DELIMITER + this.domainId.name.string}\"}" - -fun AccountId.asString() = this.name.string + ACCOUNT_ID_DELIMITER + this.domainId.name.string - -fun AccountId.asJsonString() = "{\"${AccountId::class.java.simpleName.toSnakeCase()}\": " + - "\"${this.name.string + ACCOUNT_ID_DELIMITER + this.domainId.name.string}\"}" +fun AccountId.asJsonString(withPrefix: Boolean = true) = "{\"account\": \"${this.signatory.payload.toHex(withPrefix) + ACCOUNT_ID_DELIMITER + this.domain.name.string}\"}" fun DomainId.asString() = this.name.string -fun DomainId.asJsonString() = "{\"${DomainId::class.java.simpleName.toSnakeCase()}\": " + - "\"${this.name.string}\"}" + +fun DomainId.asJsonString() = "{\"domain\": \"${this.name.string}\"}" fun RoleId.asString() = this.name.string -fun RoleId.asJsonString() = "{\"${RoleId::class.java.simpleName.toSnakeCase()}\": \"${this.name.string}\"}" +fun RoleId.asJsonString() = "{\"role\": \"${this.name.string}\"}" + +fun String.fromJsonString() = when { + this.startsWith("\"") && this.endsWith("\"") -> this.drop(1).dropLast(1) + else -> this +} fun SocketAddr.asString() = when (this) { is SocketAddr.Host -> this.socketAddrHost.let { "${it.host}:${it.port}" } @@ -340,30 +173,26 @@ fun SocketAddr.asString() = when (this) { is SocketAddr.Ipv6 -> this.socketAddrV6.let { "${it.ip}:${it.port}" } } -fun TriggerId.asString() = when (this.domainId) { - null -> this.name.string - else -> this.name.string + TRIGGER_ID_DELIMITER + this.domainId!!.name.string -} - -fun Parameter.asString() = this.id.name.string + PARAMETER_DELIMITER + this.`val`.cast().string +fun TriggerId.asString() = this.name.string fun Metadata.merge(extra: Metadata) = Metadata( - this.map.toMutableMap().also { it.putAll(extra.map) }, + this.sortedMapOfName.toMutableMap().also { it.putAll(extra.sortedMapOfName) }, ) -fun InstructionExpr.Register.extractIdentifiableBox() = runCatching { - this.registerExpr.`object`.expression - .cast().value - .cast().identifiableBox -}.getOrNull() +fun InstructionBox.Register.extractBox() = when (this.registerBox.discriminant()) { + 0 -> this.registerBox.cast() as RegisterBox + 1 -> this.registerBox.cast() as RegisterBox + 2 -> this.registerBox.cast() as RegisterBox + 3 -> this.registerBox.cast() as RegisterBox + 4 -> this.registerBox.cast() as RegisterBox + 5 -> this.registerBox.cast() as RegisterBox + 6 -> this.registerBox.cast() as RegisterBox + else -> null +} -fun Iterable.extractIdentifiableBoxes() = this.asSequence() - .filterIsInstance() - .map { it.registerExpr.`object`.expression } - .filterIsInstance() - .map { it.value } - .filterIsInstance() - .map { it.identifiableBox }.toList() +fun Iterable.extractRegisterBoxes() = this.asSequence() + .filterIsInstance() + .map { it.registerBox } fun IdBox.extractId(): Any = when (this) { is IdBox.RoleId -> this.roleId @@ -373,219 +202,74 @@ fun IdBox.extractId(): Any = when (this) { is IdBox.DomainId -> this.domainId is IdBox.TriggerId -> this.triggerId is IdBox.PeerId -> this.peerId - is IdBox.PermissionTokenId -> this.name - is IdBox.ParameterId -> this.parameterId + is IdBox.CustomParameterId -> this.customParameterId + is IdBox.Permission -> this.permission } -fun InstructionExpr.extractAccount() = this - .cast() - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox - .cast().newAccount - -fun InstructionExpr.Register.extractAccount() = this - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox - .cast().newAccount - -fun InstructionExpr.Register.extractDomain() = this - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox - .cast().newDomain - -fun InstructionExpr.Register.extractAssetDefinition() = this - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox - .cast().newAssetDefinition - -fun InstructionExpr.SetKeyValue.extractKey() = this - .setKeyValueExpr.key.expression - .cast().value - .cast().name - .string - -fun InstructionExpr.SetKeyValue.extractAccountId() = this.setKeyValueExpr.objectId.extractAccountId() - -fun InstructionExpr.Unregister.extractAccountId() = this.unregisterExpr.objectId.extractAccountId() - -fun InstructionExpr.Unregister.extractDomainId() = this.unregisterExpr.objectId.extractDomainId() - -fun EvaluatesTo.extractAssetId() = this - .expression - .cast().value - .cast().idBox - .cast().assetId - -fun EvaluatesTo.extractAccountId() = this - .expression - .cast().value - .cast().idBox - .cast().accountId - -fun EvaluatesTo.extractDomainId() = this - .expression - .cast().value - .cast().idBox - .cast().domainId - -fun InstructionExpr.Mint.extractPublicKey() = this - .mintExpr.`object`.expression - .cast().value - .cast().publicKey - .payload.toHex() - -fun EvaluatesTo.extractNewAssetDefinition() = this - .expression - .cast().value - .cast().identifiableBox - .cast().newAssetDefinition - -inline fun SignedTransaction.extractInstruction() = this +fun InstructionBox.extractAccount() = this + .cast() + .registerBox + .cast() + .registerOfAccount.`object` + +fun InstructionBox.Register.extractAccount() = this + .registerBox + .cast() + .registerOfAccount.`object` + +fun InstructionBox.Register.extractDomain() = this + .cast() + .registerBox + .cast() + .registerOfDomain.`object` + +fun InstructionBox.Register.extractAssetDefinition() = this + .cast() + .registerBox + .cast() + .registerOfAssetDefinition.`object` + +inline fun SignedTransaction.extractInstruction(): I = this .cast() .extractInstruction() -inline fun SignedTransaction.V1.extractInstruction() = this +inline fun SignedTransaction.V1.extractInstruction() = this .extractInstructionVec() .first().cast() -inline fun SignedTransaction.V1.extractInstructions() = this +inline fun SignedTransaction.V1.extractInstructions() = this .extractInstructionVec() .cast>() -inline fun SignedTransaction.V1.extractInstructionVec() = this +inline fun SignedTransaction.V1.extractInstructionVec() = this .signedTransactionV1.payload.instructions .cast() .vec.filterIsInstance() -fun InstructionExpr.Register.extractNewDomainMetadata() = this - .registerExpr.`object`.expression - .cast().value - .cast().identifiableBox - .cast().newDomain.metadata - -fun InstructionExpr.SetKeyValue.extractDomainId() = this - .setKeyValueExpr.objectId.expression - .cast().value - .cast().idBox - .cast().domainId - -fun InstructionExpr.SetKeyValue.key() = this - .setKeyValueExpr.key.expression - .cast().value - .cast().name.string - -fun InstructionExpr.SetKeyValue.extractValueString() = this - .setKeyValueExpr.value.expression - .cast().value - .cast().string - -fun InstructionExpr.SetKeyValue.extractValueU32() = this.setKeyValueExpr.value.extractValueU32() - -fun InstructionExpr.SetKeyValue.extractValueU128() = this - .setKeyValueExpr.value.expression - .cast().value - .getValue().numericValue - .getValue() - -fun InstructionExpr.SetKeyValue.extractValueBoolean() = this - .setKeyValueExpr.value.expression - .cast().value - .cast().bool - -fun InstructionExpr.Grant.extractValuePermissionToken() = this - .grantExpr.`object`.expression - .cast().value - .cast().permissionToken - -fun InstructionExpr.Burn.extractValueU32() = this.burnExpr.`object`.extractValueU32() - -fun EvaluatesTo.extractValueU32() = this - .expression - .cast().value - .getValue().numericValue - .getValue() - -fun TriggerOfTriggeringFilterBox.extractSchedule() = this.action.filter.extractSchedule() - -fun TriggeringFilterBox.extractSchedule() = this - .cast() - .timeEventFilter.executionTime - .cast().schedule - -fun FilterBox.extractSchedule() = this - .cast() +fun InstructionBox.SetKeyValue.extractDomainId() = this + .cast() + .setKeyValueBox + .cast() + .setKeyValueOfDomain + .`object` + +fun InstructionBox.Grant.extractValuePermissionToken() = this + .cast() + .grantBox + .cast() + .grantOfPermissionAndAccount + .`object` + +fun EventFilterBox.extractSchedule() = this + .cast() .timeEventFilter.executionTime .cast().schedule -fun BlockMessage.extractBlock() = this - .cast().signedBlock.cast().signedBlockV1 - .extractBlock() - -fun SignedBlockV1.extractBlock() = this.cast().payload +fun BlockMessage.extractBlock() = this.signedBlock.cast().signedBlockV1.payload fun BlockPayload.height() = this.header.height -fun Metadata.getStringValue(key: String) = this.map.getStringValue(key) - -fun Metadata.getBooleanValue(key: String) = this.map.getBooleanValue(key) - -fun Metadata.getNameValue(key: String) = this.map.getNameValue(key) - -fun Metadata.getFixedValue(key: String) = this.map.getFixedValue(key) - -fun Map.getStringValue(key: String) = this[key.asName()]?.cast()?.string - -fun Map.getBooleanValue(key: String) = this[key.asName()]?.cast()?.bool - -fun Map.getU32Value(key: String) = this[key.asName()] - ?.cast()?.numericValue - ?.cast()?.u32 - -fun Map.getU64Value(key: String) = this[key.asName()] - ?.cast()?.numericValue - ?.cast()?.u64 - -fun Map.getU128Value(key: String) = this[key.asName()] - ?.cast()?.numericValue - ?.cast()?.u128 - -fun Map.getFixedValue(key: String) = this[key.asName()] - ?.cast()?.numericValue - ?.cast()?.fixed?.fixedPointOfI64 - -fun Map.getNameValue(key: String) = this[key.asName()]?.cast()?.name - -inline fun NumericValue.getValue() = when (this) { - is NumericValue.U32 -> this.u32.cast() - is NumericValue.U64 -> this.u64.cast() - is NumericValue.U128 -> this.u128.cast() - is NumericValue.Fixed -> this.fixed.fixedPointOfI64.cast() -} - -inline fun Value.getValue() = when (this) { - is Value.Numeric -> this.numericValue.cast() - is Value.Bool -> this.bool.cast() - is Value.String -> this.string.cast() - is Value.Name -> this.name.string.cast() - else -> throw IllegalArgumentException("Value type is not supported") -} - -inline fun Map.extract(key: String) = when (T::class) { - Int::class -> this.getU32Value(key)?.toInt() - BigInteger::class -> this.getU128Value(key) - String::class -> this.getStringValue(key) - Boolean::class -> this.getBooleanValue(key) - BigDecimal::class -> this.getFixedValue(key) - else -> throw RuntimeException("Unknown type ${T::class}") -} as T? - -inline fun Metadata.extract(key: String) = this.map.extract(key) - -fun Asset.metadata() = this.value.cast().metadata.map +fun Asset.metadata() = this.value.cast().metadata.sortedMapOfName fun TransactionBuilder.merge(other: TransactionBuilder) = this.instructions.value.addAll(other.instructions.value) @@ -607,9 +291,8 @@ fun FindError.extract() = when (this) { is FindError.Role -> this.roleId.asString() is FindError.Block -> this.hashOf.hash.arrayOfU8.toHex() is FindError.MetadataKey -> this.name.string - is FindError.Parameter -> this.parameterId.name.string is FindError.Peer -> this.peerId.address.toString() - is FindError.PermissionToken -> this.name.string + is FindError.Permission -> this.permission.name is FindError.PublicKey -> this.publicKey.payload.toString() is FindError.Trigger -> this.triggerId.asString() is FindError.Transaction -> this.hashOf.hash.arrayOfU8.toHex() @@ -648,10 +331,60 @@ fun String.toSnakeCase() = this .joinToString("_") .lowercase(Locale.getDefault()) -fun String.asStringWithJson() = StringWithJson(this) +fun Number.asNumeric() = when (this) { + is Int -> this.asNumeric() + is Long -> this.asNumeric() + is BigInteger -> this.asNumeric() + is Double -> this.asNumeric() + is BigDecimal -> this.asNumeric() + else -> throw IrohaSdkException("Unexpected type to extract numeric ${this::class}") +} + +fun String.asNumeric() = Numeric(mantissa = this.toBigInteger(), scale = 0) + +fun Int.asNumeric() = Numeric(mantissa = this.toBigInteger(), scale = 0) + +fun Long.asNumeric() = Numeric(mantissa = this.toBigInteger(), scale = 0) + +fun BigInteger.asNumeric() = Numeric(mantissa = this, scale = 0) + +fun Double.asNumeric() = this.toBigDecimal().asNumeric() + +fun BigDecimal.asNumeric() = Numeric(mantissa = this.unscaledValue(), scale = this.scale().toLong()) + +fun Numeric.asInt() = this.mantissa.toInt() + +fun Numeric.asLong() = this.mantissa.toLong() -fun AssetId.asStringWithJson() = this.asJsonString().asStringWithJson() +fun Numeric.asBigInteger() = this.mantissa -fun AccountId.asStringWithJson() = this.asJsonString().asStringWithJson() +fun Numeric.asBigDecimal() = BigDecimal.valueOf(this.mantissa.toLong(), this.scale.toInt()) -fun RoleId.asStringWithJson() = this.asJsonString().asStringWithJson() +fun Numeric.asNumber() = when (this.scale) { + 0L -> this.mantissa + else -> this.asBigDecimal() +} + +fun Numeric.asString() = this.asNumber().toString() + +fun AssetType.Companion.numeric(scale: Long? = null) = AssetType.Numeric(NumericSpec(scale)) + +fun Metadata.getStringValue(key: String) = this.sortedMapOfName[key.asName()] + +fun Metadata.getBooleanValue(key: String) = this.sortedMapOfName[key.asName()] + +fun Metadata.getNameValue(key: String) = this.sortedMapOfName[key.asName()] + +fun Metadata.getFixedValue(key: String) = this.sortedMapOfName[key.asName()] + +fun JsonNode.asStringOrNull() = when (this) { + is NullNode -> null + is TextNode -> this.asText() + else -> this.toString() +} + +fun String.asPrettyJson(): String { + val gson = GsonBuilder().setPrettyPrinting().create() + val jsonElement = com.google.gson.JsonParser.parseString(this) + return gson.toJson(jsonElement) +} 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 82dd2a0b4..4c8781319 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 @@ -3,44 +3,43 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.generated.Account import jp.co.soramitsu.iroha2.generated.Asset import jp.co.soramitsu.iroha2.generated.AssetDefinition -import jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue +import jp.co.soramitsu.iroha2.generated.BatchedResponse import jp.co.soramitsu.iroha2.generated.BlockHeader import jp.co.soramitsu.iroha2.generated.Domain +import jp.co.soramitsu.iroha2.generated.ExecutorDataModel import jp.co.soramitsu.iroha2.generated.IdBox import jp.co.soramitsu.iroha2.generated.IdentifiableBox -import jp.co.soramitsu.iroha2.generated.NumericValue +import jp.co.soramitsu.iroha2.generated.Numeric import jp.co.soramitsu.iroha2.generated.Peer -import jp.co.soramitsu.iroha2.generated.PermissionToken -import jp.co.soramitsu.iroha2.generated.PermissionTokenSchema +import jp.co.soramitsu.iroha2.generated.Permission +import jp.co.soramitsu.iroha2.generated.QueryOutputBox 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.Trigger import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox -import jp.co.soramitsu.iroha2.generated.Value -import java.math.BigInteger /** * Extractors are used by [QueryBuilder] to extract data from query results */ interface ResultExtractor { - fun extract(result: BatchedResponseOfValue): T + fun extract(result: BatchedResponse): T } /** * @return the query result as it is */ -object AsIs : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): BatchedResponseOfValue = result +object AsIs : ResultExtractor> { + override fun extract(result: BatchedResponse): BatchedResponse = result } /** * Extract an asset from a query [result] */ object AssetExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Asset { - return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Asset::asset) + override fun extract(result: BatchedResponse): Asset { + return extractIdentifiable(result.cast().batchedResponseV1.batch, IdentifiableBox.Asset::asset) } } @@ -48,8 +47,8 @@ object AssetExtractor : ResultExtractor { * Extract an asset definition from a query [result] */ object AssetDefinitionExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): AssetDefinition { - return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.AssetDefinition::assetDefinition) + override fun extract(result: BatchedResponse): AssetDefinition { + return extractIdentifiable(result.cast().batchedResponseV1.batch, IdentifiableBox.AssetDefinition::assetDefinition) } } @@ -57,8 +56,8 @@ object AssetDefinitionExtractor : ResultExtractor { * Extract an account from a query [result] */ object AccountExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Account { - return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Account::account) + override fun extract(result: BatchedResponse): Account { + return extractIdentifiable(result.cast().batchedResponseV1.batch, IdentifiableBox.Account::account) } } @@ -66,19 +65,28 @@ object AccountExtractor : ResultExtractor { * Extract a list of accounts from a query [result] */ object AccountsExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.Account::account) } } } +/** + * Extract a numeric from a query + */ +object NumericExtractor : ResultExtractor { + override fun extract(result: BatchedResponse): Numeric { + return result.cast().batchedResponseV1.batch.cast().numeric + } +} + /** * Extract a list of assets from a query [result] */ object AssetsExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.Asset::asset) } } @@ -88,8 +96,8 @@ object AssetsExtractor : ResultExtractor> { * Extract a list of asset definitions from a query [result] */ object AssetDefinitionsExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.AssetDefinition::assetDefinition) } } @@ -99,8 +107,8 @@ object AssetDefinitionsExtractor : ResultExtractor> { * Extract a domain from a query [result] */ object DomainExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Domain { - return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Domain::domain) + override fun extract(result: BatchedResponse): Domain { + return extractIdentifiable(result.cast().batchedResponseV1.batch, IdentifiableBox.Domain::domain) } } @@ -108,8 +116,8 @@ object DomainExtractor : ResultExtractor { * Extract a list of domains from a query [result] */ object DomainsExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.Domain::domain) } } @@ -119,8 +127,8 @@ object DomainsExtractor : ResultExtractor> { * Extract a lost of peers from a query [result] */ object PeersExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.Peer::peer) } } @@ -129,11 +137,11 @@ object PeersExtractor : ResultExtractor> { /** * Extract a trigger from a query [result] */ -object TriggerBoxExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): TriggerOfTriggeringFilterBox { +object TriggerBoxExtractor : ResultExtractor { + override fun extract(result: BatchedResponse): Trigger { return extractIdentifiable( - result.cast().batchedResponseV1OfValue.batch, - IdentifiableBox.Trigger::triggerOfTriggeringFilterBox, + result.cast().batchedResponseV1.batch, + IdentifiableBox.Trigger::trigger, ) } } @@ -141,10 +149,10 @@ object TriggerBoxExtractor : ResultExtractor { /** * Extract a list of triggers from a query [result] */ -object TriggerBoxesExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractIdentifiable(it, IdentifiableBox.Trigger::triggerOfTriggeringFilterBox) +object TriggerBoxesExtractor : ResultExtractor> { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractIdentifiable(it, IdentifiableBox.Trigger::trigger) } } } @@ -153,9 +161,9 @@ object TriggerBoxesExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.Id::idBox).cast().triggerId + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.Id::idBox).cast().triggerId } } } @@ -163,10 +171,10 @@ object TriggerIdsExtractor : ResultExtractor> { /** * Extract a list of permission tokens from a query [result] */ -object PermissionTokensExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.PermissionToken::permissionToken) +object PermissionTokensExtractor : ResultExtractor> { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.Permission::permission) } } } @@ -174,9 +182,9 @@ object PermissionTokensExtractor : ResultExtractor> { /** * Extract a permission token schema from a query [result] */ -object PermissionTokenSchemaExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): PermissionTokenSchema { - return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.PermissionTokenSchema::permissionTokenSchema) +object ExecutorDataModelExtractor : ResultExtractor { + override fun extract(result: BatchedResponse): ExecutorDataModel { + return extractValue(result.cast().batchedResponseV1.batch, QueryOutputBox.ExecutorDataModel::executorDataModel) } } @@ -184,9 +192,9 @@ object PermissionTokenSchemaExtractor : ResultExtractor { * Extract a list of transaction values from a query [result] */ object TransactionValuesExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.TransactionQueryOutput::transactionQueryOutput) + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.Transaction::transactionQueryOutput) } } } @@ -195,72 +203,41 @@ object TransactionValuesExtractor : ResultExtractor * Extract a transaction value from a query [result] */ object TransactionValueExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): TransactionQueryOutput { - return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.TransactionQueryOutput::transactionQueryOutput) + override fun extract(result: BatchedResponse): TransactionQueryOutput { + return extractValue(result.cast().batchedResponseV1.batch, QueryOutputBox.Transaction::transactionQueryOutput) } } object BlocksValueExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.Block::signedBlock) + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.Block::signedBlock) } } } object BlockHeadersExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.BlockHeader::blockHeader) + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.BlockHeader::blockHeader) } } } object BlockHeaderExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): BlockHeader { - return extractValue(result.cast().batchedResponseV1OfValue.batch, Value.BlockHeader::blockHeader) - } -} - -/** - * Extract `Value.U32` from a query [result] - */ -object U32Extractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Long { - return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> - v.cast().numericValue.cast().u32 - } - } -} - -/** - * Extract `Value.U64` from a query [result] - */ -object U64Extractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): BigInteger { - return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> - v.cast().numericValue.cast().u64 - } - } -} - -/** - * Extract `Value.U128` from a query [result] - */ -object U128Extractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): BigInteger { - return extractValue(result.cast().batchedResponseV1OfValue.batch) { v: Value -> - v.cast().numericValue.cast().u128 - } + override fun extract(result: BatchedResponse): BlockHeader { + return extractValue(result.cast().batchedResponseV1.batch, QueryOutputBox.BlockHeader::blockHeader) } } /** - * Extract `Value` from a query [result] + * Extract `String` from a query [result] */ -object ValueExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Value { - return result.cast().batchedResponseV1OfValue.batch +object StringExtractor : ResultExtractor { + override fun extract(result: BatchedResponse): String { + return result.cast().batchedResponseV1.batch + .cast().string + .fromJsonString() } } @@ -268,8 +245,8 @@ object ValueExtractor : ResultExtractor { * Extract a list of roles from a query [result] */ object RolesExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { extractIdentifiable(it, IdentifiableBox.Role::role) } } @@ -279,8 +256,8 @@ object RolesExtractor : ResultExtractor> { * Extract a role from a query [result] */ object RoleExtractor : ResultExtractor { - override fun extract(result: BatchedResponseOfValue): Role { - return extractIdentifiable(result.cast().batchedResponseV1OfValue.batch, IdentifiableBox.Role::role) + override fun extract(result: BatchedResponse): Role { + return extractIdentifiable(result.cast().batchedResponseV1.batch, IdentifiableBox.Role::role) } } @@ -288,9 +265,9 @@ object RoleExtractor : ResultExtractor { * Extract a list of role IDs from a query [result] */ object RoleIdsExtractor : ResultExtractor> { - override fun extract(result: BatchedResponseOfValue): List { - return extractVec(result.cast().batchedResponseV1OfValue.batch) { - extractValue(it, Value.Id::idBox).cast().roleId + override fun extract(result: BatchedResponse): List { + return extractVec(result.cast().batchedResponseV1.batch) { + extractValue(it, QueryOutputBox.Id::idBox).cast().roleId } } } @@ -300,9 +277,9 @@ object RoleIdsExtractor : ResultExtractor> { * * @param downstream Type to extract */ -inline fun extractIdentifiable(value: Value, downstream: (I) -> R): R { +inline fun extractIdentifiable(value: QueryOutputBox, downstream: (I) -> R): R { return when (value) { - is Value.Identifiable -> when (val box = value.identifiableBox) { + is QueryOutputBox.Identifiable -> when (val box = value.identifiableBox) { is I -> downstream(box) else -> throw QueryPayloadExtractionException( "Expected `${I::class.qualifiedName}`, but got `${box::class.qualifiedName}`", @@ -310,7 +287,7 @@ inline fun extractIdentifiable(value: Value, downstream: } else -> throw QueryPayloadExtractionException( - "Expected `${Value.Identifiable::class.qualifiedName}`, but got `${value::class.qualifiedName}`", + "Expected `${QueryOutputBox.Identifiable::class.qualifiedName}`, but got `${value::class.qualifiedName}`", ) } } @@ -320,14 +297,14 @@ inline fun extractIdentifiable(value: Value, downstream: * * @param downstream Type to extract */ -inline fun extractVec(value: Value, downstream: (Value) -> R): List { +inline fun extractVec(value: QueryOutputBox, downstream: (QueryOutputBox) -> R): List { when (value) { - is Value.Vec -> { + is QueryOutputBox.Vec -> { return value.vec.map { downstream(it) } } else -> throw QueryPayloadExtractionException( - "Expected `${Value.Vec::class.qualifiedName}`, but got `${value::class.qualifiedName}`", + "Expected `${QueryOutputBox.Vec::class.qualifiedName}`, but got `${value::class.qualifiedName}`", ) } } @@ -337,7 +314,7 @@ inline fun extractVec(value: Value, downstream: (Value) -> R): List< * * @param downstream Type to extract */ -inline fun extractValue(value: Value, downstream: (V) -> R): R { +inline fun extractValue(value: QueryOutputBox, downstream: (V) -> R): R { return when (value) { is V -> downstream(value) else -> throw QueryPayloadExtractionException( 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 e6d5be0df..935bcf08e 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 @@ -37,21 +37,19 @@ import jp.co.soramitsu.iroha2.client.blockstream.BlockStreamStorage 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.BatchedResponse +import jp.co.soramitsu.iroha2.generated.BatchedResponseV1 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.EventBox import jp.co.soramitsu.iroha2.generated.EventMessage import jp.co.soramitsu.iroha2.generated.EventSubscriptionRequest 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.PipelineEventBox +import jp.co.soramitsu.iroha2.generated.QueryOutputBox 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.TransactionStatus import jp.co.soramitsu.iroha2.hash import jp.co.soramitsu.iroha2.height import jp.co.soramitsu.iroha2.model.IrohaUrls @@ -100,14 +98,13 @@ open class Iroha2Client( constructor( apiUrl: URL, - telemetryUrl: URL, peerUrl: URL, log: Boolean = false, credentials: String? = null, eventReadTimeoutInMills: Long = 250, eventReadMaxAttempts: Int = 10, ) : this( - IrohaUrls(apiUrl, telemetryUrl, peerUrl), + IrohaUrls(apiUrl, peerUrl), log, credentials, eventReadTimeoutInMills, @@ -116,7 +113,6 @@ open class Iroha2Client( constructor( apiUrl: String, - telemetryUrl: String, peerUrl: String, log: Boolean = true, credentials: String? = null, @@ -124,7 +120,6 @@ open class Iroha2Client( eventReadMaxAttempts: Int = 10, ) : this( URL(apiUrl), - URL(telemetryUrl), URL(peerUrl), log, credentials, @@ -169,15 +164,16 @@ open class Iroha2Client( credentials { BasicAuthCredentials(pair[0], pair[1]) } + sendWithoutRequest { + true + } } } } HttpResponseValidator { handleResponseExceptionWithRequest { exception, _ -> - val status = exception - .takeIf { it is ClientRequestException } - ?.cast() - ?.response?.status + val err = exception.takeIf { it is ClientRequestException }?.cast() + val status = err?.response?.status throw IrohaClientException(cause = exception, status = status) } } @@ -189,26 +185,21 @@ open class Iroha2Client( */ suspend fun sendQuery( queryAndExtractor: QueryAndExtractor, - start: Long? = null, - limit: Long? = null, - sorting: String? = null, + cursor: ForwardCursor? = null, ): T { logger.debug("Sending query") - val responseDecoded = sendQueryRequest(queryAndExtractor, start, limit, sorting) - val cursor = responseDecoded.cast().batchedResponseV1OfValue.cursor - val finalResult = when (cursor.cursor) { + val responseDecoded = sendQueryRequest(queryAndExtractor, cursor) + val decodedCursor = responseDecoded.cast().batchedResponseV1.cursor + val finalResult = when (decodedCursor.cursor) { null -> responseDecoded.let { queryAndExtractor.resultExtractor.extract(it) } else -> { - val resultList = getQueryResultWithCursor(queryAndExtractor, start, limit, sorting, cursor) + val resultList = getQueryResultWithCursor(queryAndExtractor, decodedCursor) resultList.addAll( - responseDecoded.cast() - .batchedResponseV1OfValue.batch.cast().vec, + responseDecoded.cast() + .batchedResponseV1.batch.cast().vec, ) - BatchedResponseOfValue.V1( - BatchedResponseV1OfValue( - Value.Vec(resultList), - ForwardCursor(), - ), + BatchedResponse.V1( + BatchedResponseV1(QueryOutputBox.Vec(resultList), ForwardCursor()), ).let { queryAndExtractor.resultExtractor.extract(it) } } } @@ -260,7 +251,7 @@ open class Iroha2Client( ): Pair, BlockStreamSubscription> = subscribeToBlockStream( from, onBlock = { block -> block }, - cancelIf = { block -> block.extractBlock().height() == BigInteger.valueOf(from + count - 1) }, + cancelIf = { block -> block.extractBlock().height().u64 == BigInteger.valueOf(from + count - 1) }, autoStart = autoStart, ) @@ -331,40 +322,33 @@ open class Iroha2Client( private suspend fun sendQueryRequest( queryAndExtractor: QueryAndExtractor, - start: Long? = null, - limit: Long? = null, - sorting: String? = null, - queryCursor: ForwardCursor? = null, - ): BatchedResponseOfValue { + cursor: ForwardCursor? = null, + ): BatchedResponse { val response: HttpResponse = client.post("${getApiUrl()}$QUERY_ENDPOINT") { - setBody(SignedQuery.encode(queryAndExtractor.query)) - start?.also { parameter("start", it) } - limit?.also { parameter("limit", it) } - sorting?.also { parameter("sort_by_metadata_key", it) } - queryCursor?.queryId?.also { parameter("query_id", it) } - queryCursor?.cursor?.u64?.also { parameter("cursor", it) } + if (cursor != null) { + parameter("query", cursor.query) + parameter("cursor", cursor.cursor?.u64) + } else { + setBody(SignedQuery.encode(queryAndExtractor.query)) + } } - return response.body() - .let { BatchedResponseOfValue.decode(it) } + return response.body().let { BatchedResponse.decode(it) }.cast>() } private suspend fun getQueryResultWithCursor( queryAndExtractor: QueryAndExtractor, - start: Long? = null, - limit: Long? = null, - sorting: String? = null, queryCursor: ForwardCursor? = null, - ): MutableList { - val resultList = mutableListOf() - val responseDecoded = sendQueryRequest(queryAndExtractor, start, limit, sorting, queryCursor) + ): MutableList { + val resultList = mutableListOf() + val responseDecoded = sendQueryRequest(queryAndExtractor, queryCursor) resultList.addAll( - responseDecoded.cast().batchedResponseV1OfValue.batch.cast().vec, + responseDecoded.cast().batchedResponseV1.batch.cast().vec, ) - val cursor = responseDecoded.cast().batchedResponseV1OfValue.cursor + val cursor = responseDecoded.cast().batchedResponseV1.cursor return when (cursor.cursor) { null -> resultList else -> { - resultList.addAll(getQueryResultWithCursor(queryAndExtractor, start, limit, sorting, cursor)) + resultList.addAll(getQueryResultWithCursor(queryAndExtractor, cursor)) resultList } } @@ -400,7 +384,8 @@ open class Iroha2Client( for (i in 1..eventReadMaxAttempts) { try { - val processed = pipelineEventProcess(readMessage(incoming.receive()), hash, hexHash) + val income = readMessage(incoming.receive()) + val processed = pipelineEventProcess(income, hash, hexHash) if (processed != null) { result.complete(processed) break @@ -421,30 +406,31 @@ open class Iroha2Client( hash: ByteArray, hexHash: String, ): ByteArray? { - when (val event = eventPublisherMessage.event) { - is Event.Pipeline -> { - val eventInner = event.pipelineEvent - if (eventInner.entityKind is PipelineEntityKind.Transaction && hash.contentEquals(eventInner.hash.arrayOfU8)) { - when (val status = eventInner.status) { - is PipelineStatus.Committed -> { - logger.debug("Transaction {} committed", hexHash) + when (val event = eventPublisherMessage.eventBox) { + is EventBox.Pipeline -> { + val eventBox = event.pipelineEventBox + if (eventBox is PipelineEventBox.Transaction && hash.contentEquals(eventBox.transactionEvent.hash.hash.arrayOfU8)) { + when (val status = eventBox.transactionEvent.status) { + is TransactionStatus.Approved -> { + logger.debug("Transaction {} approved", hexHash) return hash } - is PipelineStatus.Rejected -> { - val reason = status.pipelineRejectionReason.message() + is TransactionStatus.Rejected -> { + val reason = status.transactionRejectionReason.message() logger.error("Transaction {} was rejected by reason: `{}`", hexHash, reason) throw TransactionRejectedException("Transaction rejected with reason '$reason'") } - is PipelineStatus.Validating -> logger.debug("Transaction {} is validating", hexHash) + is TransactionStatus.Expired -> logger.debug("Transaction {} is expired", hexHash) + is TransactionStatus.Queued -> logger.debug("Transaction {} is queued", hexHash) } } return null } else -> throw WebSocketProtocolException( - "Expected message with type ${Event.Pipeline::class.qualifiedName}, " + + "Expected message with type ${EventBox.Pipeline::class.qualifiedName}, " + "but was ${event::class.qualifiedName}", ) } @@ -453,23 +439,12 @@ open class Iroha2Client( /** * Extract the rejection reason */ - private fun PipelineRejectionReason.message(): String = when (this) { - is PipelineRejectionReason.Block -> when (this.blockRejectionReason) { - is BlockRejectionReason.ConsensusBlockRejection -> "Block was rejected during consensus" - } - - is PipelineRejectionReason.Transaction -> when (val reason = this.transactionRejectionReason) { - is TransactionRejectionReason.InstructionExecution -> { - val details = reason.instructionExecutionFail - "Failed: `${details.reason}` during execution of instruction: ${details.instruction::class.qualifiedName}" - } - - is TransactionRejectionReason.WasmExecution -> reason.wasmExecutionFail.reason - is TransactionRejectionReason.LimitCheck -> reason.transactionLimitError.reason - is TransactionRejectionReason.Expired -> reason.toString() - is TransactionRejectionReason.AccountDoesNotExist -> reason.findError.extract() - is TransactionRejectionReason.Validation -> reason.validationFail.toString() - } + private fun TransactionRejectionReason.message(): String = when (this) { + is TransactionRejectionReason.InstructionExecution -> this.instructionExecutionFail.reason + is TransactionRejectionReason.WasmExecution -> this.wasmExecutionFail.reason + is TransactionRejectionReason.LimitCheck -> this.transactionLimitError.reason + is TransactionRejectionReason.AccountDoesNotExist -> this.findError.extract() + is TransactionRejectionReason.Validation -> this.validationFail.toString() } /** @@ -477,7 +452,9 @@ open class Iroha2Client( */ private fun readMessage(frame: Frame): EventMessage = when (frame) { is Frame.Binary -> { - frame.readBytes().let { EventMessage.decode(it) } + frame.readBytes().let { + EventMessage.decode(it) + } } else -> throw WebSocketProtocolException( @@ -487,9 +464,8 @@ open class Iroha2Client( private fun eventSubscriberMessageOf( hash: ByteArray, - entityKind: PipelineEntityKind = PipelineEntityKind.Transaction(), ) = EventSubscriptionRequest( - Filters.pipeline(entityKind, null, hash), + listOf(Filters.pipelineTransaction(hash)), ) object DurationDeserializer : JsonDeserializer() { diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/BalancingStrategy.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/BalancingStrategy.kt index 2c74be377..ee7748371 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/BalancingStrategy.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/BalancingStrategy.kt @@ -3,8 +3,6 @@ package jp.co.soramitsu.iroha2.client.balancing import java.net.URL interface BalancingStrategy { - fun getTelemetryUrl(): URL - fun getApiUrl(): URL fun getPeerUrl(): URL diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/RoundRobinStrategy.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/RoundRobinStrategy.kt index 38fae08b6..323a27e66 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/RoundRobinStrategy.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/RoundRobinStrategy.kt @@ -10,8 +10,6 @@ open class RoundRobinStrategy(private val urls: List) : BalancingStra private var lastRequestedPeerIdx: Int? = null - override fun getTelemetryUrl(): URL = getUrls().telemetryUrl - override fun getApiUrl(): URL = getUrls().apiUrl override fun getPeerUrl(): URL = getUrls().peerUrl diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/WithoutBalancingStrategy.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/WithoutBalancingStrategy.kt index a07cf9272..4edb430d0 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/WithoutBalancingStrategy.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/client/balancing/WithoutBalancingStrategy.kt @@ -4,8 +4,6 @@ import jp.co.soramitsu.iroha2.model.IrohaUrls import java.net.URL open class WithoutBalancingStrategy(private val urls: List) : BalancingStrategy { - override fun getTelemetryUrl(): URL = urls.first().telemetryUrl - override fun getApiUrl(): URL = urls.first().apiUrl override fun getPeerUrl(): URL = urls.first().peerUrl 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 31054f26d..314143344 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 @@ -1,6 +1,7 @@ package jp.co.soramitsu.iroha2.client.blockstream import io.ktor.client.plugins.websocket.webSocket +import io.ktor.http.HttpMethod import io.ktor.websocket.close import io.ktor.websocket.readBytes import jp.co.soramitsu.iroha2.IrohaSdkException @@ -105,11 +106,11 @@ open class BlockStreamSubscription private constructor( BigInteger.valueOf(context.from), ), ) - context.client.webSocket( host = context.apiUrl.host, port = context.apiUrl.port, path = Iroha2Client.WS_ENDPOINT_BLOCK_STREAM, + method = HttpMethod.Get, ) { try { logger.debug("WebSocket opened") @@ -124,26 +125,23 @@ open class BlockStreamSubscription private constructor( logger.debug("Executing {} action", id) val result = storage.onBlock(block) logger.debug("{} action result: {}", id, result) + val channel = storage.channel.value when (channel.isClosedForSend) { - true -> logger.warn( - "Block stream channel#{} is already closed, not sending the action result", - id, - ) - + true -> logger.warn("Block stream channel#{} is already closed, not sending the action result", id) false -> channel.send(result) } if (storage.cancelIf?.let { it(block) } == true) { // idempotent channel.close() idsToRemove.add(id) - logger.debug("Block stream channel#{} is closed and scheduled for removal", id) + logger.info("Block stream channel#{} is closed and scheduled for removal", id) } } if (idsToRemove.isNotEmpty()) { idsToRemove.forEach { source.remove(it) - logger.debug("Block stream channel#{} is removed", it) + logger.info("Block stream channel#{} is removed", it) } idsToRemove.clear() } diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/model/IrohaUrls.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/model/IrohaUrls.kt index e19b63001..1f89cd0bc 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/model/IrohaUrls.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/model/IrohaUrls.kt @@ -2,10 +2,9 @@ package jp.co.soramitsu.iroha2.model import java.net.URL -data class IrohaUrls(val apiUrl: URL, val telemetryUrl: URL, val peerUrl: URL) { +data class IrohaUrls(val apiUrl: URL, val peerUrl: URL) { constructor( apiUrl: String, - telemetryUrl: String, peerUrl: String, - ) : this(URL(apiUrl), URL(telemetryUrl), URL(peerUrl)) + ) : this(URL(apiUrl), URL(peerUrl)) } 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 0e2122bea..4535ee41f 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 @@ -1,6 +1,5 @@ package jp.co.soramitsu.iroha2.query -import jp.co.soramitsu.iroha2.evaluatesTo import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId @@ -8,7 +7,6 @@ import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.FindAccountById import jp.co.soramitsu.iroha2.generated.FindAccountKeyValueByIdAndKey import jp.co.soramitsu.iroha2.generated.FindAccountsByDomainId -import jp.co.soramitsu.iroha2.generated.FindAccountsByName import jp.co.soramitsu.iroha2.generated.FindAccountsWithAsset import jp.co.soramitsu.iroha2.generated.FindAllAccounts import jp.co.soramitsu.iroha2.generated.FindAllActiveTriggerIds @@ -35,8 +33,8 @@ import jp.co.soramitsu.iroha2.generated.FindAssetsByName import jp.co.soramitsu.iroha2.generated.FindBlockHeaderByHash import jp.co.soramitsu.iroha2.generated.FindDomainById import jp.co.soramitsu.iroha2.generated.FindDomainKeyValueByIdAndKey -import jp.co.soramitsu.iroha2.generated.FindPermissionTokenSchema -import jp.co.soramitsu.iroha2.generated.FindPermissionTokensByAccountId +import jp.co.soramitsu.iroha2.generated.FindExecutorDataModel +import jp.co.soramitsu.iroha2.generated.FindPermissionsByAccountId import jp.co.soramitsu.iroha2.generated.FindRoleByRoleId import jp.co.soramitsu.iroha2.generated.FindRolesByAccountId import jp.co.soramitsu.iroha2.generated.FindTotalAssetQuantityByAssetDefinitionId @@ -44,13 +42,13 @@ import jp.co.soramitsu.iroha2.generated.FindTransactionByHash import jp.co.soramitsu.iroha2.generated.FindTransactionsByAccountId import jp.co.soramitsu.iroha2.generated.FindTriggerById import jp.co.soramitsu.iroha2.generated.FindTriggerKeyValueByIdAndKey -import jp.co.soramitsu.iroha2.generated.FindTriggersByDomainId +import jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityDomainId +import jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityId import jp.co.soramitsu.iroha2.generated.Hash 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 @@ -67,32 +65,27 @@ object Queries { /** * Return the full account information corresponding to the given [AccountId] */ - fun findAccountById(accountId: AccountId) = QueryBox.FindAccountById(FindAccountById(accountId.evaluatesTo())) + fun findAccountById(accountId: AccountId) = QueryBox.FindAccountById(FindAccountById(accountId)) /** * Return the value keyed by the provided [Name] for the given [AccountId] */ fun findAccountKeyValueByIdAndKey(accountId: AccountId, key: Name) = QueryBox.FindAccountKeyValueByIdAndKey( - FindAccountKeyValueByIdAndKey(accountId.evaluatesTo(), key.evaluatesTo()), + FindAccountKeyValueByIdAndKey(accountId, key), ) - /** - * Return all the accounts that have the given [Name] - */ - fun findAccountsByName(name: Name) = QueryBox.FindAccountsByName(FindAccountsByName(name.evaluatesTo())) - /** * Return all the accounts that belong to a specific domain [DomainId] */ fun findAccountsByDomainId(domainId: DomainId) = QueryBox.FindAccountsByDomainId( - FindAccountsByDomainId(domainId.evaluatesTo()), + FindAccountsByDomainId(domainId), ) /** * Return all the accounts that belong to a specific asset definition [AssetDefinitionId] */ fun findAccountsWithAsset(definitionId: AssetDefinitionId) = QueryBox.FindAccountsWithAsset( - FindAccountsWithAsset(definitionId.evaluatesTo()), + FindAccountsWithAsset(definitionId), ) /** @@ -103,32 +96,32 @@ object Queries { /** * Return the aggregated data about the [AssetId] usage across the network */ - fun findAssetById(assetId: AssetId) = QueryBox.FindAssetById(FindAssetById(assetId.evaluatesTo())) + fun findAssetById(assetId: AssetId) = QueryBox.FindAssetById(FindAssetById(assetId)) /** * Return all the assets that are registered in the given domain [DomainId] */ fun findAssetsByDomainId(domainId: DomainId) = QueryBox.FindAssetsByDomainId( - FindAssetsByDomainId(domainId.evaluatesTo()), + FindAssetsByDomainId(domainId), ) /** * Search the network for all assets that match the given [Name] */ - fun findAssetsByName(name: Name) = QueryBox.FindAssetsByName(FindAssetsByName(name.evaluatesTo())) + fun findAssetsByName(name: Name) = QueryBox.FindAssetsByName(FindAssetsByName(name)) /** * Return all the assets that belong to a given [AccountId] */ fun findAssetsByAccountId(accountId: AccountId) = QueryBox.FindAssetsByAccountId( - FindAssetsByAccountId(accountId.evaluatesTo()), + FindAssetsByAccountId(accountId), ) /** * Search for all the assets that have the given [AssetDefinitionId] */ fun findAssetsByAssetDefinitionId(assetDefinition: AssetDefinitionId) = QueryBox.FindAssetsByAssetDefinitionId( - FindAssetsByAssetDefinitionId(assetDefinition.evaluatesTo()), + FindAssetsByAssetDefinitionId(assetDefinition), ) /** @@ -139,8 +132,8 @@ object Queries { assetDefinition: AssetDefinitionId, ) = QueryBox.FindAssetsByDomainIdAndAssetDefinitionId( FindAssetsByDomainIdAndAssetDefinitionId( - domainId.evaluatesTo(), - assetDefinition.evaluatesTo(), + domainId, + assetDefinition, ), ) @@ -153,7 +146,7 @@ object Queries { * Return the asset quantity for the given asset with [AssetId] */ fun findAssetQuantityById(assetId: AssetId) = QueryBox.FindAssetQuantityById( - FindAssetQuantityById(assetId.evaluatesTo()), + FindAssetQuantityById(assetId), ) /** @@ -162,14 +155,14 @@ object Queries { fun findTotalAssetQuantityByAssetDefinitionId( definitionId: AssetDefinitionId, ) = QueryBox.FindTotalAssetQuantityByAssetDefinitionId( - FindTotalAssetQuantityByAssetDefinitionId(definitionId.evaluatesTo()), + FindTotalAssetQuantityByAssetDefinitionId(definitionId), ) /** * Return the value keyed by the given [Name] in the metadata of the asset corresponding to the given [AssetId] */ fun findAssetKeyValueByIdAndKey(assetId: AssetId, key: Name) = QueryBox.FindAssetKeyValueByIdAndKey( - FindAssetKeyValueByIdAndKey(assetId.evaluatesTo(), key.evaluatesTo()), + FindAssetKeyValueByIdAndKey(assetId, key), ) /** @@ -181,8 +174,8 @@ object Queries { key: Name, ) = QueryBox.FindAssetDefinitionKeyValueByIdAndKey( FindAssetDefinitionKeyValueByIdAndKey( - assetDefinition.evaluatesTo(), - key.evaluatesTo(), + assetDefinition, + key, ), ) @@ -190,7 +183,7 @@ object Queries { * Return the asset definition corresponding to the given [AssetDefinitionId] */ fun findAssetDefinitionById(definitionId: AssetDefinitionId) = QueryBox.FindAssetDefinitionById( - FindAssetDefinitionById(definitionId.evaluatesTo()), + FindAssetDefinitionById(definitionId), ) /** @@ -201,7 +194,7 @@ object Queries { /** * Return the domain corresponding to the given [DomainId] */ - fun findDomainById(domainId: DomainId) = QueryBox.FindDomainById(FindDomainById(domainId.evaluatesTo())) + fun findDomainById(domainId: DomainId) = QueryBox.FindDomainById(FindDomainById(domainId)) /** * Return all known peers identified by their key and accompanied by the address of their API endpoint @@ -212,35 +205,35 @@ object Queries { * Return the full set of transactions that an account with [AccountId] has submitted throughout the existence of the blockchain */ fun findTransactionsByAccountId(accountId: AccountId) = QueryBox.FindTransactionsByAccountId( - FindTransactionsByAccountId(accountId.evaluatesTo()), + FindTransactionsByAccountId(accountId), ) /** * Return all the permission tokens granted to the specified [AccountId] */ - fun findPermissionTokensByAccountId(accountId: AccountId) = QueryBox.FindPermissionTokensByAccountId( - FindPermissionTokensByAccountId(accountId.evaluatesTo()), + fun findPermissionsByAccountId(accountId: AccountId) = QueryBox.FindPermissionsByAccountId( + FindPermissionsByAccountId(accountId), ) /** - * Return permission token ids schema + * Return executor data model */ - fun findPermissionTokenIdsSchema() = QueryBox.FindPermissionTokenSchema( - FindPermissionTokenSchema(), + fun findExecutorDataModel() = QueryBox.FindExecutorDataModel( + FindExecutorDataModel(), ) /** * Return the transaction by [Hash] */ fun findTransactionByHash(hash: Hash) = QueryBox.FindTransactionByHash( - FindTransactionByHash(HashOf(hash).evaluatesTo()), + FindTransactionByHash(HashOf(hash)), ) /** * Return all the role IDs that are attached to the given [AccountId] */ fun findRolesByAccountId(accountId: AccountId) = QueryBox.FindRolesByAccountId( - FindRolesByAccountId(accountId.evaluatesTo()), + FindRolesByAccountId(accountId), ) /** @@ -251,7 +244,7 @@ object Queries { /** * Return the role by [RoleId] */ - fun findRoleByRoleId(roleId: RoleId) = QueryBox.FindRoleByRoleId(FindRoleByRoleId(roleId.evaluatesTo())) + fun findRoleByRoleId(roleId: RoleId) = QueryBox.FindRoleByRoleId(FindRoleByRoleId(roleId)) /** * Return all role IDs @@ -262,30 +255,39 @@ object Queries { * Return the value keyed by the given [Name] in the domain corresponding to the given [DomainId] */ fun findDomainKeyValueByIdAndKey(id: DomainId, key: Name) = QueryBox.FindDomainKeyValueByIdAndKey( - FindDomainKeyValueByIdAndKey(id.evaluatesTo(), key.evaluatesTo()), + FindDomainKeyValueByIdAndKey(id, key), ) /** * Return the value corresponding to the given key [Name] in the metadata of the trigger with the given [TriggerId] */ fun findTriggerKeyValueByIdAndKey(id: TriggerId, key: Name) = QueryBox.FindTriggerKeyValueByIdAndKey( - FindTriggerKeyValueByIdAndKey(id.evaluatesTo(), key.evaluatesTo()), + FindTriggerKeyValueByIdAndKey(id, key), ) /** * Return the trigger with the given [TriggerId] */ - fun findTriggerById(id: TriggerId) = QueryBox.FindTriggerById(FindTriggerById(id.evaluatesTo())) + fun findTriggerById(id: TriggerId) = QueryBox.FindTriggerById(FindTriggerById(id)) /** - * Return all the triggers that are attached to the given [DomainId] + * Return all currently active triggers, that have not expired at the time of the query */ - fun findTriggersByDomainId(id: DomainId) = QueryBox.FindTriggersByDomainId(FindTriggersByDomainId(id.evaluatesTo())) + fun findAllActiveTriggerIds() = QueryBox.FindAllActiveTriggerIds(FindAllActiveTriggerIds()) /** - * Return all currently active triggers, that is, triggers that have not expired at the time of the query + * Return a trigger with the given [AccountId] */ - fun findAllActiveTriggerIds() = QueryBox.FindAllActiveTriggerIds(FindAllActiveTriggerIds()) + fun findTriggersByAuthorityId(id: AccountId) = QueryBox.FindTriggersByAuthorityId( + FindTriggersByAuthorityId(id), + ) + + /** + * Return all currently triggers with the given [DomainId] + */ + fun findTriggersByAuthorityDomainId(domainId: DomainId) = QueryBox.FindTriggersByAuthorityDomainId( + FindTriggersByAuthorityDomainId(domainId), + ) /** * Return all blocks @@ -301,7 +303,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)), ) /** 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 49c6d9915..a3a471647 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 @@ -11,82 +11,102 @@ import jp.co.soramitsu.iroha2.BlockHeadersExtractor import jp.co.soramitsu.iroha2.BlocksValueExtractor import jp.co.soramitsu.iroha2.DomainExtractor import jp.co.soramitsu.iroha2.DomainsExtractor +import jp.co.soramitsu.iroha2.ExecutorDataModelExtractor +import jp.co.soramitsu.iroha2.NumericExtractor import jp.co.soramitsu.iroha2.PeersExtractor -import jp.co.soramitsu.iroha2.PermissionTokenSchemaExtractor import jp.co.soramitsu.iroha2.PermissionTokensExtractor import jp.co.soramitsu.iroha2.ResultExtractor import jp.co.soramitsu.iroha2.RoleExtractor import jp.co.soramitsu.iroha2.RoleIdsExtractor import jp.co.soramitsu.iroha2.RolesExtractor +import jp.co.soramitsu.iroha2.StringExtractor import jp.co.soramitsu.iroha2.TransactionValueExtractor import jp.co.soramitsu.iroha2.TransactionValuesExtractor import jp.co.soramitsu.iroha2.TriggerBoxExtractor import jp.co.soramitsu.iroha2.TriggerBoxesExtractor import jp.co.soramitsu.iroha2.TriggerIdsExtractor -import jp.co.soramitsu.iroha2.U32Extractor -import jp.co.soramitsu.iroha2.ValueExtractor import jp.co.soramitsu.iroha2.asName import jp.co.soramitsu.iroha2.asSignatureOf import jp.co.soramitsu.iroha2.fromHex import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.ClientQueryPayload import jp.co.soramitsu.iroha2.generated.DomainId +import jp.co.soramitsu.iroha2.generated.FetchSize import jp.co.soramitsu.iroha2.generated.GenericPredicateBox import jp.co.soramitsu.iroha2.generated.Hash import jp.co.soramitsu.iroha2.generated.Name +import jp.co.soramitsu.iroha2.generated.NonZeroOfu32 +import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 +import jp.co.soramitsu.iroha2.generated.Pagination +import jp.co.soramitsu.iroha2.generated.PublicKey import jp.co.soramitsu.iroha2.generated.QueryBox -import jp.co.soramitsu.iroha2.generated.QueryPayload +import jp.co.soramitsu.iroha2.generated.QueryOutputPredicate +import jp.co.soramitsu.iroha2.generated.QuerySignature 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.Sorting import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.ValuePredicate import jp.co.soramitsu.iroha2.hash import jp.co.soramitsu.iroha2.sign import jp.co.soramitsu.iroha2.toIrohaHash -import jp.co.soramitsu.iroha2.toIrohaPublicKey import java.math.BigInteger import java.security.KeyPair -import java.time.Instant class QueryBuilder( private val query: QueryBox, private val resultExtractor: ResultExtractor, - private val queryFilter: GenericPredicateBox? = null, + private val queryFilter: GenericPredicateBox? = null, ) { - private var accountId: AccountId? = null - private var creationTimeMillis: BigInteger? = null + private var sorting: Sorting? = null + private var pagination: Pagination? = null + private var fetchSize: FetchSize? = null fun account(accountId: AccountId) = this.apply { this.accountId = accountId } - fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(domainId, accountName)) + fun account(signatory: PublicKey, domainId: DomainId) = this.account(AccountId(domainId, signatory)) - fun creationTime(creationTimeMillis: BigInteger) = this.apply { this.creationTimeMillis = creationTimeMillis } + fun sorting(key: String) = this.apply { + this.sorting = Sorting(key.asName()) + } - fun creationTime(creationTimeMillis: Instant) = this.apply { this.creationTime(creationTimeMillis.toEpochMilli()) } + fun sorting(key: Name) = this.apply { + this.sorting = Sorting(key) + } - fun creationTime(creationTimeMillis: Long) = - this.apply { this.creationTime(BigInteger.valueOf(creationTimeMillis)) } + fun pagination(limit: Long? = null, start: BigInteger? = null) = this.apply { + this.pagination = Pagination(limit?.let { NonZeroOfu32(limit) }, start?.let { NonZeroOfu64(start) }) + } - fun buildSigned(keyPair: KeyPair): QueryAndExtractor { - val filter = queryFilter ?: GenericPredicateBox.Raw(ValuePredicate.Pass()) - val payload = QueryPayload(checkNotNull(accountId) { "Account Id of the sender is mandatory" }, query, filter) - val encodedPayload = QueryPayload.encode(payload) - val signature = Signature(keyPair.public.toIrohaPublicKey(), keyPair.private.sign(encodedPayload)) + fun fetchSize(value: Long) = this.apply { + this.fetchSize = FetchSize(NonZeroOfu32(value)) + } - val query = SignedQuery.V1(SignedQueryV1(signature.asSignatureOf(), payload)) + fun buildSigned(keyPair: KeyPair): QueryAndExtractor { + val filter = queryFilter ?: GenericPredicateBox.Raw(QueryOutputPredicate.Pass()) + val payload = ClientQueryPayload( + checkNotNull(accountId) { "Account ID of the sender is mandatory" }, + query, + filter, + sorting ?: Sorting(null), + this.pagination ?: Pagination(null, null), + this.fetchSize ?: FetchSize(null), + ) + val encodedPayload = ClientQueryPayload.encode(payload) + val signature = QuerySignature(Signature(keyPair.private.sign(encodedPayload)).asSignatureOf()) + + val query = SignedQuery.V1(SignedQueryV1(signature, payload)) return QueryAndExtractor(query, resultExtractor) } - private fun fallbackCreationTime() = BigInteger.valueOf(System.currentTimeMillis()) - companion object { @JvmStatic @JvmOverloads - fun findAllAccounts(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllAccounts(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllAccounts(), AccountsExtractor, queryFilter, @@ -95,7 +115,7 @@ class QueryBuilder( @JvmStatic fun findAccountKeyValueByIdAndKey(accountId: AccountId, key: Name) = QueryBuilder( Queries.findAccountKeyValueByIdAndKey(accountId, key), - ValueExtractor, + StringExtractor, ) @JvmStatic @@ -104,34 +124,23 @@ class QueryBuilder( key: String, ) = findAccountKeyValueByIdAndKey(accountId, key.asName()) - @JvmStatic - @JvmOverloads - fun findAccountsByName( - name: Name, - queryFilter: GenericPredicateBox? = null, - ) = QueryBuilder( - Queries.findAccountsByName(name), - AccountsExtractor, - queryFilter, - ) - @JvmStatic @JvmOverloads fun findAccountsByDomainId( domainId: DomainId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder(Queries.findAccountsByDomainId(domainId), AccountsExtractor, queryFilter) @JvmStatic @JvmOverloads fun findAccountsWithAsset( definitionId: AssetDefinitionId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder(Queries.findAccountsWithAsset(definitionId), AccountsExtractor, queryFilter) @JvmStatic @JvmOverloads - fun findAllAssets(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllAssets(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllAssets(), AssetsExtractor, queryFilter, @@ -140,7 +149,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads fun findAllAssetsDefinitions( - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAllAssetsDefinitions(), AssetDefinitionsExtractor, @@ -151,7 +160,7 @@ class QueryBuilder( @JvmOverloads fun findAssetsByName( name: Name, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAssetsByName(name), AssetsExtractor, @@ -162,7 +171,7 @@ class QueryBuilder( @JvmOverloads fun findAssetsByAccountId( accountId: AccountId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAssetsByAccountId(accountId), AssetsExtractor, @@ -179,7 +188,7 @@ class QueryBuilder( @JvmOverloads fun findAssetsByDomainId( domainId: DomainId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAssetsByDomainId(domainId), AssetsExtractor, @@ -196,7 +205,7 @@ class QueryBuilder( @JvmOverloads fun findAllAssetsDefinitions( assetDefinition: AssetDefinitionId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAssetsByAssetDefinitionId(assetDefinition), AssetDefinitionsExtractor, @@ -208,7 +217,7 @@ class QueryBuilder( fun findAssetsByDomainIdAndAssetDefinitionId( domainId: DomainId, assetDefinition: AssetDefinitionId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findAssetsByDomainIdAndAssetDefinitionId(domainId, assetDefinition), AssetsExtractor, @@ -218,19 +227,19 @@ class QueryBuilder( @JvmStatic fun findAssetQuantityById(assetId: AssetId) = QueryBuilder( Queries.findAssetQuantityById(assetId), - U32Extractor, + NumericExtractor, ) @JvmStatic fun findTotalAssetQuantityByAssetDefinitionId(definitionId: AssetDefinitionId) = QueryBuilder( Queries.findTotalAssetQuantityByAssetDefinitionId(definitionId), - U32Extractor, + NumericExtractor, ) @JvmStatic fun findAssetKeyValueByIdAndKey(assetId: AssetId, key: Name) = QueryBuilder( Queries.findAssetKeyValueByIdAndKey(assetId, key), - ValueExtractor, + StringExtractor, ) @JvmStatic @@ -242,7 +251,7 @@ class QueryBuilder( @JvmStatic fun findAssetDefinitionKeyValueByIdAndKey(id: AssetDefinitionId, key: Name) = QueryBuilder( Queries.findAssetDefinitionKeyValueByIdAndKey(id, key), - ValueExtractor, + StringExtractor, ) @JvmStatic @@ -257,13 +266,13 @@ class QueryBuilder( @JvmStatic fun findDomainKeyValueByIdAndKey(id: DomainId, key: Name) = QueryBuilder( Queries.findDomainKeyValueByIdAndKey(id, key), - ValueExtractor, + StringExtractor, ) @JvmStatic @JvmOverloads fun findAllDomains( - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder(Queries.findAllDomains(), DomainsExtractor, queryFilter) @JvmStatic @@ -271,13 +280,13 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findAllPeers(queryFilter: GenericPredicateBox? = null) = + fun findAllPeers(queryFilter: GenericPredicateBox? = null) = QueryBuilder(Queries.findAllPeers(), PeersExtractor, queryFilter) @JvmStatic fun findTransactionsByAccountId( accountId: AccountId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( Queries.findTransactionsByAccountId(accountId), TransactionValuesExtractor, @@ -286,27 +295,27 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findPermissionTokensByAccountId( + fun findPermissionsByAccountId( accountId: AccountId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( - Queries.findPermissionTokensByAccountId(accountId), + Queries.findPermissionsByAccountId(accountId), PermissionTokensExtractor, queryFilter, ) @JvmStatic - fun findPermissionTokenIdsSchema( - queryFilter: GenericPredicateBox? = null, + fun findExecutorDataModel( + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( - Queries.findPermissionTokenIdsSchema(), - PermissionTokenSchemaExtractor, + Queries.findExecutorDataModel(), + ExecutorDataModelExtractor, queryFilter, ) @JvmStatic @JvmOverloads - fun findRolesByAccountId(accountId: AccountId, queryFilter: GenericPredicateBox? = null) = + fun findRolesByAccountId(accountId: AccountId, queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findRolesByAccountId(accountId), RoleIdsExtractor, @@ -315,7 +324,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findAllRoleIds(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllRoleIds(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllRoleIds(), RoleIdsExtractor, queryFilter, @@ -323,7 +332,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findAllRoles(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllRoles(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllRoles(), RolesExtractor, queryFilter, @@ -331,7 +340,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findRoleByRoleId(roleId: RoleId, queryFilter: GenericPredicateBox? = null) = + fun findRoleByRoleId(roleId: RoleId, queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findRoleByRoleId(roleId), RoleExtractor, @@ -351,7 +360,7 @@ class QueryBuilder( fun findTransactionByHash(hex: String) = findTransactionByHash(hex.fromHex().hash().toIrohaHash()) @JvmStatic - fun findAllTransactions(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllTransactions(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllTransactions(), TransactionValuesExtractor, queryFilter, @@ -359,7 +368,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findAllBlocks(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllBlocks(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllBlocks(), BlocksValueExtractor, queryFilter, @@ -367,7 +376,7 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findAllBlockHeaders(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllBlockHeaders(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllBlockHeaders(), BlockHeadersExtractor, queryFilter, @@ -394,12 +403,12 @@ class QueryBuilder( @JvmStatic fun findTriggerKeyValueByIdAndKey(id: TriggerId, key: Name) = QueryBuilder( Queries.findTriggerKeyValueByIdAndKey(id, key), - ValueExtractor, + StringExtractor, ) @JvmStatic @JvmOverloads - fun findAllActiveTriggerIds(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllActiveTriggerIds(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllActiveTriggerIds(), TriggerIdsExtractor, queryFilter, @@ -407,20 +416,31 @@ class QueryBuilder( @JvmStatic @JvmOverloads - fun findTriggersByDomainId( + fun findTriggersByAuthorityId( + id: AccountId, + queryFilter: GenericPredicateBox? = null, + ) = QueryBuilder( + Queries.findTriggersByAuthorityId(id), + TriggerBoxExtractor, + queryFilter, + ) + + @JvmStatic + @JvmOverloads + fun findTriggersByAuthorityDomainId( domainId: DomainId, - queryFilter: GenericPredicateBox? = null, + queryFilter: GenericPredicateBox? = null, ) = QueryBuilder( - Queries.findTriggersByDomainId(domainId), + Queries.findTriggersByAuthorityDomainId(domainId), TriggerBoxesExtractor, queryFilter, ) @JvmStatic @JvmOverloads - fun findAllParameters(queryFilter: GenericPredicateBox? = null) = QueryBuilder( + fun findAllParameters(queryFilter: GenericPredicateBox? = null) = QueryBuilder( Queries.findAllParameters(), - ValueExtractor, + StringExtractor, queryFilter, ) } diff --git a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Filters.kt b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Filters.kt index 9be5c99e0..83c4bc129 100644 --- a/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Filters.kt +++ b/modules/client/src/main/kotlin/jp/co/soramitsu/iroha2/transaction/Filters.kt @@ -1,66 +1,35 @@ package jp.co.soramitsu.iroha2.transaction +import jp.co.soramitsu.iroha2.asHashOf import jp.co.soramitsu.iroha2.generated.AccountEventFilter -import jp.co.soramitsu.iroha2.generated.AccountFilter import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter -import jp.co.soramitsu.iroha2.generated.AssetDefinitionFilter +import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetEventFilter -import jp.co.soramitsu.iroha2.generated.AssetFilter -import jp.co.soramitsu.iroha2.generated.DataEntityFilter +import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.DataEventFilter import jp.co.soramitsu.iroha2.generated.DomainEventFilter -import jp.co.soramitsu.iroha2.generated.DomainFilter -import jp.co.soramitsu.iroha2.generated.Duration +import jp.co.soramitsu.iroha2.generated.DomainId +import jp.co.soramitsu.iroha2.generated.EventFilterBox import jp.co.soramitsu.iroha2.generated.ExecuteTriggerEventFilter import jp.co.soramitsu.iroha2.generated.ExecutionTime -import jp.co.soramitsu.iroha2.generated.FilterBox -import jp.co.soramitsu.iroha2.generated.FilterOptOfAccountEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfAccountFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfAssetEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfAssetFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfDataEntityFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfDomainEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfDomainFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAccountEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetDefinitionEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfDomainEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfPeerEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfRoleEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfTriggerEvent -import jp.co.soramitsu.iroha2.generated.FilterOptOfPeerEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfPeerFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfRoleEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfRoleFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerEventFilter -import jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerFilter import jp.co.soramitsu.iroha2.generated.GenericPredicateBox import jp.co.soramitsu.iroha2.generated.NonTrivial -import jp.co.soramitsu.iroha2.generated.OriginFilterOfAccountEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfAssetDefinitionEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfAssetEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfDomainEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfPeerEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfRoleEvent -import jp.co.soramitsu.iroha2.generated.OriginFilterOfTriggerEvent +import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 import jp.co.soramitsu.iroha2.generated.PeerEventFilter -import jp.co.soramitsu.iroha2.generated.PeerFilter -import jp.co.soramitsu.iroha2.generated.PipelineEntityKind -import jp.co.soramitsu.iroha2.generated.PipelineEventFilter -import jp.co.soramitsu.iroha2.generated.PipelineStatusKind +import jp.co.soramitsu.iroha2.generated.PeerId +import jp.co.soramitsu.iroha2.generated.PipelineEventFilterBox +import jp.co.soramitsu.iroha2.generated.QueryOutputPredicate import jp.co.soramitsu.iroha2.generated.RoleEventFilter -import jp.co.soramitsu.iroha2.generated.RoleFilter +import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.Schedule import jp.co.soramitsu.iroha2.generated.StringPredicate import jp.co.soramitsu.iroha2.generated.TimeEventFilter +import jp.co.soramitsu.iroha2.generated.TransactionEventFilter +import jp.co.soramitsu.iroha2.generated.TransactionStatus import jp.co.soramitsu.iroha2.generated.TriggerEventFilter -import jp.co.soramitsu.iroha2.generated.TriggerFilter import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox -import jp.co.soramitsu.iroha2.generated.ValuePredicate -import jp.co.soramitsu.iroha2.toIrohaHash +import java.math.BigInteger /** * Filters are used to filter out events @@ -71,15 +40,14 @@ object Filters { /** * Create a data filter */ - fun data(entityFilter: DataEntityFilter? = null) = TriggeringFilterBox.Data( - entityFilter?.let { FilterOptOfDataEntityFilter.BySome(it) } - ?: FilterOptOfDataEntityFilter.AcceptAll(), + fun data(entityFilter: DataEventFilter) = EventFilterBox.Data( + entityFilter, ) /** * Create a [time based event filter][TimeEventFilter] */ - fun time(eventFilter: TimeEventFilter) = FilterBox.Time(eventFilter) + fun time(eventFilter: TimeEventFilter) = EventFilterBox.Time(eventFilter) /** * Execute a given trigger based on a specified [authority] @@ -87,26 +55,27 @@ object Filters { fun executeTrigger( triggerId: TriggerId, authority: AccountId, - ) = TriggeringFilterBox.ExecuteTrigger( + ) = EventFilterBox.ExecuteTrigger( ExecuteTriggerEventFilter(triggerId, authority), ) /** - * Create an event filter that matches events based on associated [entityKind], [statusKind], [hash], + * Create an event filter that matches events based on associated [hash], [blockHeight], [status], * or any combination of these. * - * @see jp.co.soramitsu.iroha2.generated.pipeline.StatusKind - * @see jp.co.soramitsu.iroha2.generated.pipeline.EntityKind + * @see jp.co.soramitsu.iroha2.generated.TransactionStatus */ - fun pipeline( - entityKind: PipelineEntityKind? = null, - statusKind: PipelineStatusKind? = null, + fun pipelineTransaction( hash: ByteArray? = null, - ) = FilterBox.Pipeline( - PipelineEventFilter( - entityKind, - statusKind, - hash?.toIrohaHash(), + blockHeight: BigInteger? = null, + status: TransactionStatus? = null, + ) = EventFilterBox.Pipeline( + PipelineEventFilterBox.Transaction( + TransactionEventFilter( + hash?.asHashOf(), + blockHeight?.let { NonZeroOfu64(it) }, + status, + ), ), ) } @@ -122,161 +91,77 @@ object EntityFilters { * its [id][OriginFilterOfAssetDefinitionEvent] or [event type][AssetDefinitionEventFilter] */ fun byAssetDefinition( - originFilter: OriginFilterOfAssetDefinitionEvent? = null, - eventFilter: AssetDefinitionEventFilter? = null, - ) = DataEntityFilter.ByAssetDefinition( - FilterOptOfAssetDefinitionFilter.BySome( - AssetDefinitionFilter( - originFilter?.let { FilterOptOfOriginFilterOfAssetDefinitionEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfAssetDefinitionEvent.AcceptAll(), - eventFilter?.let { FilterOptOfAssetDefinitionEventFilter.BySome(it) } - ?: FilterOptOfAssetDefinitionEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + definitionId: AssetDefinitionId? = null, + ) = DataEventFilter.AssetDefinition( + AssetDefinitionEventFilter(definitionId, eventSet), ) - /** - * Match events associated with asset definition - */ - fun byAssetDefinition() = DataEntityFilter.ByAssetDefinition(FilterOptOfAssetDefinitionFilter.AcceptAll()) - /** * Match events associated with accounts and apply another filter referenced by * its [id][OriginFilterOfAccountEvent] or [event type][AccountEventFilter] */ fun byAccount( - idFilter: OriginFilterOfAccountEvent? = null, - eventFilter: AccountEventFilter? = null, - ) = DataEntityFilter.ByAccount( - FilterOptOfAccountFilter.BySome( - AccountFilter( - idFilter?.let { FilterOptOfOriginFilterOfAccountEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfAccountEvent.AcceptAll(), - eventFilter?.let { FilterOptOfAccountEventFilter.BySome(it) } - ?: FilterOptOfAccountEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + accountId: AccountId? = null, + ) = DataEventFilter.Account( + AccountEventFilter(accountId, eventSet), ) - /** - * Match events associated with accounts - */ - fun byAccount() = DataEntityFilter.ByAccount(FilterOptOfAccountFilter.AcceptAll()) - /** * Match events associated with assets and apply another filter referenced by * its [id][FilterOptOfOriginFilterOfAssetEvent] or [event type][AssetEventFilter] */ fun byAsset( - assetFilter: OriginFilterOfAssetEvent? = null, - eventFilter: AssetEventFilter? = null, - ) = DataEntityFilter.ByAsset( - FilterOptOfAssetFilter.BySome( - AssetFilter( - assetFilter?.let { FilterOptOfOriginFilterOfAssetEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfAssetEvent.AcceptAll(), - eventFilter?.let { FilterOptOfAssetEventFilter.BySome(it) } - ?: FilterOptOfAssetEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + assetId: AssetId? = null, + ) = DataEventFilter.Asset( + AssetEventFilter(assetId, eventSet), ) - /** - * Match events associated with assets - */ - fun byAsset() = DataEntityFilter.ByAsset(FilterOptOfAssetFilter.AcceptAll()) - /** * Match events associated with triggers and apply another filter referenced by * its [id][FilterOptOfOriginFilterOfTriggerEvent] or [event type][TriggerEventFilter] */ fun byTrigger( - idFilter: OriginFilterOfTriggerEvent? = null, - eventFilter: TriggerEventFilter? = null, - ) = DataEntityFilter.ByTrigger( - FilterOptOfTriggerFilter.BySome( - TriggerFilter( - idFilter?.let { FilterOptOfOriginFilterOfTriggerEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfTriggerEvent.AcceptAll(), - eventFilter?.let { FilterOptOfTriggerEventFilter.BySome(it) } - ?: FilterOptOfTriggerEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + triggerId: TriggerId? = null, + ) = DataEventFilter.Trigger( + TriggerEventFilter(triggerId, eventSet), ) - /** - * Match events associated with triggers - */ - fun byTrigger() = DataEntityFilter.ByTrigger(FilterOptOfTriggerFilter.AcceptAll()) - /** * Match events associated with domains and apply another filter referenced by * its [id][FilterOptOfOriginFilterOfDomainEvent] or [event type][DomainEventFilter] */ fun byDomain( - originFilter: OriginFilterOfDomainEvent? = null, - eventFilter: DomainEventFilter? = null, - ) = DataEntityFilter.ByDomain( - FilterOptOfDomainFilter.BySome( - DomainFilter( - originFilter?.let { FilterOptOfOriginFilterOfDomainEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfDomainEvent.AcceptAll(), - eventFilter?.let { FilterOptOfDomainEventFilter.BySome(it) } - ?: FilterOptOfDomainEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + domainId: DomainId? = null, + ) = DataEventFilter.Domain( + DomainEventFilter(domainId, eventSet), ) - /** - * Match events associated with domains - */ - fun byDomain() = DataEntityFilter.ByDomain(FilterOptOfDomainFilter.AcceptAll()) - /** * Match events associated with peers and apply another filter referenced by * its [id][FilterOptOfOriginFilterOfPeerEvent] or [event type][PeerEventFilter] */ fun byPeer( - originFilter: OriginFilterOfPeerEvent? = null, - eventFilter: PeerEventFilter? = null, - ) = DataEntityFilter.ByPeer( - FilterOptOfPeerFilter.BySome( - PeerFilter( - originFilter?.let { FilterOptOfOriginFilterOfPeerEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfPeerEvent.AcceptAll(), - eventFilter?.let { FilterOptOfPeerEventFilter.BySome(it) } - ?: FilterOptOfPeerEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + peerId: PeerId? = null, + ) = DataEventFilter.Peer( + PeerEventFilter(peerId, eventSet), ) - /** - * Match events associated with peers - */ - fun byPeer() = DataEntityFilter.ByPeer(FilterOptOfPeerFilter.AcceptAll()) - /** * Match events associated with roles and apply another filter referenced by * its [id][FilterOptOriginFilterRoleEvent] or [event type][RoleEventFilter] */ fun byRole( - originFilter: OriginFilterOfRoleEvent? = null, - eventFilter: RoleEventFilter? = null, - ) = DataEntityFilter.ByRole( - FilterOptOfRoleFilter.BySome( - RoleFilter( - originFilter?.let { FilterOptOfOriginFilterOfRoleEvent.BySome(it) } - ?: FilterOptOfOriginFilterOfRoleEvent.AcceptAll(), - eventFilter?.let { FilterOptOfRoleEventFilter.BySome(it) } - ?: FilterOptOfRoleEventFilter.AcceptAll(), - ), - ), + eventSet: Long, + roleId: RoleId? = null, + ) = DataEventFilter.Role( + RoleEventFilter(roleId, eventSet), ) - - /** - * Match events associated with roles - */ - fun byRole() = DataEntityFilter.ByRole(FilterOptOfRoleFilter.AcceptAll()) } /** @@ -288,8 +173,8 @@ object EventFilters { * Create a filter with a timed execution */ fun timeEventFilter( - start: Duration, - period: Duration? = null, + start: BigInteger, + period: BigInteger? = null, ) = TimeEventFilter(ExecutionTime.Schedule(Schedule(start, period))) /** @@ -307,43 +192,43 @@ object QueryFilters { * Starts with filter */ fun startsWith(prefix: String) = GenericPredicateBox.Raw( - ValuePredicate.Identifiable(StringPredicate.StartsWith(prefix)), + QueryOutputPredicate.Identifiable(StringPredicate.StartsWith(prefix)), ) /** * Ends with filter */ fun endsWith(suffix: String) = GenericPredicateBox.Raw( - ValuePredicate.Identifiable(StringPredicate.EndsWith(suffix)), + QueryOutputPredicate.Identifiable(StringPredicate.EndsWith(suffix)), ) /** * Contains filter */ fun contains(value: String) = GenericPredicateBox.Raw( - ValuePredicate.Identifiable(StringPredicate.Contains(value)), + QueryOutputPredicate.Identifiable(StringPredicate.Contains(value)), ) /** * Is filter */ fun `is`(value: String) = GenericPredicateBox.Raw( - ValuePredicate.Identifiable(StringPredicate.Is(value)), + QueryOutputPredicate.Identifiable(StringPredicate.Is(value)), ) /** * Filter for multiple matches (OR) */ fun or(vararg predicates: StringPredicate) = predicates - .map { GenericPredicateBox.Raw(ValuePredicate.Identifiable(it)) }.toList() - .let { NonTrivial>(it) } + .map { GenericPredicateBox.Raw(QueryOutputPredicate.Identifiable(it)) }.toList() + .let { NonTrivial>(it) } .let { GenericPredicateBox.Or(it) } /** * Filter for multiple matches (AND) */ fun and(vararg predicates: StringPredicate) = predicates - .map { GenericPredicateBox.Raw(ValuePredicate.Identifiable(it)) }.toList() - .let { NonTrivial>(it) } + .map { GenericPredicateBox.Raw(QueryOutputPredicate.Identifiable(it)) }.toList() + .let { NonTrivial>(it) } .let { GenericPredicateBox.And(it) } } 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 88b3e1c23..7b6134f4b 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 @@ -3,60 +3,8 @@ package jp.co.soramitsu.iroha2.transaction import jp.co.soramitsu.iroha2.Permissions import jp.co.soramitsu.iroha2.asJsonString import jp.co.soramitsu.iroha2.asName -import jp.co.soramitsu.iroha2.asStringWithJson -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.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.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.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.InstructionExpr -import jp.co.soramitsu.iroha2.generated.IpfsPath -import jp.co.soramitsu.iroha2.generated.Metadata -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.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.RegisterExpr -import jp.co.soramitsu.iroha2.generated.RegistrableBox -import jp.co.soramitsu.iroha2.generated.RemoveKeyValueExpr -import jp.co.soramitsu.iroha2.generated.Repeats -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.SequenceExpr -import jp.co.soramitsu.iroha2.generated.SetKeyValueExpr -import jp.co.soramitsu.iroha2.generated.SignatureCheckCondition -import jp.co.soramitsu.iroha2.generated.TimeEventFilter -import jp.co.soramitsu.iroha2.generated.TransferExpr -import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggerOfTriggeringFilterBox -import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox -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 +import jp.co.soramitsu.iroha2.asNumeric +import jp.co.soramitsu.iroha2.generated.* // ktlint-disable no-wildcard-imports import java.math.BigDecimal /** @@ -70,10 +18,10 @@ object Instructions { */ fun registerRole( roleId: RoleId, - vararg tokens: PermissionToken, - ) = registerSome { - RegistrableBox.Role(NewRole(Role(roleId, tokens.toList()))) - } + vararg tokens: Permission, + ) = InstructionBox.Register( + RegisterBox.Role(RegisterOfRole(Role(roleId, tokens.toList()))), + ) /** * Register an account @@ -81,139 +29,80 @@ object Instructions { @JvmOverloads fun registerAccount( id: AccountId, - signatories: List, metadata: Metadata = Metadata(mapOf()), - ) = registerSome { - RegistrableBox.Account(NewAccount(id, signatories, metadata)) - } - - /** - * Register a time trigger - */ - fun registerTimeTrigger( - triggerId: TriggerId, - isi: List, - repeats: Repeats, - accountId: AccountId, - filter: TimeEventFilter, - metadata: Metadata, - ) = registerSome { - RegistrableBox.Trigger( - TriggerOfTriggeringFilterBox( - triggerId, - ActionOfTriggeringFilterBox( - Executable.Instructions(isi), - repeats, - accountId, - TriggeringFilterBox.Time(filter), - metadata, - ), - ), - ) - } - - /** - * Register an executable trigger - */ - fun registerExecutableTrigger( - triggerId: TriggerId, - isi: List, - repeats: Repeats, - accountId: AccountId, - metadata: Metadata, - ) = registerSome { - RegistrableBox.Trigger( - TriggerOfTriggeringFilterBox( - triggerId, - ActionOfTriggeringFilterBox( - Executable.Instructions(isi), - repeats, - accountId, - Filters.executeTrigger(triggerId, accountId), - metadata, - ), - ), - ) - } + ) = InstructionBox.Register( + RegisterBox.Account(RegisterOfAccount(NewAccount(id, metadata))), + ) /** - * Register an event trigger + * Register a WASM trigger */ - fun registerEventTrigger( + fun registerTrigger( triggerId: TriggerId, - isi: List, + wasm: ByteArray, repeats: Repeats, accountId: AccountId, metadata: Metadata, - filter: TriggeringFilterBox, - ) = registerSome { - RegistrableBox.Trigger( - TriggerOfTriggeringFilterBox( - triggerId, - ActionOfTriggeringFilterBox( - Executable.Instructions(isi), - repeats, - accountId, - filter, - metadata, + filter: EventFilterBox, + ) = InstructionBox.Register( + RegisterBox.Trigger( + RegisterOfTrigger( + Trigger( + triggerId, + Action(Executable.Wasm(WasmSmartContract(wasm)), repeats, accountId, filter, metadata), ), ), - ) - } + ), + ) /** - * Register a WASM trigger + * Register a instructions trigger to run after every transaction */ - fun registerWasmTrigger( + fun registerTrigger( triggerId: TriggerId, - wasm: ByteArray, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata, - filter: TriggeringFilterBox, - ) = registerSome { - RegistrableBox.Trigger( - TriggerOfTriggeringFilterBox( - triggerId, - ActionOfTriggeringFilterBox( - Executable.Wasm(WasmSmartContract(wasm)), - repeats, - accountId, - filter, - metadata, - ), - ), - ) - } + filter: TimeEventFilter, + ) = registerTrigger( + triggerId, + isi, + repeats, + accountId, + metadata, + EventFilterBox.Time(TimeEventFilter(filter.executionTime)), + ) /** - * Register a pre-commit trigger to run after every transaction + * Register a instructions trigger to run after every transaction */ - fun registerPreCommitTrigger( + fun registerTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata, - ) = registerSome { - RegistrableBox.Trigger( - TriggerOfTriggeringFilterBox( - triggerId, - ActionOfTriggeringFilterBox( - Executable.Instructions(isi), - repeats, - accountId, - TriggeringFilterBox.Time(EventFilters.timeEventFilter()), - metadata, + filter: EventFilterBox = EventFilterBox.ExecuteTrigger( + ExecuteTriggerEventFilter(triggerId, accountId), + ), + ) = InstructionBox.Register( + RegisterBox.Trigger( + RegisterOfTrigger( + Trigger( + triggerId, + Action(Executable.Instructions(isi), repeats, accountId, filter, metadata), ), ), - ) - } + ), + ) /** * Unregister a trigger */ - fun unregisterTrigger(id: TriggerId) = unregisterSome { IdBox.TriggerId(id) } + fun unregisterTrigger(id: TriggerId) = InstructionBox.Unregister( + UnregisterBox.Trigger(UnregisterOfTrigger(id)), + ) /** * Unregister a trigger @@ -221,34 +110,36 @@ object Instructions { fun unregisterTrigger( triggerName: String, domainId: DomainId? = null, - ) = unregisterSome { - IdBox.TriggerId(TriggerId(domainId, triggerName.asName())) - } + ) = unregisterTrigger(TriggerId(triggerName.asName())) /** * Unregister an asset */ - fun unregisterAsset(id: AssetId) = unregisterSome { IdBox.AssetId(id) } + fun unregisterAsset(id: AssetId) = InstructionBox.Unregister(UnregisterBox.Asset(UnregisterOfAsset(id))) /** * Unregister an asset definition */ - fun unregisterAssetDefinition(id: AssetDefinitionId) = unregisterSome { IdBox.AssetDefinitionId(id) } + fun unregisterAssetDefinition(id: AssetDefinitionId) = InstructionBox.Unregister( + UnregisterBox.AssetDefinition( + UnregisterOfAssetDefinition(id), + ), + ) /** * Unregister an account */ - fun unregisterAccount(id: AccountId) = unregisterSome { IdBox.AccountId(id) } + fun unregisterAccount(id: AccountId) = InstructionBox.Unregister(UnregisterBox.Account(UnregisterOfAccount(id))) /** * Unregister a domain */ - fun unregisterDomain(id: DomainId) = unregisterSome { IdBox.DomainId(id) } + fun unregisterDomain(id: DomainId) = InstructionBox.Unregister(UnregisterBox.Domain(UnregisterOfDomain(id))) /** * Unregister a role */ - fun unregisterRole(id: RoleId) = unregisterSome { IdBox.RoleId(id) } + fun unregisterRole(id: RoleId) = InstructionBox.Unregister(UnregisterBox.Role(UnregisterOfRole(id))) /** * Register an asset @@ -256,21 +147,24 @@ object Instructions { @JvmOverloads fun registerAssetDefinition( id: AssetDefinitionId, - assetValueType: AssetValueType, + assetType: AssetType, metadata: Metadata = Metadata(mapOf()), mintable: Mintable = Mintable.Infinitely(), - ) = registerSome { - RegistrableBox.AssetDefinition( - NewAssetDefinition(id, assetValueType, mintable, metadata = metadata), - ) - } + logo: IpfsPath? = null, + ) = InstructionBox.Register( + RegisterBox.AssetDefinition( + RegisterOfAssetDefinition( + NewAssetDefinition(id, assetType, mintable, logo, metadata), + ), + ), + ) /** * Register an asset */ - fun registerAsset(id: AssetId, assetValue: AssetValue) = registerSome { - RegistrableBox.Asset(Asset(id, assetValue)) - } + fun registerAsset(id: AssetId, assetValue: AssetValue) = InstructionBox.Register( + RegisterBox.Asset(RegisterOfAsset(Asset(id, assetValue))), + ) /** * Register a domain @@ -278,39 +172,27 @@ object Instructions { @JvmOverloads fun registerDomain( domainId: DomainId, - metadata: Map = mapOf(), + metadata: Map = mapOf(), logo: IpfsPath? = null, - ) = registerSome { - RegistrableBox.Domain(NewDomain(domainId, logo, Metadata(metadata))) - } + ) = InstructionBox.Register( + RegisterBox.Domain(RegisterOfDomain(NewDomain(domainId, logo, Metadata(metadata)))), + ) /** * Register a peer */ - @JvmOverloads fun registerPeer( - address: String, - payload: ByteArray, - digestFunction: Algorithm = Algorithm.Ed25519(), - ) = registerSome { - RegistrableBox.Peer( - Peer(PeerId(address.toSocketAddr(), PublicKey(digestFunction, payload))), - ) - } + peerId: PeerId, + ) = InstructionBox.Register( + RegisterBox.Peer(RegisterOfPeer(Peer(peerId))), + ) /** * Unregister a peer */ - @JvmOverloads - fun unregisterPeer( - address: String, - payload: ByteArray, - digestFunction: Algorithm = Algorithm.Ed25519(), - ) = unregisterSome { - IdBox.PeerId( - PeerId(address.toSocketAddr(), PublicKey(digestFunction, payload)), - ) - } + fun unregisterPeer(peerId: PeerId) = InstructionBox.Unregister( + UnregisterBox.Peer(UnregisterOfPeer(peerId)), + ) /** * Set key/value for a given asset @@ -318,12 +200,10 @@ object Instructions { fun setKeyValue( assetId: AssetId, key: Name, - value: Value, - ) = InstructionExpr.SetKeyValue( - SetKeyValueExpr( - objectId = IdBox.AssetId(assetId).evaluatesTo(), - key = key.evaluatesTo(), - value = value.evaluatesTo(), + value: String, + ) = InstructionBox.SetKeyValue( + SetKeyValueBox.Asset( + SetKeyValueOfAsset(assetId, key, value), ), ) @@ -333,12 +213,10 @@ object Instructions { fun setKeyValue( triggerId: TriggerId, key: Name, - value: Value, - ) = InstructionExpr.SetKeyValue( - SetKeyValueExpr( - objectId = IdBox.TriggerId(triggerId).evaluatesTo(), - key = key.evaluatesTo(), - value = value.evaluatesTo(), + value: String, + ) = InstructionBox.SetKeyValue( + SetKeyValueBox.Trigger( + SetKeyValueOfTrigger(triggerId, key, value), ), ) @@ -348,203 +226,139 @@ object Instructions { fun setKeyValue( definitionId: AssetDefinitionId, key: Name, - value: Value, - ) = InstructionExpr.SetKeyValue( - SetKeyValueExpr( - objectId = IdBox.AssetDefinitionId(definitionId).evaluatesTo(), - key = key.evaluatesTo(), - value = value.evaluatesTo(), + value: String, + ) = InstructionBox.SetKeyValue( + SetKeyValueBox.AssetDefinition( + SetKeyValueOfAssetDefinition(definitionId, key, value), ), ) /** - * Set key/value in the metadata of a given account + * Set key/value in the metadata of a given domain */ fun setKeyValue( - accountId: AccountId, + domainId: DomainId, key: Name, - value: Value, - ) = InstructionExpr.SetKeyValue( - SetKeyValueExpr( - objectId = IdBox.AccountId(accountId).evaluatesTo(), - key = key.evaluatesTo(), - value = value.evaluatesTo(), - ), + value: String, + ) = InstructionBox.SetKeyValue( + SetKeyValueBox.Domain(SetKeyValueOfDomain(domainId, key, value)), ) /** - * Remove key/value from a given asset - */ - fun removeKeyValue(assetId: AssetId, key: Name) = InstructionExpr.RemoveKeyValue( - RemoveKeyValueExpr( - objectId = IdBox.AssetId(assetId).evaluatesTo(), - key = key.evaluatesTo(), - ), - ) - - /** - * Set key/value in the metadata of a given domain + * Set key/value in the metadata of a given account */ fun setKeyValue( - domainId: DomainId, + accountId: AccountId, key: Name, - value: Value, - ) = InstructionExpr.SetKeyValue( - SetKeyValueExpr( - objectId = IdBox.DomainId(domainId).evaluatesTo(), - key = key.evaluatesTo(), - value = value.evaluatesTo(), - ), + value: String, + ) = InstructionBox.SetKeyValue( + SetKeyValueBox.Account(SetKeyValueOfAccount(accountId, key, value)), ) /** - * Execute a trigger + * Remove key/value from a given asset */ - fun executeTrigger(triggerId: TriggerId) = InstructionExpr.ExecuteTrigger( - ExecuteTriggerExpr(triggerId.evaluatesTo()), + fun removeKeyValue(assetId: AssetId, key: Name) = InstructionBox.RemoveKeyValue( + RemoveKeyValueBox.Asset(RemoveKeyValueOfAsset(assetId, key)), ) /** - * Mint an asset of the [AssetValueType.Quantity] asset value type - */ - fun mintAsset(assetId: AssetId, quantity: Int) = mintSome(quantity.asValue(), assetId) - - /** - * Mint an asset of the [AssetValueType.Fixed] asset value type + * Execute a trigger */ - fun mintAsset(assetId: AssetId, quantity: BigDecimal) = mintSome(quantity.asValue(), assetId) + fun executeTrigger(triggerId: TriggerId) = InstructionBox.ExecuteTrigger(ExecuteTrigger(triggerId)) /** - * Mint a public key + * Mint an asset of the [AssetType.Quantity] asset value type */ - fun mintPublicKey(accountId: AccountId, pubKey: PublicKey) = mintSome( - Value.PublicKey(pubKey), - IdBox.AccountId(accountId), + fun mintAsset(assetId: AssetId, quantity: Int) = InstructionBox.Mint( + MintBox.Asset(MintOfNumericAndAsset(quantity.asNumeric(), assetId)), ) /** - * Mint + * Mint an asset of the [AssetType.Fixed] asset value type */ - fun mintSignatureCheckCondition(accountId: AccountId, signature: SignatureCheckCondition) = mintSome( - Value.SignatureCheckCondition(signature), - IdBox.AccountId(accountId), + fun mintAsset(assetId: AssetId, quantity: BigDecimal) = InstructionBox.Mint( + MintBox.Asset(MintOfNumericAndAsset(quantity.asNumeric(), assetId)), ) /** - * Burn an asset of the [AssetValueType.Quantity] asset value type + * Burn an asset of the [AssetType.Quantity] asset value type */ - fun burnAsset(assetId: AssetId, value: Int) = burnSome(value.asValue(), IdBox.AssetId(assetId)) - - /** - * Burn an asset of the [AssetValueType.Fixed] asset value type - */ - fun burnAsset(assetId: AssetId, value: BigDecimal) = burnSome(value.asValue(), IdBox.AssetId(assetId)) - - /** - * Burn a public key - */ - fun burnPublicKey(accountId: AccountId, pubKey: PublicKey) = burnSome( - Value.PublicKey(pubKey), - IdBox.AccountId(accountId), + fun burnAsset(assetId: AssetId, value: Int) = InstructionBox.Burn( + BurnBox.Asset(BurnOfNumericAndAsset(value.asNumeric(), assetId)), ) - fun removePublicKey(accountId: AccountId, pubKey: PublicKey) = burnPublicKey(accountId, pubKey) - /** - * Grant an account the [Permissions.CanTransferUserAssetsToken] permission + * Burn an asset of the [AssetType.Fixed] asset value type */ - fun grantPermissionToken( - permission: Permissions, - payload: String, - target: AccountId, - ) = grantSome(target, PermissionToken(permission.type, payload.asStringWithJson()).asValue()) + fun burnAsset(assetId: AssetId, value: BigDecimal) = InstructionBox.Burn( + BurnBox.Asset(BurnOfNumericAndAsset(value.asNumeric(), assetId)), + ) /** * Grant an account the custom permission */ fun grantPermissionToken( - permission: String, - payload: String = "", - target: AccountId, - ) = grantSome(target, PermissionToken(permission.asName(), payload.asStringWithJson()).asValue()) + permission: Permissions, + payload: String = "null", + destinationId: AccountId, + ) = InstructionBox.Grant( + GrantBox.Permission( + GrantOfPermissionAndAccount( + Permission(permission.type, payload), + destinationId, + ), + ), + ) /** * Grant an account a given role. */ - fun grantRole(roleId: RoleId, accountId: AccountId) = InstructionExpr.Grant( - GrantExpr( - destinationId = accountId.evaluatesTo().cast(), - `object` = IdBox.RoleId(roleId).evaluatesTo().cast(), - ), + fun grantRole(roleId: RoleId, destinationId: AccountId) = InstructionBox.Grant( + GrantBox.Role(GrantOfRoleIdAndAccount(roleId, destinationId)), ) /** * Transfer an asset from the identifiable source. */ - 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(), + fun transferAsset(sourceId: AssetId, value: Int, destinationId: AccountId) = InstructionBox.Transfer( + TransferBox.Asset( + AssetTransferBox.Numeric( + TransferOfAssetAndNumericAndAccount(sourceId, value.asNumeric(), destinationId), + ), ), ) /** * Transfer domain ownership. */ - fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = - InstructionExpr.Transfer( - TransferExpr( - sourceId = IdBox.AccountId(sourceId).evaluatesTo(), - `object` = Value.Id(value).evaluatesTo(), - destinationId = IdBox.AccountId(destinationId).evaluatesTo(), + fun transferDomainOwnership(sourceId: AccountId, domainId: DomainId, destinationId: AccountId) = + InstructionBox.Transfer( + TransferBox.Domain( + TransferOfAccountAndDomainIdAndAccount(sourceId, domainId, destinationId), ), ) /** - * Evaluate one instruction if a [condition] is met and another one otherwise. - */ - fun `if`( - condition: Boolean, - then: InstructionExpr, - otherwise: InstructionExpr, - ) = InstructionExpr.If(ConditionalExpr(condition.evaluatesTo(), then, otherwise)) - - /** - * PairExpr two instructions together. - */ - fun pair(left: InstructionExpr, right: InstructionExpr) = InstructionExpr.Pair(PairExpr(left, right)) - - /** - * Combine multiple [instructions] into a sequence. + * Revoke an account the [Permissions.CanSetKeyValueInUserAsset] permission */ - fun sequence(instructions: List) = InstructionExpr.Sequence(SequenceExpr(instructions)) - - /** - * Fail a transaction with a given [message]. - */ - fun fail(message: String) = InstructionExpr.Fail(Fail(message)) - - /** - * Revoke an account the [Permissions.CanSetKeyValueUserAssetsToken] permission - */ - fun revokeSetKeyValueAsset(assetId: AssetId, target: AccountId): InstructionExpr { + fun revokeSetKeyValueAsset(assetId: AssetId, target: AccountId): InstructionBox { return revokeSome(target) { - PermissionToken( - definitionId = Permissions.CanSetKeyValueUserAssetsToken.type, - payload = assetId.asJsonString().asStringWithJson(), + Permission( + name = Permissions.CanSetKeyValueInUserAsset.type, + payload = assetId.asJsonString(), ) } } /** - * Revoke an account the [Permissions.CanSetKeyValueInUserAccount] permission + * Revoke an account the [Permissions.CanSetKeyValueInAccount] permission */ - fun revokeSetKeyValueAccount(accountId: AccountId, target: AccountId): InstructionExpr { + fun revokeSetKeyValueAccount(accountId: AccountId, target: AccountId): InstructionBox { return revokeSome(target) { - PermissionToken( - definitionId = Permissions.CanSetKeyValueInUserAccount.type, - payload = accountId.asJsonString().asStringWithJson(), + Permission( + name = Permissions.CanSetKeyValueInAccount.type, + payload = accountId.asJsonString(), ) } } @@ -552,24 +366,28 @@ object Instructions { /** * Revoke an account the [Permissions.CanSetKeyValueInDomain] permission */ - fun grantSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionExpr { - return grantSome( - target, - PermissionToken( - definitionId = Permissions.CanSetKeyValueInDomain.type, - payload = domainId.asJsonString().asStringWithJson(), - ).asValue(), + fun grantSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionBox { + return InstructionBox.Grant( + GrantBox.Permission( + GrantOfPermissionAndAccount( + Permission( + name = Permissions.CanSetKeyValueInDomain.type, + payload = domainId.asJsonString(), + ), + target, + ), + ), ) } /** * Revoke an account the [Permissions.CanSetKeyValueInDomain] permission */ - fun revokeSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionExpr { + fun revokeSetKeyValueDomain(domainId: DomainId, target: AccountId): InstructionBox { return revokeSome(target) { - PermissionToken( - definitionId = Permissions.CanSetKeyValueInDomain.type, - payload = domainId.asJsonString().asStringWithJson(), + Permission( + name = Permissions.CanSetKeyValueInDomain.type, + payload = domainId.asJsonString(), ) } } @@ -577,60 +395,18 @@ object Instructions { /** * Revoke an account a given role. */ - fun revokeRole(roleId: RoleId, accountId: AccountId): InstructionExpr { - return InstructionExpr.Revoke( - RevokeExpr( - destinationId = accountId.evaluatesTo().cast(), - `object` = IdBox.RoleId(roleId).evaluatesTo().cast(), - ), + fun revokeRole(roleId: RoleId, accountId: AccountId): InstructionBox { + return InstructionBox.Revoke( + RevokeBox.Role(RevokeOfRoleIdAndAccount(roleId, accountId)), ) } - private inline fun unregisterSome(idBox: () -> IdBox) = InstructionExpr.Unregister( - UnregisterExpr(idBox().evaluatesTo()), - ) - - private inline fun registerSome( - regBox: () -> RegistrableBox, - ) = InstructionExpr.Register(RegisterExpr(regBox().evaluatesTo())) - - private fun grantSome(accountId: AccountId, value: Value) = InstructionExpr.Grant( - GrantExpr( - `object` = value.evaluatesTo(), - destinationId = accountId.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) = InstructionExpr.Burn( - BurnExpr( - `object` = value.evaluatesTo(), - destinationId = idBox.evaluatesTo(), - ), - ) - - private fun mintSome(value: Value, idBox: IdBox) = InstructionExpr.Mint( - MintExpr( - `object` = value.evaluatesTo(), - destinationId = idBox.evaluatesTo(), - ), - ) - - private fun mintSome(value: Value, assetId: AssetId) = InstructionExpr.Mint( - MintExpr( - `object` = value.evaluatesTo(), - destinationId = IdBox.AssetId(assetId).evaluatesTo(), + permission: () -> Permission, + ) = InstructionBox.Revoke( + RevokeBox.Permission( + RevokeOfPermissionAndAccount(permission(), accountId), ), ) } 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 01915783e..26a8f4c15 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 @@ -5,56 +5,29 @@ import jp.co.soramitsu.iroha2.Permissions import jp.co.soramitsu.iroha2.U32_MAX_VALUE import jp.co.soramitsu.iroha2.asName import jp.co.soramitsu.iroha2.asSignatureOf -import jp.co.soramitsu.iroha2.generated.AccountId -import jp.co.soramitsu.iroha2.generated.Algorithm -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.DomainId -import jp.co.soramitsu.iroha2.generated.Executable -import jp.co.soramitsu.iroha2.generated.IdBox -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 -import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.NonZeroOfu32 -import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 -import jp.co.soramitsu.iroha2.generated.PermissionToken -import jp.co.soramitsu.iroha2.generated.PublicKey -import jp.co.soramitsu.iroha2.generated.Repeats -import jp.co.soramitsu.iroha2.generated.RoleId -import jp.co.soramitsu.iroha2.generated.Signature -import jp.co.soramitsu.iroha2.generated.SignatureCheckCondition -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.* // ktlint-disable no-wildcard-imports import jp.co.soramitsu.iroha2.sign -import jp.co.soramitsu.iroha2.toIrohaPublicKey import java.math.BigDecimal import java.math.BigInteger import java.security.KeyPair import java.time.Duration import java.time.Instant +import java.util.UUID import kotlin.random.Random import kotlin.random.nextLong class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { + var chainId: ChainId? var accountId: AccountId? - val instructions: Lazy> + val instructions: Lazy> var creationTimeMillis: BigInteger? var timeToLiveMillis: BigInteger? var nonce: Long? - var metadata: Lazy> + var metadata: Lazy> init { + chainId = ChainId("00000000-0000-0000-0000-000000000000") accountId = null instructions = lazy { ArrayList() } creationTimeMillis = null @@ -64,16 +37,18 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { builder(this) } + fun chainId(uuid: UUID) = this.apply { chainId = ChainId(uuid.toString()) } + fun account(accountId: AccountId) = this.apply { this.accountId = accountId } - fun account(accountName: Name, domainId: DomainId) = this.account(AccountId(domainId, accountName)) + fun account(signatory: PublicKey, domainId: DomainId) = this.account(AccountId(domainId, signatory)) - fun instructions(vararg instructions: InstructionExpr) = this.apply { this.instructions.value.addAll(instructions) } + fun instructions(vararg instructions: InstructionBox) = 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: InstructionExpr) = this.apply { this.instructions.value.add(instruction) } + fun instruction(instruction: InstructionBox) = this.apply { this.instructions.value.add(instruction) } fun creationTime(creationTimeMillis: BigInteger) = this.apply { this.creationTimeMillis = creationTimeMillis } @@ -87,46 +62,41 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun timeToLive(ttlMillis: Long) = this.apply { this.timeToLive(ttlMillis.toBigInteger()) } - fun buildSigned(vararg keyPairs: KeyPair): SignedTransaction { + fun buildSigned(keyPair: KeyPair): SignedTransaction { val payload = TransactionPayload( + checkNotNull(chainId) { "Chain ID is required" }, + checkNotNull(accountId) { "Account Id is required" }, creationTimeMillis ?: fallbackCreationTime(), - checkNotNull(accountId) { "Account Id of the sender is mandatory" }, Executable.Instructions(instructions.value), NonZeroOfu64(timeToLiveMillis ?: DURATION_OF_24_HOURS_IN_MILLIS), NonZeroOfu32(nonce ?: throw IrohaClientException("Nonce must not be null")), - metadata.value, + Metadata(metadata.value), ) val encodedPayload = TransactionPayload.encode(payload) - - val signatures = keyPairs.map { - Signature( - it.public.toIrohaPublicKey(), - it.private.sign(encodedPayload), - ).asSignatureOf() - }.toList() + val signature = Signature(keyPair.private.sign(encodedPayload)).asSignatureOf() return SignedTransaction.V1( - SignedTransactionV1(SignaturesOfOfTransactionPayload(signatures), payload), + SignedTransactionV1(TransactionSignature(signature), payload), ) } @JvmOverloads fun registerTimeTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, filter: TimeEventFilter, metadata: Metadata = Metadata(mapOf()), ) = this.apply { instructions.value.add( - Instructions.registerTimeTrigger( + Instructions.registerTrigger( triggerId, isi, repeats, accountId, - filter, metadata, + filter, ), ) } @@ -134,13 +104,13 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerExecutableTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), ) = this.apply { instructions.value.add( - Instructions.registerExecutableTrigger( + Instructions.registerTrigger( triggerId, isi, repeats, @@ -153,14 +123,14 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerEventTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), - filter: TriggeringFilterBox, + filter: EventFilterBox, ) = this.apply { instructions.value.add( - Instructions.registerEventTrigger( + Instructions.registerTrigger( triggerId, isi, repeats, @@ -178,10 +148,10 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), - filter: TriggeringFilterBox, + filter: EventFilterBox, ) = this.apply { instructions.value.add( - Instructions.registerWasmTrigger( + Instructions.registerTrigger( triggerId, wasm, repeats, @@ -195,18 +165,20 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerPreCommitTrigger( triggerId: TriggerId, - isi: List, + isi: List, repeats: Repeats, accountId: AccountId, metadata: Metadata = Metadata(mapOf()), + filter: EventFilterBox = EventFilterBox.Time(TimeEventFilter(ExecutionTime.PreCommit())), ) = this.apply { instructions.value.add( - Instructions.registerPreCommitTrigger( + Instructions.registerTrigger( triggerId, isi, repeats, accountId, metadata, + filter, ), ) } @@ -250,7 +222,7 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun registerRole( id: RoleId, - vararg tokens: PermissionToken, + vararg tokens: Permission, ) = this.apply { instructions.value.add(Instructions.registerRole(id, *tokens)) } fun unregisterRole( @@ -260,14 +232,13 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { @JvmOverloads fun registerAccount( id: AccountId, - signatories: List, metadata: Metadata = Metadata(mapOf()), - ) = this.apply { instructions.value.add(Instructions.registerAccount(id, signatories, metadata)) } + ) = this.apply { instructions.value.add(Instructions.registerAccount(id, metadata)) } @JvmOverloads fun registerAssetDefinition( id: AssetDefinitionId, - assetValueType: AssetValueType, + assetValueType: AssetType, metadata: Metadata = Metadata(mapOf()), mintable: Mintable = Mintable.Infinitely(), ) = this.apply { @@ -280,12 +251,12 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun registerAssetDefinition( name: Name, domainId: DomainId, - assetValueType: AssetValueType, + assetValueType: AssetType, metadata: Metadata = Metadata(mapOf()), mintable: Mintable = Mintable.Infinitely(), ) = this.apply { instructions.value.add( - Instructions.registerAssetDefinition(AssetDefinitionId(name, domainId), assetValueType, metadata, mintable), + Instructions.registerAssetDefinition(AssetDefinitionId(domainId, name), assetValueType, metadata, mintable), ) } @@ -297,37 +268,37 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { fun setKeyValue( assetId: AssetId, key: String, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(assetId, key.asName(), value)) } fun setKeyValue( assetId: AssetId, key: Name, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(assetId, key, value)) } fun setKeyValue( accountId: AccountId, key: Name, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(accountId, key, value)) } fun setKeyValue( definitionId: AssetDefinitionId, key: Name, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(definitionId, key, value)) } fun setKeyValue( triggerId: TriggerId, key: Name, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(triggerId, key, value)) } fun setKeyValue( domainId: DomainId, key: Name, - value: Value, + value: String, ) = this.apply { instructions.value.add(Instructions.setKeyValue(domainId, key, value)) } fun removeKeyValue( @@ -354,15 +325,10 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { quantity: BigDecimal, ) = this.apply { instructions.value.add(Instructions.mintAsset(assetId, quantity)) } - fun mintSignatureCheckCondition( - accountId: AccountId, - signature: SignatureCheckCondition, - ) = this.apply { instructions.value.add(Instructions.mintSignatureCheckCondition(accountId, signature)) } - @JvmOverloads fun registerDomain( domainId: DomainId, - metadata: Map = mapOf(), + metadata: Map = mapOf(), logo: IpfsPath? = null, ) = this.apply { instructions.value.add( @@ -374,28 +340,16 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { ) } - @JvmOverloads - fun registerPeer( - address: String, - payload: ByteArray, - algorithm: Algorithm = Algorithm.Ed25519(), - ) = this.apply { instructions.value.add(Instructions.registerPeer(address, payload, algorithm)) } + fun registerPeer(peerId: PeerId) = this.apply { instructions.value.add(Instructions.registerPeer(peerId)) } - @JvmOverloads fun unregisterPeer( - address: String, - payload: ByteArray, - algorithm: Algorithm = Algorithm.Ed25519(), - ) = this.apply { instructions.value.add(Instructions.unregisterPeer(address, payload, algorithm)) } + peerId: PeerId, + ) = this.apply { instructions.value.add(Instructions.unregisterPeer(peerId)) } fun grantPermissionToken(permission: Permissions, payload: String, target: AccountId) = this.apply { instructions.value.add(Instructions.grantPermissionToken(permission, payload, target)) } - fun grantPermissionToken(permission: String, payload: String = "", target: AccountId) = this.apply { - instructions.value.add(Instructions.grantPermissionToken(permission, payload, target)) - } - fun burnAsset(assetId: AssetId, value: Int) = this.apply { instructions.value.add(Instructions.burnAsset(assetId, value)) } @@ -404,40 +358,14 @@ class TransactionBuilder(builder: TransactionBuilder.() -> Unit = {}) { instructions.value.add(Instructions.burnAsset(assetId, value)) } - fun burnPublicKey(accountId: AccountId, pubKey: PublicKey) = this.apply { - instructions.value.add(Instructions.burnPublicKey(accountId, pubKey)) - } - - fun mintPublicKey(accountId: AccountId, pubKey: PublicKey) = this.apply { - instructions.value.add(Instructions.mintPublicKey(accountId, pubKey)) - } - - fun removePublicKey(accountId: AccountId, pubKey: PublicKey) = burnPublicKey(accountId, pubKey) - fun transferAsset(sourceId: AssetId, value: Int, destinationId: AccountId) = this.apply { instructions.value.add(Instructions.transferAsset(sourceId, value, destinationId)) } - fun `if`(condition: Boolean, then: InstructionExpr, otherwise: InstructionExpr) = this.apply { - instructions.value.add(Instructions.`if`(condition, then, otherwise)) - } - - fun transferDomainOwnership(sourceId: AccountId, value: IdBox.DomainId, destinationId: AccountId) = this.apply { + fun transferDomainOwnership(sourceId: AccountId, value: DomainId, destinationId: AccountId) = this.apply { instructions.value.add(Instructions.transferDomainOwnership(sourceId, value, destinationId)) } - fun pair(left: InstructionExpr, right: InstructionExpr) = this.apply { - instructions.value.add(Instructions.pair(left, right)) - } - - fun sequence(vararg instructions: InstructionExpr) = this.apply { - this.instructions.value.add(Instructions.sequence(instructions.toList())) - } - - fun fail(message: String) = this.apply { - this.instructions.value.add(Instructions.fail(message)) - } - fun revokeSetKeyValueAsset(assetId: AssetId, target: AccountId) = this.apply { instructions.value.add(Instructions.revokeSetKeyValueAsset(assetId, target)) } diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/build.sh b/modules/client/src/test/create_nft_for_alice_smartcontract/build.sh deleted file mode 100755 index 21ded470d..000000000 --- a/modules/client/src/test/create_nft_for_alice_smartcontract/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cargo +nightly-2023-06-25 build --release -Zbuild-std -Zbuild-std-features=panic_immediate_abort -cp ./target/wasm32-unknown-unknown/release/create_nft_for_alice_smartcontract.wasm ../resources/create_nft_for_alice_smartcontract.wasm diff --git a/modules/client/src/test/executor/src/lib.rs b/modules/client/src/test/executor/src/lib.rs deleted file mode 100644 index 358264e4e..000000000 --- a/modules/client/src/test/executor/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Runtime Executor for client tests -#![no_std] - -extern crate alloc; -#[cfg(not(test))] -extern crate panic_halt; - -use iroha_executor::{default::default_permission_token_schema, 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(Clone, Constructor, Debug, ValidateEntrypoints, ExpressionEvaluator, Validate, Visit)] -pub struct Executor { - verdict: Result, - block_height: u64, - host: smart_contract::Host, -} - -/// 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 executor will stay unchanged. -#[entrypoint] -pub fn migrate(_block_height: u64) -> MigrationResult { - let schema = default_permission_token_schema(); - let (token_ids, schema_str) = schema.serialize(); - - iroha_executor::set_permission_token_schema( - &iroha_executor::data_model::permission::PermissionTokenSchema::new(token_ids, schema_str), - ); - - Ok(()) -} 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 b86f057b9..870a46071 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 @@ -1,11 +1,14 @@ package jp.co.soramitsu.iroha2; +import java.security.*; import java.time.*; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import static jp.co.soramitsu.iroha2.CryptoUtils.generateKeyPair; +import static jp.co.soramitsu.iroha2.ExtensionsKt.toIrohaPublicKey; import jp.co.soramitsu.iroha2.client.Iroha2AsyncClient; import jp.co.soramitsu.iroha2.client.blockstream.*; import jp.co.soramitsu.iroha2.generated.*; @@ -29,22 +32,11 @@ import static jp.co.soramitsu.iroha2.testengine.TestConstsKt.DEFAULT_ASSET_DEFINITION_ID; import static jp.co.soramitsu.iroha2.testengine.TestConstsKt.DEFAULT_ASSET_ID; import static jp.co.soramitsu.iroha2.testengine.TestConstsKt.DEFAULT_DOMAIN_ID; -import org.junit.jupiter.api.parallel.ResourceLock; +import org.junit.jupiter.api.parallel.*; import static org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; public class JavaTest extends IrohaTest { - @Test - @WithIroha(sources = DefaultGenesis.class) - public void instructionFailed() { - final SignedTransaction transaction = TransactionBuilder.Companion.builder() - .account(ALICE_ACCOUNT_ID) - .fail("FAIL MESSAGE") - .buildSigned(ALICE_KEYPAIR); - final CompletableFuture future = client.sendTransactionAsync(transaction); - Assertions.assertThrows(ExecutionException.class, () -> future.get(getTxTimeout().getSeconds(), TimeUnit.SECONDS)); - } - @Test @WithIroha(sources = DefaultGenesis.class) public void registerDomain() throws ExecutionException, InterruptedException, TimeoutException { @@ -66,10 +58,11 @@ public void registerDomain() throws ExecutionException, InterruptedException, Ti @Test @WithIroha(sources = DefaultGenesis.class) public void registerAccount() throws Exception { - final AccountId accountId = new AccountId(DEFAULT_DOMAIN_ID, new Name("new_account")); + final KeyPair keyPair = generateKeyPair(); + final AccountId accountId = new AccountId(DEFAULT_DOMAIN_ID, toIrohaPublicKey(keyPair.getPublic())); final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) - .registerAccount(accountId, new ArrayList<>()) + .registerAccount(accountId, new Metadata(Collections.emptyMap())) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(transaction).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); @@ -86,7 +79,7 @@ public void registerAccount() throws Exception { public void mintAsset() throws Exception { final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) - .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Quantity()) + .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetType.Numeric(new NumericSpec())) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); @@ -96,57 +89,56 @@ public void mintAsset() throws Exception { .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(mintAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); - final QueryAndExtractor query = QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) + final QueryAndExtractor> query = QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR); - final CompletableFuture future = client.sendQueryAsync(query); - final Account account = future.get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); - final AssetValue value = account.getAssets().get(DEFAULT_ASSET_ID).getValue(); - Assertions.assertEquals(5, ((AssetValue.Quantity) value).getU32()); + final CompletableFuture> future = client.sendQueryAsync(query); + final List assets = future.get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); + Assertions.assertEquals(5, ((AssetValue.Numeric) assets.stream().findFirst().get().getValue()).getNumeric().getMantissa().intValue()); } @Test @WithIroha(sources = DefaultGenesis.class) public void updateKeyValue() throws Exception { final Name assetMetadataKey = new Name("asset_metadata_key"); - final Value.String assetMetadataValue = new Value.String("some string value"); - final Value.String assetMetadataValue2 = new Value.String("some string value 2"); - final Metadata metadata = new Metadata(new HashMap() {{ + final String assetMetadataValue = "some string value"; + final String assetMetadataValue2 = "some string value 2"; + final Metadata metadata = new Metadata(new HashMap() {{ put(assetMetadataKey, assetMetadataValue); }}); final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) - .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Store(), metadata) + .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetType.Store(), metadata, new Mintable.Infinitely()) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); - final AssetId assetId = new AssetId(DEFAULT_ASSET_DEFINITION_ID, ALICE_ACCOUNT_ID); + final AssetId assetId = new AssetId(ALICE_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID); final SignedTransaction keyValueTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) .setKeyValue(assetId, assetMetadataKey, assetMetadataValue2) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(keyValueTx).get(30, TimeUnit.SECONDS); - final QueryAndExtractor assetDefinitionValueQuery = QueryBuilder + final QueryAndExtractor assetDefinitionValueQuery = QueryBuilder .findAssetKeyValueByIdAndKey(assetId, assetMetadataKey) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR); - final CompletableFuture future = client.sendQueryAsync(assetDefinitionValueQuery); + final CompletableFuture future = client.sendQueryAsync(assetDefinitionValueQuery); - final Value value = future.get(30, TimeUnit.SECONDS); - Assertions.assertEquals(((Value.String) value).getString(), assetMetadataValue2.getString()); + final String value = future.get(30, TimeUnit.SECONDS); + Assertions.assertEquals(value, assetMetadataValue2); } @Test @WithIroha(sources = DefaultGenesis.class) public void setKeyValue() throws Exception { - final Value.String assetValue = new Value.String("some string value"); + final String assetValue = "some string value"; final Name assetKey = new Name("asset_metadata_key"); final SignedTransaction registerAssetTx = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) - .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetValueType.Store()) + .registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, new AssetType.Store()) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(registerAssetTx).get(getTxTimeout().getSeconds(), TimeUnit.SECONDS); @@ -156,14 +148,14 @@ public void setKeyValue() throws Exception { .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(keyValueTx).get(10, TimeUnit.SECONDS); - final QueryAndExtractor assetDefinitionValueQuery = QueryBuilder + final QueryAndExtractor assetDefinitionValueQuery = QueryBuilder .findAssetDefinitionKeyValueByIdAndKey(DEFAULT_ASSET_DEFINITION_ID, assetKey) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR); - final CompletableFuture future = client.sendQueryAsync(assetDefinitionValueQuery); + final CompletableFuture future = client.sendQueryAsync(assetDefinitionValueQuery); - final Value value = future.get(10, TimeUnit.SECONDS); - Assertions.assertEquals(((Value.String) value).getString(), assetValue.getString()); + final String value = future.get(10, TimeUnit.SECONDS); + Assertions.assertEquals(value, assetValue); } @Test @@ -182,7 +174,7 @@ public void blockStreaming() throws ExecutionException, InterruptedException { for (int i = 0; i <= count + 1; i++) { final SignedTransaction transaction = TransactionBuilder.Companion.builder() .account(ALICE_ACCOUNT_ID) - .setKeyValue(ALICE_ACCOUNT_ID, new Name(randomAlphabetic(10)), new Value.String(randomAlphabetic(10))) + .setKeyValue(ALICE_ACCOUNT_ID, new Name(randomAlphabetic(10)), new String(randomAlphabetic(10))) .buildSigned(ALICE_KEYPAIR); client.sendTransactionAsync(transaction); } 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 818618e2b..8f0d0bca2 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 @@ -6,23 +6,24 @@ import io.qameta.allure.Owner import io.qameta.allure.Story import jp.co.soramitsu.iroha2.annotations.Sdk 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.AssetType 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.InstructionExpr +import jp.co.soramitsu.iroha2.generated.InstructionBox +import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 +import jp.co.soramitsu.iroha2.generated.SetKeyValueBox import jp.co.soramitsu.iroha2.generated.SignedTransaction import jp.co.soramitsu.iroha2.generated.TransactionPayload 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 import jp.co.soramitsu.iroha2.testengine.BOB_KEYPAIR +import jp.co.soramitsu.iroha2.testengine.BOB_PUBLIC_KEY import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID -import jp.co.soramitsu.iroha2.testengine.DefaultGenesis -import jp.co.soramitsu.iroha2.testengine.GENESIS +import jp.co.soramitsu.iroha2.testengine.GENESIS_ADDRESS +import jp.co.soramitsu.iroha2.testengine.GENESIS_DOMAIN import jp.co.soramitsu.iroha2.testengine.IrohaTest import jp.co.soramitsu.iroha2.testengine.NewAccountWithMetadata import jp.co.soramitsu.iroha2.testengine.WithIroha @@ -38,7 +39,7 @@ import kotlin.test.assertTrue @Owner("akostyuchenko") @Sdk("Java/Kotlin") @Feature("Block Streaming") -class BlockStreamTest : IrohaTest() { +class BlockStreamTest : IrohaTest() { @Test @WithIroha([NewAccountWithMetadata::class]) @@ -47,40 +48,41 @@ class BlockStreamTest : IrohaTest() { @Issue("https://app.zenhub.com/workspaces/iroha-v2-60ddb820813b9100181fc060/issues/gh/hyperledger/iroha-java/361") @ResourceLock("blockStream") fun `subscription to block stream`(): Unit = runBlocking { - val idToSubscription = client.subscribeToBlockStream(from = 1, count = 2) + val idToSubscription = client.subscribeToBlockStream(from = 1, count = 3) val actionId = idToSubscription.first.first().id val subscription = idToSubscription.second val newAssetName = "rox" + client.tx { + transferDomainOwnership(ALICE_ACCOUNT_ID, DEFAULT_DOMAIN_ID, BOB_ACCOUNT_ID) + } client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - registerAssetDefinition(newAssetName.asName(), DEFAULT_DOMAIN_ID, AssetValueType.Store()) + registerAssetDefinition(newAssetName.asName(), DEFAULT_DOMAIN_ID, AssetType.Store()) } - var blocks = mutableListOf() + + val 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 expectedSize = NewAccountWithMetadata().transaction.instructions.count() + 2 // + wasm + peer register + var isi = blocks[0].validate(1, GENESIS_DOMAIN, GENESIS_ADDRESS, expectedSize) + 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()) - assertEquals(BOB_ACCOUNT_ID.asString(), isi[2].extractAccount().id.asString()) - assertEquals( - "${NewAccountWithMetadata.ACCOUNT_NAME.string}$ACCOUNT_ID_DELIMITER$DEFAULT_DOMAIN", - isi[3].extractAccount().id.asString(), - ) + assertEquals(ALICE_ACCOUNT_ID, isi[1].extractAccount().id) + assertEquals(BOB_ACCOUNT_ID, isi[2].extractAccount().id) + assertEquals(NewAccountWithMetadata.ACCOUNT_ID, isi[3].extractAccount().id) - isi = blocks[1].validate(2, DEFAULT_DOMAIN, BOB_ACCOUNT, 1) - var newAssetDefinition = isi[0].cast().extractAssetDefinition() + isi = blocks[2].validate(3, DEFAULT_DOMAIN, BOB_PUBLIC_KEY.payload.toHex(true), 1) + val newAssetDefinition = isi[0].cast().extractAssetDefinition() assertNotNull(newAssetDefinition) assertEquals(newAssetName, newAssetDefinition.id.name.string) - assertEquals(DEFAULT_DOMAIN, newAssetDefinition.id.domainId.asString()) + assertEquals(DEFAULT_DOMAIN, newAssetDefinition.id.domain.asString()) subscription.stop() } @Test - @WithIroha([DefaultGenesis::class]) + @WithIroha([NewAccountWithMetadata::class]) @Story("Successful subscription to endless block stream") @SdkTestId("subscription_to_endless_block_stream") @ResourceLock("blockStream") @@ -89,21 +91,21 @@ class BlockStreamTest : IrohaTest() { val shift = 1 // to test not to take more than was ordered val idToSubscription = client.subscribeToBlockStream( onBlock = { block -> block.extractBlock().height() }, - cancelIf = { block -> block.extractBlock().height() == BigInteger.valueOf(repeatTimes.toLong()) }, + cancelIf = { block -> block.extractBlock().height().u64 == BigInteger.valueOf(repeatTimes.toLong()) }, ) val initialActionId = idToSubscription.first.first().id val subscription = idToSubscription.second var heightSum = BigInteger.ZERO - subscription.receive(initialActionId) { heightSum += it } + subscription.receive(initialActionId) { heightSum += it.u64 } repeat(repeatTimes + shift) { - client.tx { setKeyValue(ALICE_ACCOUNT_ID, randomAlphabetic(16).asName(), randomAlphabetic(16).asValue()) } + client.tx { setKeyValue(ALICE_ACCOUNT_ID, randomAlphabetic(16).asName(), randomAlphabetic(16)) } } 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() }, ), @@ -113,10 +115,12 @@ class BlockStreamTest : IrohaTest() { lateinit var lastValue: String repeat(repeatTimes * 2) { lastValue = randomAlphabetic(16) - client.tx { setKeyValue(ALICE_ACCOUNT_ID, randomAlphabetic(16).asName(), lastValue.asValue()) } + client.tx { setKeyValue(ALICE_ACCOUNT_ID, randomAlphabetic(16).asName(), lastValue) } } Thread.sleep(5000) - assertEquals(lastValue, isi.last().cast().extractValueString()) + val actual = isi.last().cast().setKeyValueBox + .cast().setKeyValueOfAccount.value + assertEquals(lastValue, actual) subscription.stop() } @@ -133,13 +137,17 @@ class BlockStreamTest : IrohaTest() { expectedDomain: String, expectedAccount: String, expectedIsiSize: Int, - ): List { + ): List { val committedBlock = this.extractBlock() - assertEquals(expectedHeight, committedBlock.header.height.toLong()) + assertEquals(expectedHeight, committedBlock.header.height.u64.toLong()) val payloads = committedBlock.payloads() - assertTrue { payloads.any { it.authority.domainId.name.string == expectedDomain } } - assertTrue { payloads.any { it.authority.name.string == expectedAccount } } + assertTrue { payloads.any { it.authority.domain.name.string == expectedDomain } } + assertTrue { + payloads.any { + it.authority.signatory.payload.toHex(true).lowercase() == expectedAccount.lowercase() + } + } val instructions = payloads.reversed().map { it.instructions.cast().vec diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/ExampleTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/ExampleTest.kt index a2a3e1519..d10f57092 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/ExampleTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/ExampleTest.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.time.withTimeout import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.time.Duration -import kotlin.reflect.full.createInstance import kotlin.test.assertEquals @Disabled @@ -24,10 +23,10 @@ class ExampleTest { fun `register domain instruction committed`(): Unit = runBlocking { val container = IrohaContainer { this.alias = "iroha$DEFAULT_P2P_PORT" - this.genesis = DefaultGenesis::class.createInstance() + this.genesis = DefaultGenesis() }.also { it.start() } - val client = Iroha2Client(container.getApiUrl(), container.getTelemetryUrl(), container.getP2pUrl(), true) + val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl(), true) val domainId = "new_domain_name".asDomainId() client.sendTransaction { diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/GenesisTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/GenesisTest.kt index 39f8a47c7..442b264a8 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/GenesisTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/GenesisTest.kt @@ -2,12 +2,14 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.generated.AssetDefinitionId -import jp.co.soramitsu.iroha2.generated.AssetValueType +import jp.co.soramitsu.iroha2.generated.AssetType import jp.co.soramitsu.iroha2.query.QueryBuilder import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID +import jp.co.soramitsu.iroha2.testengine.ALICE_KEYPAIR import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT_ID import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID import jp.co.soramitsu.iroha2.testengine.DefaultGenesis +import jp.co.soramitsu.iroha2.testengine.IROHA_CONFIG_DELIMITER import jp.co.soramitsu.iroha2.testengine.IrohaContainer import jp.co.soramitsu.iroha2.testengine.IrohaTest import jp.co.soramitsu.iroha2.testengine.WithIroha @@ -17,14 +19,10 @@ import kotlin.test.assertEquals class GenesisTest : IrohaTest() { companion object { - private val ALICE_KEYPAIR = keyPairFromHex( - "cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1", - "3bac34cda9e3763fa069c1198312d1ec73b53023b8180c822ac355435edc4a24", - ) } @Test - @WithIroha(source = "src/test/resources/genesis.json") + @WithIroha(source = "src/test/resources/genesis.json", configs = ["LOG_LEVEL${IROHA_CONFIG_DELIMITER}TRACE"]) fun `register asset instruction committed`(): Unit = runBlocking { client.checkAliceAndBobExists() } @@ -37,15 +35,15 @@ class GenesisTest : IrohaTest() { this.genesisPath = path }.also { it.start() } - val client = Iroha2Client(container.getApiUrl(), container.getTelemetryUrl(), container.getP2pUrl(), true) + val client = Iroha2Client(container.getApiUrl(), container.getP2pUrl(), true) client.checkAliceAndBobExists() } @Test @WithIroha([DefaultGenesis::class], executorSource = "src/test/resources/executor.wasm") fun `custom executor path`(): Unit = runBlocking { - val definitionId = AssetDefinitionId("XSTUSD".asName(), DEFAULT_DOMAIN_ID) - client.tx { registerAssetDefinition(definitionId, AssetValueType.Quantity()) } + val definitionId = AssetDefinitionId(DEFAULT_DOMAIN_ID, "XSTUSD".asName()) + client.tx { registerAssetDefinition(definitionId, AssetType.numeric()) } QueryBuilder.findAssetDefinitionById(definitionId) .account(super.account) 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 d8376a5e9..09a60a208 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 @@ -8,30 +8,19 @@ import jp.co.soramitsu.iroha2.annotations.Sdk import jp.co.soramitsu.iroha2.annotations.SdkTestId import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.generated.AccountId +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.AssetType import jp.co.soramitsu.iroha2.generated.AssetValue -import jp.co.soramitsu.iroha2.generated.AssetValueType -import jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue -import jp.co.soramitsu.iroha2.generated.BatchedResponseV1OfValue import jp.co.soramitsu.iroha2.generated.DomainId -import jp.co.soramitsu.iroha2.generated.IdBox -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.PermissionToken -import jp.co.soramitsu.iroha2.generated.PublicKey import jp.co.soramitsu.iroha2.generated.RoleId -import jp.co.soramitsu.iroha2.generated.SignatureCheckCondition -import jp.co.soramitsu.iroha2.generated.SignedTransaction -import jp.co.soramitsu.iroha2.generated.Value 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 import jp.co.soramitsu.iroha2.testengine.ALICE_KEYPAIR import jp.co.soramitsu.iroha2.testengine.AliceAndBobEachHave100Xor -import jp.co.soramitsu.iroha2.testengine.AliceAndBobHasPermissionToMintPublicKeys -import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToBurn +import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToMintAndBurn import jp.co.soramitsu.iroha2.testengine.AliceHasPermissionToUnregisterDomain import jp.co.soramitsu.iroha2.testengine.AliceHasRoleWithAccessToBobsMetadata import jp.co.soramitsu.iroha2.testengine.AliceWithTestAssets @@ -53,10 +42,6 @@ import jp.co.soramitsu.iroha2.testengine.WithDomainTransferredToBob import jp.co.soramitsu.iroha2.testengine.WithIroha import jp.co.soramitsu.iroha2.testengine.WithIrohaManual import jp.co.soramitsu.iroha2.testengine.XorAndValAssets -import jp.co.soramitsu.iroha2.transaction.Instructions -import jp.co.soramitsu.iroha2.transaction.Instructions.fail -import jp.co.soramitsu.iroha2.transaction.TransactionBuilder -import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.time.withTimeout import org.apache.commons.lang3.RandomStringUtils.randomAlphabetic @@ -68,18 +53,12 @@ import java.math.BigDecimal import java.math.MathContext import java.math.RoundingMode import java.security.SecureRandom -import java.time.Instant import java.util.UUID -import kotlin.reflect.full.callSuspend -import kotlin.reflect.full.declaredMemberFunctions -import kotlin.reflect.jvm.isAccessible import kotlin.test.assertEquals -import kotlin.test.assertFails import kotlin.test.assertFailsWith import kotlin.test.assertFalse -import kotlin.test.assertNotNull -import kotlin.test.assertNull import kotlin.test.assertTrue +import kotlin.test.fail @Owner("akostyuchenko") @Sdk("Java/Kotlin") @@ -89,9 +68,8 @@ class InstructionsTest : IrohaTest() { @Disabled // EXAMPLE @WithIrohaManual( ["http://localhost:8080", "http://localhost:8081", "http://localhost:8082", "http://localhost:8083"], - ["http://localhost:8180", "http://localhost:8181", "http://localhost:8182", "http://localhost:8183"], ["http://localhost:1337", "http://localhost:1338", "http://localhost:1339", "http://localhost:1340"], - account = ALICE_ACCOUNT_ID_VALUE, + account = "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0${ACCOUNT_ID_DELIMITER}wonderland", "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", ) @@ -115,7 +93,7 @@ class InstructionsTest : IrohaTest() { @Test @Disabled // EXAMPLE @WithIrohaManual( - account = ALICE_ACCOUNT_ID_VALUE, + account = "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0${ACCOUNT_ID_DELIMITER}wonderland", publicKey = "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", privateKey = "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", dockerComposeFile = "../../docker-compose/docker-compose.yaml", @@ -149,6 +127,7 @@ class InstructionsTest : IrohaTest() { @SdkTestId("register_domain") fun `register domain`(): Unit = runBlocking { val domainId = "new_domain_name".asDomainId() + client.sendTransaction { account(super.account) registerDomain(domainId) @@ -176,10 +155,10 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_account") fun `register account`(): Unit = runBlocking { - val newAccountId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) + val newAccountId = AccountId(DEFAULT_DOMAIN_ID, generatePublicKey()) client.sendTransaction { account(super.account) - registerAccount(newAccountId, listOf()) + registerAccount(newAccountId) buildSigned(super.keyPair) }.also { d -> withTimeout(txTimeout) { d.await() } @@ -202,9 +181,9 @@ class InstructionsTest : IrohaTest() { @SdkTestId("register_account") @SdkTestId("unregister_account") fun `register and unregister account`(): Unit = runBlocking { - val joeId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) val joeKeyPair = generateKeyPair() - client.tx { registerAccount(joeId, listOf(joeKeyPair.public.toIrohaPublicKey())) } + val joeId = AccountId(DEFAULT_DOMAIN_ID, joeKeyPair.public.toIrohaPublicKey()) + client.tx { registerAccount(joeId) } QueryBuilder.findAccountById(joeId) .account(super.account) @@ -215,7 +194,7 @@ class InstructionsTest : IrohaTest() { client.tx(joeId, joeKeyPair) { grantPermissionToken( Permissions.CanUnregisterAccount, - joeId.asJsonString(), + joeId.asJsonString(true), ALICE_ACCOUNT_ID, ) unregisterAccount(joeId) @@ -239,11 +218,11 @@ class InstructionsTest : IrohaTest() { @SdkTestId("register_asset_definition") @SdkTestId("unregister_asset_definition") fun `register and unregister asset`(): Unit = runBlocking { - val definitionId = AssetDefinitionId("XSTUSD".asName(), DEFAULT_DOMAIN_ID) - client.tx { registerAssetDefinition(definitionId, AssetValueType.Quantity()) } + val definitionId = AssetDefinitionId(DEFAULT_DOMAIN_ID, "XSTUSD".asName()) + client.tx { registerAssetDefinition(definitionId, AssetType.numeric()) } - val assetId = AssetId(definitionId, ALICE_ACCOUNT_ID) - client.tx { registerAsset(assetId, AssetValue.Quantity(0)) } + val assetId = AssetId(ALICE_ACCOUNT_ID, definitionId) + client.tx { registerAsset(assetId, AssetValue.Numeric(0.asNumeric())) } QueryBuilder.findAssetById(assetId) .account(super.account) @@ -298,15 +277,14 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_account_with_metadata") fun `register account with metadata`(): Unit = runBlocking { - val newAccountId = AccountId(DEFAULT_DOMAIN_ID, "foo".asName()) val addressKey = "address".asName() val phoneKey = "phone".asName() val emailKey = "email".asName() val cityKey = "city".asName() - val addressValue = "address".asValue() - val phoneValue = "phone".asValue() - val emailValue = "email".asValue() - val cityValue = "city".asValue() + val addressValue = "address" + val phoneValue = "phone" + val emailValue = "email" + val cityValue = "city" val metadata = Metadata( mapOf( Pair(addressKey, addressValue), @@ -315,15 +293,12 @@ class InstructionsTest : IrohaTest() { Pair(cityKey, cityValue), ), ) - val encodedTx = TransactionBuilder { + val newAccountId = AccountId(DEFAULT_DOMAIN_ID, generatePublicKey()) + client.sendTransaction { account(super.account) - registerAccount(newAccountId, listOf(), metadata) - }.buildSigned().let { SignedTransaction.encode(it) } - - val decodedTx = encodedTx.let { SignedTransaction.decode(it) } - val signedTx = decodedTx.appendSignatures(ALICE_KEYPAIR) - - client.sendTransaction { signedTx }.also { d -> + registerAccount(newAccountId, metadata) + buildSigned(super.keyPair) + }.also { d -> withTimeout(txTimeout) { d.await() } } @@ -333,11 +308,11 @@ class InstructionsTest : IrohaTest() { .let { query -> client.sendQuery(query) } .also { account -> assertEquals(account.id, newAccountId) } .metadata - assertEquals(4, accountMetadata.map.size) - assertEquals(addressValue, accountMetadata.map[addressKey]) - assertEquals(phoneValue, accountMetadata.map[phoneKey]) - assertEquals(emailValue, accountMetadata.map[emailKey]) - assertEquals(cityValue, accountMetadata.map[cityKey]) + assertEquals(4, accountMetadata.sortedMapOfName.size) + assertEquals(addressValue, accountMetadata.sortedMapOfName[addressKey]) + assertEquals(phoneValue, accountMetadata.sortedMapOfName[phoneKey]) + assertEquals(emailValue, accountMetadata.sortedMapOfName[emailKey]) + assertEquals(cityValue, accountMetadata.sortedMapOfName[cityKey]) } /** @@ -353,7 +328,7 @@ class InstructionsTest : IrohaTest() { fun `register asset`(): Unit = runBlocking { client.sendTransaction { account(super.account) - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) buildSigned(super.keyPair) }.also { d -> withTimeout(txTimeout) { d.await() } @@ -376,12 +351,12 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_asset_definition_with_store_value_type") fun `store asset`(): Unit = runBlocking { - val pair1 = "key1".asName() to "bar".asValue() - val pair2 = "key2".asName() to true.asValue() - val pair3 = "key3".asName() to 12345.asValue() + val pair1 = "key1".asName() to "bar" + val pair2 = "key2".asName() to "true" + val pair3 = "key3".asName() to "12345" client.tx { - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Store()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.Store()) setKeyValue(DEFAULT_ASSET_ID, pair1.first, pair1.second) setKeyValue(DEFAULT_ASSET_ID, pair2.first, pair2.second) setKeyValue(DEFAULT_ASSET_ID, pair3.first, pair3.second) @@ -392,16 +367,13 @@ class InstructionsTest : IrohaTest() { .buildSigned(super.keyPair) val asset = client.sendQuery(findAssetByIdQry) - assertEquals(DEFAULT_ASSET_ID.definitionId.name, asset.id.definitionId.name) - assertEquals(DEFAULT_ASSET_ID.definitionId.domainId, asset.id.definitionId.domainId) + assertEquals(DEFAULT_ASSET_ID.definition.name, asset.id.definition.name) + assertEquals(DEFAULT_ASSET_ID.definition.domain, asset.id.definition.domain) when (val value = asset.value) { is AssetValue.Store -> { - assertEquals(pair1.second.string, value.metadata.map[pair1.first]?.cast()?.string) - assertEquals(pair2.second.bool, value.metadata.map[pair2.first]?.cast()?.bool) - assertEquals( - pair3.second.numericValue, - value.metadata.map[pair3.first]?.cast()?.numericValue, - ) + assertEquals(pair1.second, value.metadata.sortedMapOfName[pair1.first]) + assertEquals(pair2.second, value.metadata.sortedMapOfName[pair2.first]) + assertEquals(pair3.second, value.metadata.sortedMapOfName[pair3.first]) } else -> fail("Expected result asset value has type `AssetValue.Store`, but it was `${asset.value::class.simpleName}`") @@ -413,7 +385,7 @@ class InstructionsTest : IrohaTest() { .buildSigned(super.keyPair) val assetsByDomainName = client.sendQuery(findAssetsByDomainNameQry) assertEquals(1, assetsByDomainName.size) - assertEquals(asset, assetsByDomainName.first()) + assertEquals(asset.id, assetsByDomainName.first().id) } @Test @@ -428,7 +400,7 @@ class InstructionsTest : IrohaTest() { fun `account metadata limit increased`(): Unit = runBlocking { client.tx { // 5000 characters string would be rejected by Iroha with default WSV_ACCOUNT_METADATA_LIMITS config - setKeyValue(ALICE_ACCOUNT_ID, "key".asName(), randomAlphabetic(5000).asValue()) + setKeyValue(ALICE_ACCOUNT_ID, "key".asName(), randomAlphabetic(5000)) } } @@ -439,14 +411,14 @@ class InstructionsTest : IrohaTest() { client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { registerDomain(domainId) grantPermissionToken( - Permissions.CanSetKeyValueInDomain.type.string, + Permissions.CanSetKeyValueInDomain, domainId.asJsonString(), ALICE_ACCOUNT_ID, ) } client.tx(ALICE_ACCOUNT_ID, ALICE_KEYPAIR) { - setKeyValue(domainId, randomAlphabetic(10).asName(), randomAlphabetic(10).asValue()) + setKeyValue(domainId, randomAlphabetic(10).asName(), randomAlphabetic(10)) } } @@ -460,16 +432,16 @@ class InstructionsTest : IrohaTest() { val aliceAssetId = DEFAULT_ASSET_ID client.tx { - registerAssetDefinition(aliceAssetId.definitionId, AssetValueType.Store()) + registerAssetDefinition(aliceAssetId.definition, AssetType.Store()) // grant by Alice to Bob permissions to set key value in Asset.Store grantPermissionToken( - Permissions.CanSetKeyValueUserAssetsToken, - aliceAssetId.asJsonString(), + Permissions.CanSetKeyValueInUserAsset, + aliceAssetId.asJsonString(true), BOB_ACCOUNT_ID, ) } client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - setKeyValue(aliceAssetId, "foo".asName(), "bar".asValue()) + setKeyValue(aliceAssetId, "foo".asName(), "bar") } val query = QueryBuilder.findAssetById(aliceAssetId) @@ -477,20 +449,17 @@ class InstructionsTest : IrohaTest() { .buildSigned(super.keyPair) val asset = client.sendQuery(query) - assertEquals(aliceAssetId.definitionId.name, asset.id.definitionId.name) - assertEquals(aliceAssetId.definitionId.domainId, asset.id.definitionId.domainId) + assertEquals(aliceAssetId.definition.name, asset.id.definition.name) + assertEquals(aliceAssetId.definition.domain, asset.id.definition.domain) when (val value = asset.value) { - is AssetValue.Store -> { - assertEquals("bar", (value.metadata.map["foo".asName()]?.cast())?.string) - } - + is AssetValue.Store -> assertEquals("bar", value.metadata.sortedMapOfName["foo".asName()]) else -> fail("Expected result asset value has type `AssetValue.Store`, but it was `${asset.value::class.simpleName}`") } client.tx { revokeSetKeyValueAsset(aliceAssetId, BOB_ACCOUNT_ID) } - QueryBuilder.findPermissionTokensByAccountId(BOB_ACCOUNT_ID) + QueryBuilder.findPermissionsByAccountId(BOB_ACCOUNT_ID) .account(BOB_ACCOUNT_ID) .buildSigned(BOB_KEYPAIR) .let { client.sendQuery(it) } @@ -510,83 +479,42 @@ class InstructionsTest : IrohaTest() { fun `mint asset`(): Unit = runBlocking { client.sendTransaction { account(super.account) - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) mintAsset(DEFAULT_ASSET_ID, 5) buildSigned(super.keyPair) }.also { d -> withTimeout(txTimeout) { d.await() } } - QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) + QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(super.account) .buildSigned(super.keyPair) .let { query -> client.sendQuery(query) } .also { result -> - assertEquals(5, result.assets[DEFAULT_ASSET_ID]?.value?.cast()?.u32) + assertEquals(5, result.get(DEFAULT_ASSET_ID)?.value?.cast()?.numeric?.asInt()) } } // #endregion java_mint_asset @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Assets") @Story("Account burns an asset") @Permission("no_permission_required") @SdkTestId("burn_asset_for_account_in_same_domain") fun `burn asset`(): Unit = runBlocking { // check balance before burn - val query = QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) + val query = QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(super.account) .buildSigned(super.keyPair) var result = client.sendQuery(query) - assertEquals(100, result.assets[DEFAULT_ASSET_ID]?.value?.cast()?.u32) + assertEquals(100, result.get(DEFAULT_ASSET_ID)?.value?.cast()?.numeric?.asInt()) client.tx { burnAsset(DEFAULT_ASSET_ID, 50) } // check balance after burn result = client.sendQuery(query) - assertEquals(50, result.assets[DEFAULT_ASSET_ID]?.value?.cast()?.u32) - } - - @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) - @Feature("Assets") - @Story("Account burns an asset") - @Permission("no_permission_required") - @SdkTestId("burn_asset_for_account_in_same_domain") - fun `multi signature transaction`(): Unit = runBlocking { - val newBobKeyPair = generateKeyPair() - val newBobPublicKey = newBobKeyPair.public.toIrohaPublicKey() - - client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - mintSignatureCheckCondition( - BOB_ACCOUNT_ID, - SignatureCheckCondition.AllAccountSignaturesAnd(listOf()), - ) - mintPublicKey(BOB_ACCOUNT_ID, newBobPublicKey) - } - - val keyToSuccess = randomAlphabetic(5).asName() - val valueToSuccess = randomAlphabetic(5).asValue() - - val time = Instant.now().toEpochMilli().toBigInteger() - val tx = TransactionBuilder { - creationTimeMillis = time - account(BOB_ACCOUNT_ID) - setKeyValue(BOB_ACCOUNT_ID, keyToSuccess, valueToSuccess) - } - client.fireAndForget { tx.buildSigned(BOB_KEYPAIR) } - delay(1000) - client.sendTransaction { tx.buildSigned(newBobKeyPair) }.also { - withTimeout(txTimeout) { it.await() } - } - // TODO: request /pending_transactions and extract our tx - - val bob = QueryBuilder.findAccountById(BOB_ACCOUNT_ID) - .account(BOB_ACCOUNT_ID) - .buildSigned(BOB_KEYPAIR) - .let { client.sendQuery(it) } - assertEquals(bob.metadata.map[keyToSuccess], valueToSuccess) + assertEquals(50, result.get(DEFAULT_ASSET_ID)?.value?.cast()?.numeric?.asInt()) } @Test @@ -597,7 +525,7 @@ class InstructionsTest : IrohaTest() { @SdkTestId("burn_other_user_xasset") fun `burn other user asset`(): Unit = runBlocking { client.tx { - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) mintAsset(DEFAULT_ASSET_ID, 100) grantPermissionToken( Permissions.CanBurnAssetWithDefinition, @@ -607,92 +535,18 @@ class InstructionsTest : IrohaTest() { } client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { burnAsset(DEFAULT_ASSET_ID, 50) } - val result = QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) + val result = QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(super.account) .buildSigned(super.keyPair) .let { query -> client.sendQuery(query) } - assertEquals(50, result.assets[DEFAULT_ASSET_ID]?.value?.cast()?.u32) - } - - @Test - @WithIroha([AliceAndBobHasPermissionToMintPublicKeys::class]) - @Feature("Accounts") - @Story("Account burns a public key") - @Permission("no_permission_required") - @SdkTestId("burn_one_of_several_public_keys") - fun `burn public key`(): Unit = runBlocking { - // mint public key, because needs at least 2 public keys to burn one of them - client.tx { mintPublicKey(ALICE_ACCOUNT_ID, generateKeyPair().public.toIrohaPublicKey()) } - - val alicePubKey = ALICE_KEYPAIR.public.toIrohaPublicKey() - // check public key before burn it - val query = QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) - .account(super.account) - .buildSigned(super.keyPair) - val signatories = client.sendQuery(query).signatories - - assertEquals(2, signatories.size) - assertTrue { - signatories.any { s -> - s.payload.contentEquals(alicePubKey.payload) - } - } - client.tx { burnPublicKey(ALICE_ACCOUNT_ID, alicePubKey) } - - // if keys was burned, then peer should return an error due cannot verify signature - assertFails { client.sendQuery(query) } - } - - @Test - @WithIroha([AliceAndBobHasPermissionToMintPublicKeys::class]) - @Feature("Accounts") - @Story("Account mints a public key") - @Permission("no_permission_required") - @SdkTestId("mint_public_key_after_burning_one_public_key") - fun `burn and mint public key`(): Unit = runBlocking { - val keyPair = generateKeyPair() - - // mint public key, because needs at least 2 public keys to burn one of them - client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - mintPublicKey(BOB_ACCOUNT_ID, keyPair.public.toIrohaPublicKey()) - } - // check Bob's public key before burn it - val bobPubKey = keyPair.public.toIrohaPublicKey() - var query = QueryBuilder.findAccountById(BOB_ACCOUNT_ID) - .account(super.account) - .buildSigned(super.keyPair) - var signatories = client.sendQuery(query).signatories - assertEquals(2, signatories.size) - - // burn Bob's public key - client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { burnPublicKey(BOB_ACCOUNT_ID, bobPubKey) } - - // check Bob's account has only 1 public key (was 2) - query = QueryBuilder.findAccountById(BOB_ACCOUNT_ID) - .account(super.account) - .buildSigned(super.keyPair) - signatories = client.sendQuery(query).signatories - assertEquals(1, signatories.size) - - // generate new key pair without salt for Bob's account - val newKeyPair = generateKeyPair() - - // change Bob's account public key - client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { mintPublicKey(BOB_ACCOUNT_ID, newKeyPair.public.toIrohaPublicKey()) } - - // check public keys in Bob's account - val newPubKeyQuery = QueryBuilder.findAccountById(BOB_ACCOUNT_ID) - .account(super.account) - .buildSigned(super.keyPair) - val signatoriesWithNewPubKey = client.sendQuery(newPubKeyQuery).signatories - assertEquals(2, signatoriesWithNewPubKey.size) + assertEquals(50, result.get(DEFAULT_ASSET_ID)?.value?.cast()?.numeric?.asInt()) } @Test @WithIroha([DefaultGenesis::class]) @Feature("Accounts") @Story("Account changes account metadata") - @Permission("CanSetKeyValueInUserAccount") + @Permission("CanSetKeyValueInAccount") @SdkTestId("change_account_metadata_by_granted_account") fun `change user account metadata`(): Unit = runBlocking { val saltKey = "salt" @@ -701,8 +555,8 @@ class InstructionsTest : IrohaTest() { client.sendTransaction { account(BOB_ACCOUNT_ID) grantPermissionToken( - Permissions.CanSetKeyValueInUserAccount, - BOB_ACCOUNT_ID.asJsonString(), + Permissions.CanSetKeyValueInAccount, + BOB_ACCOUNT_ID.asJsonString(true), ALICE_ACCOUNT_ID, ) buildSigned(BOB_KEYPAIR) @@ -711,7 +565,7 @@ class InstructionsTest : IrohaTest() { } // add/update salt value in Bob's account metadata - val salt = randomAlphabetic(10).asValue() + val salt = randomAlphabetic(10) client.tx { setKeyValue(BOB_ACCOUNT_ID, saltKey.asName(), salt) } // check new metadata in Bob's account @@ -719,7 +573,7 @@ class InstructionsTest : IrohaTest() { .account(super.account) .buildSigned(super.keyPair) val bobAccountMetadata = client.sendQuery(saltQuery).metadata - assertEquals(salt, bobAccountMetadata.map["salt".asName()]) + assertEquals(salt, bobAccountMetadata.sortedMapOfName["salt".asName()]) } @Test @@ -732,117 +586,32 @@ class InstructionsTest : IrohaTest() { val aliceAssetId = DEFAULT_ASSET_ID val bobAssetId = AliceAndBobEachHave100Xor.BOB_ASSET_ID - assertEquals(100, getAccountAmount(ALICE_ACCOUNT_ID, aliceAssetId)) - assertEquals(100, getAccountAmount(BOB_ACCOUNT_ID, bobAssetId)) + assertEquals(100, getAccountAmount(aliceAssetId)) + assertEquals(100, getAccountAmount(bobAssetId)) client.tx { transferAsset(aliceAssetId, 40, BOB_ACCOUNT_ID) } - assertEquals(60, getAccountAmount(ALICE_ACCOUNT_ID, aliceAssetId)) - assertEquals(140, getAccountAmount(BOB_ACCOUNT_ID, bobAssetId)) + assertEquals(60, getAccountAmount(aliceAssetId)) + assertEquals(140, getAccountAmount(bobAssetId)) client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { transferAsset(bobAssetId, 40, ALICE_ACCOUNT_ID) } - assertEquals(100, getAccountAmount(ALICE_ACCOUNT_ID, aliceAssetId)) - assertEquals(100, getAccountAmount(BOB_ACCOUNT_ID, bobAssetId)) + assertEquals(100, getAccountAmount(aliceAssetId)) + assertEquals(100, getAccountAmount(bobAssetId)) val joeDomain = "joe_domain".asDomainId() client.tx { registerDomain(joeDomain) } - val joeId = AccountId(joeDomain, "joe".asName()) val joeKeyPair = generateKeyPair() - registerAccount(joeId, joeKeyPair.public.toIrohaPublicKey()) + val joeId = AccountId(joeDomain, joeKeyPair.public.toIrohaPublicKey()) + registerAccount(joeId) client.tx { - grantPermissionToken( - Permissions.CanTransferUserAssetsToken, - aliceAssetId.asJsonString(), - joeId, - ) + grantPermissionToken(Permissions.CanTransferUserAssetsToken, aliceAssetId.asJsonString(true), joeId) } client.tx(account = joeId, joeKeyPair) { transferAsset(aliceAssetId, 40, BOB_ACCOUNT_ID) } - assertEquals(60, getAccountAmount(ALICE_ACCOUNT_ID, aliceAssetId)) - assertEquals(140, getAccountAmount(BOB_ACCOUNT_ID, bobAssetId)) - } - - @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) - @Feature("Assets") - @Story("Account burns an asset") - @Permission("no_permission_required") - @SdkTestId("burn_asset_if_condition") - @SdkTestId("not_burn_asset_if_condition_not_met") - fun `burn if condition otherwise not burn`(): Unit = runBlocking { - val toBurn = 80 - val initAliceAmount = getAccountAmount() - - sendTransactionToBurnIfCondition(initAliceAmount >= toBurn, DEFAULT_ASSET_ID, toBurn) - val aliceAmountAfterBurn = getAccountAmount() - assert(aliceAmountAfterBurn == initAliceAmount - toBurn) - - sendTransactionToBurnIfCondition(aliceAmountAfterBurn >= toBurn, DEFAULT_ASSET_ID, toBurn) - val finalAliceAmount = getAccountAmount() - assert(finalAliceAmount == aliceAmountAfterBurn) - } - - @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) - @Feature("Atomicity") - @Story("Client sends a pair instructions within transaction") - @Permission("no_permission_required") - @SdkTestId("pair_instruction") - fun `pair`(): Unit = runBlocking { - client.sendTransaction { - account(super.account) - pair( - Instructions.burnAsset(DEFAULT_ASSET_ID, 10), - Instructions.burnAsset(DEFAULT_ASSET_ID, 20), - ) - buildSigned(super.keyPair) - }.also { d -> - withTimeout(txTimeout) { d.await() } - } - - assert(getAccountAmount() == 70L) - } - - @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) - @Feature("Atomicity") - @Story("Client sends a multiple instructions within transaction") - @Permission("no_permission_required") - @SdkTestId("multiple_instructions_within_transaction") - fun `instruction sequence committed`(): Unit = runBlocking { - client.sendTransaction { - account(super.account) - sequence( - Instructions.burnAsset(DEFAULT_ASSET_ID, 10), - Instructions.burnAsset(DEFAULT_ASSET_ID, 20), - Instructions.burnAsset(DEFAULT_ASSET_ID, 30), - ) - buildSigned(super.keyPair) - }.also { d -> - withTimeout(txTimeout) { d.await() } - } - - assert(getAccountAmount() == 40L) - } - - @Test - @WithIroha([DefaultGenesis::class]) - @Feature("Atomicity") - @Story("Client sends a wrong instruction in transaction") - @Permission("no_permission_required") - @SdkTestId("instruction_failed") - fun `instruction failed`(): Unit = runBlocking { - client.sendTransaction { - account(super.account) - fail("FAIL MESSAGE") - buildSigned(super.keyPair) - }.also { d -> - assertFailsWith { - withTimeout(txTimeout) { d.await() } - } - } + assertEquals(60, getAccountAmount(aliceAssetId)) + assertEquals(140, getAccountAmount(bobAssetId)) } @Test @@ -856,14 +625,12 @@ class InstructionsTest : IrohaTest() { val assetKey = StoreAssetWithMetadata.ASSET_KEY val assetBefore = getAsset(assetId) - assertEquals( - StoreAssetWithMetadata.ASSET_VALUE, - assetBefore.value.cast().metadata.map[assetKey], - ) + val value = assetBefore.value.cast().metadata.sortedMapOfName[assetKey]?.fromJsonString() + assertEquals(StoreAssetWithMetadata.ASSET_VALUE, value) client.tx { removeKeyValue(assetId, assetKey) } val assetAfter = getAsset(assetId) - assert(assetAfter.value.cast().metadata.map.isEmpty()) + assert(assetAfter.value.cast().metadata.sortedMapOfName.isEmpty()) } @Test @@ -877,7 +644,7 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("burn_fixed_asset") fun `check assets with type Fixed are properly minted and burned`(): Unit = runBlocking { - client.tx { registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Fixed()) } + client.tx { registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) } // counter to track all changes in balance var counter = BigDecimal.ZERO @@ -901,15 +668,14 @@ class InstructionsTest : IrohaTest() { counter -= it } val assertBalance: suspend (BigDecimal) -> Unit = { expectedBalance -> - QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) + QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(super.account) .buildSigned(super.keyPair) .let { query -> client.sendQuery(query) } - .let { account -> account.assets[DEFAULT_ASSET_ID]?.value } + .let { account -> account.get(DEFAULT_ASSET_ID)?.value } .let { value -> - value?.cast()?.fixed?.fixedPointOfI64 ?: BigDecimal.ZERO - } - .also { actualBalance -> + value?.cast()?.numeric?.asBigDecimal() ?: BigDecimal.ZERO + }.also { actualBalance -> assertTrue("expected value `$expectedBalance`, but was `$actualBalance`") { expectedBalance.compareTo(actualBalance) == 0 } @@ -935,12 +701,12 @@ class InstructionsTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_asset_definition_with_metadata") fun `register asset with metadata`(): Unit = runBlocking { - val assetKey = Name("asset_metadata_key") - val assetValue = Value.String("some string value") + val assetKey = "asset_metadata_key".asName() + val assetValue = "some string value" val metadata = Metadata(mapOf(assetKey to assetValue)) client.tx { - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Store(), metadata) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.Store(), metadata) } QueryBuilder.findAssetDefinitionKeyValueByIdAndKey(DEFAULT_ASSET_DEFINITION_ID, assetKey) @@ -948,58 +714,10 @@ class InstructionsTest : IrohaTest() { .buildSigned(super.keyPair) .let { query -> client.sendQuery(query) } .also { value -> - Assertions.assertEquals( - value.cast().string, - assetValue.string, - ) + Assertions.assertEquals(value, assetValue) } } - @Test - @WithIroha([DefaultGenesis::class], fetchSize = 111) - fun `iroha respond with given fetch size`(): Unit = runBlocking { - val fetchSize = 111 - repeat(2) { i -> - val isi = mutableListOf() - val tx = TransactionBuilder { - account(ALICE_ACCOUNT_ID) - } - repeat(100) { j -> - val definitionId = AssetDefinitionId("ASSET_${j}_$i".asName(), DEFAULT_DOMAIN_ID) - isi.add(Instructions.registerAssetDefinition(definitionId, AssetValueType.Store())) - isi.add( - Instructions.setKeyValue( - AssetId(definitionId, ALICE_ACCOUNT_ID), - randomAlphabetic(10).asName(), - randomAlphabetic(100).asValue(), - ), - ) - } - tx.instructions(isi) - - client.sendTransaction { tx.buildSigned(ALICE_KEYPAIR) }.let { - withTimeout(txTimeout) { - it.await() - } - } - } - - val query = QueryBuilder.findAllAssets() - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - val method = Iroha2Client::class.declaredMemberFunctions.firstOrNull { it.name == "sendQueryRequest" } - - val response = method?.let { - it.isAccessible = true - it.callSuspend(client, query, null, null, null, null) - } - val vec = response?.cast()?.batchedResponseV1OfValue - ?.cast()?.batch - ?.cast()?.vec - - assertEquals(fetchSize, vec?.size) - } - @Test @WithIroha([DefaultGenesis::class]) @Feature("Domains") @@ -1029,26 +747,16 @@ class InstructionsTest : IrohaTest() { @Feature("Accounts") @SdkTestId("set_key_value_in_foreign_asset_after_granting_role") fun `register and grant role to account and then revoke it`(): Unit = runBlocking { - val assetId = AssetId(DEFAULT_ASSET_DEFINITION_ID, BOB_ACCOUNT_ID) + val assetId = AssetId(BOB_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID) client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Store()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.Store()) } val roleId = RoleId("BOB_ASSET_ACCESS".asName()) client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - registerRole( - roleId, - PermissionToken( - Permissions.CanSetKeyValueUserAssetsToken.type, - assetId.asStringWithJson(), - ), - PermissionToken( - Permissions.CanRemoveKeyValueInUserAssets.type, - assetId.asStringWithJson(), - ), - ) + registerRole(roleId) grantRole(roleId, ALICE_ACCOUNT_ID) - setKeyValue(assetId, "key".asName(), "value".asValue()) + setKeyValue(assetId, "key".asName(), "value") } QueryBuilder.findAssetById(assetId) @@ -1058,8 +766,8 @@ class InstructionsTest : IrohaTest() { .also { asset -> assertTrue( asset.value.cast() - .metadata.map - .containsValue("value".asValue()), + .metadata.sortedMapOfName + .containsValue("value"), ) } @@ -1080,7 +788,7 @@ class InstructionsTest : IrohaTest() { .buildSigned(BOB_KEYPAIR) .let { query -> client.sendQuery(query) } .firstOrNull { it.id == roleId } - .also { assertNotNull(it) } + .also { Assertions.assertNotNull(it) } client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { unregisterRole(roleId) @@ -1090,14 +798,14 @@ class InstructionsTest : IrohaTest() { .buildSigned(BOB_KEYPAIR) .let { query -> client.sendQuery(query) } .firstOrNull { it.id == roleId } - .also { assertNull(it) } + .also { Assertions.assertNull(it) } } @Test @WithIroha( [ DefaultGenesis::class, - AliceHas100XorAndPermissionToBurn::class, + AliceHas100XorAndPermissionToMintAndBurn::class, StoreAssetWithMetadata::class, AliceHasRoleWithAccessToBobsMetadata::class, AliceWithTestAssets::class, @@ -1117,7 +825,7 @@ class InstructionsTest : IrohaTest() { val assetBefore = getAsset(assetId) assertEquals( StoreAssetWithMetadata.ASSET_VALUE, - assetBefore.value.cast().metadata.map[assetKey], + assetBefore.value.cast().metadata.sortedMapOfName[assetKey]?.fromJsonString(), ) QueryBuilder.findAccountById(ALICE_ACCOUNT_ID) .account(super.account) @@ -1125,8 +833,8 @@ class InstructionsTest : IrohaTest() { .let { query -> client.sendQuery(query) } .also { alice -> assertEquals( - alice.metadata.map[RubbishToTestMultipleGenesis.ALICE_KEY_VALUE.asName()], - RubbishToTestMultipleGenesis.ALICE_KEY_VALUE.asValue(), + RubbishToTestMultipleGenesis.ALICE_KEY_VALUE, + alice.metadata.sortedMapOfName[RubbishToTestMultipleGenesis.ALICE_KEY_VALUE.asName()]?.fromJsonString(), ) } QueryBuilder.findAccountById(BOB_ACCOUNT_ID) @@ -1135,8 +843,8 @@ class InstructionsTest : IrohaTest() { .let { query -> client.sendQuery(query) } .also { bob -> assertEquals( - bob.metadata.map[RubbishToTestMultipleGenesis.BOB_KEY_VALUE.asName()], - RubbishToTestMultipleGenesis.BOB_KEY_VALUE.asValue(), + RubbishToTestMultipleGenesis.BOB_KEY_VALUE, + bob.metadata.sortedMapOfName[RubbishToTestMultipleGenesis.BOB_KEY_VALUE.asName()]?.fromJsonString(), ) } QueryBuilder.findDomainById(DEFAULT_DOMAIN_ID) @@ -1145,8 +853,8 @@ class InstructionsTest : IrohaTest() { .let { query -> client.sendQuery(query) } .also { domain -> assertEquals( - domain.metadata.map[RubbishToTestMultipleGenesis.DOMAIN_KEY_VALUE.asName()], - RubbishToTestMultipleGenesis.DOMAIN_KEY_VALUE.asValue(), + RubbishToTestMultipleGenesis.DOMAIN_KEY_VALUE, + domain.metadata.sortedMapOfName[RubbishToTestMultipleGenesis.DOMAIN_KEY_VALUE.asName()]?.fromJsonString(), ) } } @@ -1158,7 +866,7 @@ class InstructionsTest : IrohaTest() { @SdkTestId("transfer_domain_ownership_in_genesis") fun `transfer domain ownership in genesis`(): Unit = runBlocking { val key = randomAlphabetic(5).asName() - val value = randomAlphabetic(5).asValue() + val value = randomAlphabetic(5) client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { setKeyValue(WithDomainTransferredToBob.DOMAIN_ID, key, value) } @@ -1166,8 +874,8 @@ class InstructionsTest : IrohaTest() { .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } - .metadata.map[key] - assertEquals(value.string, extractedValue?.cast()?.string) + .metadata.sortedMapOfName[key] + assertEquals(value, extractedValue) } @Test @@ -1181,7 +889,7 @@ class InstructionsTest : IrohaTest() { assertFailsWith(TransactionRejectedException::class) { client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { - setKeyValue(domainId, randomAlphabetic(5).asName(), randomAlphabetic(5).asValue()) + setKeyValue(domainId, randomAlphabetic(5).asName(), randomAlphabetic(5)) } } var kingdomDomainOwnedBy = QueryBuilder.findDomainById(domainId) @@ -1191,7 +899,7 @@ class InstructionsTest : IrohaTest() { assertEquals(ALICE_ACCOUNT_ID, kingdomDomainOwnedBy) client.tx(ALICE_ACCOUNT_ID, ALICE_KEYPAIR) { - transferDomainOwnership(ALICE_ACCOUNT_ID, IdBox.DomainId(domainId), BOB_ACCOUNT_ID) + transferDomainOwnership(ALICE_ACCOUNT_ID, domainId, BOB_ACCOUNT_ID) } kingdomDomainOwnedBy = QueryBuilder.findDomainById(domainId) .account(ALICE_ACCOUNT_ID) @@ -1200,15 +908,15 @@ class InstructionsTest : IrohaTest() { assertEquals(BOB_ACCOUNT_ID, kingdomDomainOwnedBy) val key = randomAlphabetic(5).asName() - val value = randomAlphabetic(5).asValue() + val value = randomAlphabetic(5) client.tx(BOB_ACCOUNT_ID, BOB_KEYPAIR) { setKeyValue(domainId, key, value) } val extractedValue = QueryBuilder.findDomainById(domainId) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } - .metadata.map[key] - assertEquals(value.string, extractedValue?.cast()?.string) + .metadata.sortedMapOfName[key] + assertEquals(value, extractedValue) } @Test @@ -1222,42 +930,26 @@ class InstructionsTest : IrohaTest() { .also { accounts -> assert(accounts.any { it.id == BOB_ACCOUNT_ID }) } } - private suspend fun registerAccount(id: AccountId, publicKey: PublicKey) { + private suspend fun registerAccount(id: AccountId) { client.sendTransaction { account(super.account) - registerAccount(id, listOf(publicKey)) + registerAccount(id) buildSigned(super.keyPair) }.also { d -> withTimeout(txTimeout) { d.await() } } } - private suspend fun getAccountAmount( - accountId: AccountId = ALICE_ACCOUNT_ID, - assetId: AssetId = DEFAULT_ASSET_ID, - ) = QueryBuilder.findAccountById(accountId) + private suspend fun getAccountAmount(assetId: AssetId = DEFAULT_ASSET_ID) = QueryBuilder + .findAssetById(assetId) .account(super.account) .buildSigned(super.keyPair) .let { query -> - client.sendQuery(query).assets[assetId]?.value + client.sendQuery(query).value }.let { value -> - (value as? AssetValue.Quantity)?.u32 ?: 0 + (value as? AssetValue.Numeric)?.numeric?.asLong() ?: 0 } - private suspend fun sendTransactionToBurnIfCondition(condition: Boolean, assetId: AssetId, toBurn: Int) { - client.sendTransaction { - account(super.account) - `if`( - condition = condition, - then = Instructions.burnAsset(assetId, toBurn), - otherwise = Instructions.burnAsset(assetId, 0), - ) - buildSigned(super.keyPair) - }.also { d -> - withTimeout(txTimeout) { d.await() } - } - } - private suspend fun getAsset(assetId: AssetId? = null) = QueryBuilder .findAssetById(assetId ?: DEFAULT_ASSET_ID) .account(super.account) @@ -1265,4 +957,6 @@ class InstructionsTest : IrohaTest() { .let { query -> client.sendQuery(query) } + + private fun List.get(id: AssetId) = this.find { it.id == id } } diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/PeerTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/PeerTest.kt index d0dd08ce9..ece88ac9e 100644 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/PeerTest.kt +++ b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/PeerTest.kt @@ -7,6 +7,7 @@ import jp.co.soramitsu.iroha2.annotations.Permission import jp.co.soramitsu.iroha2.annotations.Sdk import jp.co.soramitsu.iroha2.annotations.SdkTestId import jp.co.soramitsu.iroha2.client.Iroha2Client +import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.DomainId import jp.co.soramitsu.iroha2.generated.PeerId import jp.co.soramitsu.iroha2.generated.SocketAddr @@ -17,26 +18,31 @@ import jp.co.soramitsu.iroha2.testengine.ALICE_KEYPAIR import jp.co.soramitsu.iroha2.testengine.AliceCanUnregisterAnyPeer import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID import jp.co.soramitsu.iroha2.testengine.DefaultGenesis +import jp.co.soramitsu.iroha2.testengine.IrohaConfig import jp.co.soramitsu.iroha2.testengine.IrohaContainer import jp.co.soramitsu.iroha2.testengine.IrohaTest import jp.co.soramitsu.iroha2.testengine.WithIroha +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.time.withTimeout +import kotlinx.coroutines.withContext import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.Timeout import java.security.KeyPair import java.time.Duration -import kotlin.reflect.full.createInstance import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue -@Timeout(100) +@Timeout(1000) @Owner("akostyuchenko") @Sdk("Java/Kotlin") @Feature("Peers") +@Disabled // https://github.com/hyperledger/iroha/issues/4999 class PeerTest : IrohaTest() { companion object { @@ -49,16 +55,22 @@ class PeerTest : IrohaTest() { @Permission("no_permission_required") @SdkTestId("register_peer") fun `register peer`(): Unit = runBlocking { - val p2pPort = DEFAULT_P2P_PORT + val p2pPort = DEFAULT_P2P_PORT + PEER_AMOUNT val alias = "iroha$p2pPort" val address = "$alias:$p2pPort" val keyPair = generateKeyPair() val payload = keyPair.public.bytes() - startNewContainer(keyPair, alias).use { - registerPeer(address, payload) - assertTrue(isPeerAvailable(address, payload)) + val containerJob = async { + startNewContainer(keyPair, alias, PEER_AMOUNT) + } + val registerJob = async { + registerPeer(PeerId(SocketAddr.Host(SocketAddrHost(address, p2pPort)), keyPair.public.toIrohaPublicKey())) } + containerJob.await() + registerJob.await() + + assertTrue(isPeerAvailable(address, payload)) } @Disabled // https://app.zenhub.com/workspaces/iroha-v2-60ddb820813b9100181fc060/issues/gh/hyperledger/iroha-java/372 @@ -74,11 +86,11 @@ class PeerTest : IrohaTest() { val keyPair = generateKeyPair() val payload = keyPair.public.bytes() - startNewContainer(keyPair, alias).use { - registerPeer(address, payload) + startNewContainer(keyPair, alias, PEER_AMOUNT).use { + registerPeer(PeerId(SocketAddr.Host(SocketAddrHost(address, p2pPort)), keyPair.public.toIrohaPublicKey())) repeat(PEER_AMOUNT) { assertTrue(isPeerAvailable(address, payload)) } - unregisterPeer(address, payload) + unregisterPeer(PeerId(SocketAddr.Host(SocketAddrHost(address, p2pPort)), keyPair.public.toIrohaPublicKey())) repeat(PEER_AMOUNT) { assertFalse(isPeerAvailable(address, payload)) } } } @@ -92,8 +104,8 @@ class PeerTest : IrohaTest() { val keyPair = generateKeyPair() val payload = keyPair.public.bytes() - startNewContainer(keyPair, alias).use { container -> - registerPeer(address, payload) + startNewContainer(keyPair, alias, PEER_AMOUNT).use { container -> + registerPeer(PeerId(SocketAddr.Host(SocketAddrHost(address, p2pPort)), keyPair.public.toIrohaPublicKey())) assertTrue(isPeerAvailable(address, payload)) delay(5000) @@ -112,7 +124,6 @@ class PeerTest : IrohaTest() { .let { Iroha2Client( container.getApiUrl(), - container.getTelemetryUrl(), container.getP2pUrl(), ).sendQuery(it) } @@ -132,18 +143,24 @@ class PeerTest : IrohaTest() { } } - private fun startNewContainer( + private suspend fun startNewContainer( keyPair: KeyPair, alias: String, - ): IrohaContainer { - return IrohaContainer { + amount: Int, + ): IrohaContainer = coroutineScope { + IrohaContainer { this.waitStrategy = false this.keyPair = keyPair this.alias = alias this.networkToJoin = containers.first().network ?: throw IrohaSdkException("Container network not found") - this.genesis = DefaultGenesis::class.createInstance() + this.submitGenesis = false + this.ports = listOf(DEFAULT_P2P_PORT + amount, DEFAULT_API_PORT + amount) this.trustedPeers = containers.map { it.extractPeerId() } - }.also { it.start() } + }.also { + withContext(Dispatchers.IO) { + it.start() + } + } } private suspend fun isPeerAvailable( @@ -163,13 +180,12 @@ class PeerTest : IrohaTest() { } private suspend fun unregisterPeer( - address: String, - payload: ByteArray, + peerId: PeerId, keyPair: KeyPair = ALICE_KEYPAIR, ) { client.sendTransaction { account(ALICE_ACCOUNT_ID) - unregisterPeer(address, payload) + unregisterPeer(peerId) buildSigned(keyPair) }.also { d -> withTimeout(txTimeout.plus(Duration.ofSeconds(20))) { d.await() } @@ -177,13 +193,13 @@ class PeerTest : IrohaTest() { } private suspend fun registerPeer( - address: String, - payload: ByteArray, + peerId: PeerId, + account: AccountId = ALICE_ACCOUNT_ID, keyPair: KeyPair = ALICE_KEYPAIR, ) { client.sendTransaction { - account(ALICE_ACCOUNT_ID) - registerPeer(address, payload) + account(account) + registerPeer(peerId) buildSigned(keyPair) }.also { d -> withTimeout(txTimeout.plus(Duration.ofSeconds(20))) { d.await() } @@ -191,7 +207,12 @@ class PeerTest : IrohaTest() { } private fun IrohaContainer.extractPeerId() = PeerId( - SocketAddr.Host(SocketAddrHost(this.getP2pUrl().host, this.getP2pUrl().port)), + SocketAddr.Host( + SocketAddrHost( + this.config.alias, + this.config.ports[IrohaConfig.P2P_PORT_IDX], + ), + ), this.config.keyPair.public.toIrohaPublicKey(), ) 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 3799c164a..d810f0e71 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 @@ -10,34 +10,29 @@ import jp.co.soramitsu.iroha2.annotations.SdkTestId import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.generated.AccountId 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.InstructionExpr +import jp.co.soramitsu.iroha2.generated.AssetType +import jp.co.soramitsu.iroha2.generated.DomainId +import jp.co.soramitsu.iroha2.generated.InstructionBox import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name +import jp.co.soramitsu.iroha2.generated.RegisterBox 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.query.QueryBuilder import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_ID -import jp.co.soramitsu.iroha2.testengine.ALICE_ACCOUNT_NAME import jp.co.soramitsu.iroha2.testengine.ALICE_KEYPAIR -import jp.co.soramitsu.iroha2.testengine.AliceAndBobHasPermissionToMintPublicKeys +import jp.co.soramitsu.iroha2.testengine.ALICE_PUBLIC_KEY import jp.co.soramitsu.iroha2.testengine.AliceCanMintXor -import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToBurn +import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToMintAndBurn import jp.co.soramitsu.iroha2.testengine.AliceHasRoleWithAccessToBobsMetadata import jp.co.soramitsu.iroha2.testengine.AliceWithTestAssets import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT_ID -import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT_NAME -import jp.co.soramitsu.iroha2.testengine.BOB_KEYPAIR +import jp.co.soramitsu.iroha2.testengine.BOB_PUBLIC_KEY import jp.co.soramitsu.iroha2.testengine.DEFAULT_ASSET_DEFINITION_ID import jp.co.soramitsu.iroha2.testengine.DEFAULT_ASSET_ID import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID import jp.co.soramitsu.iroha2.testengine.DefaultGenesis +import jp.co.soramitsu.iroha2.testengine.IROHA_CONFIG_DELIMITER import jp.co.soramitsu.iroha2.testengine.IrohaTest import jp.co.soramitsu.iroha2.testengine.NewAccountWithMetadata import jp.co.soramitsu.iroha2.testengine.NewDomain @@ -55,6 +50,8 @@ import kotlinx.coroutines.time.withTimeout import org.apache.commons.lang3.RandomStringUtils import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import java.math.BigInteger +import java.security.KeyPair import java.time.Instant import kotlin.test.assertContains import kotlin.test.assertContentEquals @@ -67,34 +64,7 @@ import kotlin.test.assertTrue class QueriesTest : IrohaTest() { @Test - @WithIroha([AliceAndBobHasPermissionToMintPublicKeys::class]) - @Feature("Accounts") - @Story("Account sets key value pair") - @Permission("CanSetKeyValueInUserAsset") - @SdkTestId("query_permission_tokens_by_accountId") - fun `query permission tokens by accountId`(): Unit = runBlocking { - val permissionsBefore = QueryBuilder.findPermissionTokensByAccountId(BOB_ACCOUNT_ID) - .account(BOB_ACCOUNT_ID) - .buildSigned(BOB_KEYPAIR) - .let { query -> client.sendQuery(query) } - assertEquals(1, permissionsBefore.size) - - client.tx(ALICE_ACCOUNT_ID, ALICE_KEYPAIR) { - grantPermissionToken( - Permissions.CanSetKeyValueInUserAccount, - ALICE_ACCOUNT_ID.asJsonString(), - BOB_ACCOUNT_ID, - ) - } - val permissionsAfter = QueryBuilder.findPermissionTokensByAccountId(BOB_ACCOUNT_ID) - .account(BOB_ACCOUNT_ID) - .buildSigned(BOB_KEYPAIR) - .let { query -> client.sendQuery(query) } - assertEquals(2, permissionsAfter.size) - } - - @Test - @WithIroha([NewAccountWithMetadata::class]) + @WithIroha([NewAccountWithMetadata::class], configs = ["LOG_LEVEL${IROHA_CONFIG_DELIMITER}TRACE"]) @Feature("Accounts") @Query("FindAllAccounts") @Story("Account queries all accounts") @@ -106,8 +76,8 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { accounts -> - assert(accounts.any { it.id.name == ALICE_ACCOUNT_NAME }) - assert(accounts.any { it.id.name == NewAccountWithMetadata.ACCOUNT_NAME }) + assert(accounts.any { it.id.signatory == ALICE_PUBLIC_KEY }) + assert(accounts.any { it.id.signatory == NewAccountWithMetadata.ACCOUNT_ID.signatory }) } } @@ -119,8 +89,8 @@ class QueriesTest : IrohaTest() { @SdkTestId("find_all_accounts_with_filter") fun `find all accounts with filter`(): Unit = runBlocking { val filter = QueryFilters.or( - StringPredicate.Is("alice@wonderland"), - StringPredicate.Is("bob@wonderland"), + StringPredicate.Is("ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"), + StringPredicate.Is("ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland"), ) QueryBuilder.findAllAccounts(filter) .account(ALICE_ACCOUNT_ID) @@ -129,43 +99,8 @@ class QueriesTest : IrohaTest() { client.sendQuery(query) }.also { accounts -> assert(accounts.size == 2) - assert(accounts.any { it.id.name == ALICE_ACCOUNT_NAME }) - assert(accounts.any { it.id.name == BOB_ACCOUNT_NAME }) - } - } - - @Test - @WithIroha([DefaultGenesis::class]) - @Feature("Accounts") - @Query("FindAccountsByName") - @Story("Account queries accounts by name") - @SdkTestId("find_accounts_by_name") - fun `find accounts by name`(): Unit = runBlocking { - QueryBuilder.findAccountsByName(ALICE_ACCOUNT_NAME) - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - .let { query -> - client.sendQuery(query) - }.also { accounts -> - assert(accounts.all { it.id.name == ALICE_ACCOUNT_NAME }) - } - } - - @Test - @WithIroha([DefaultGenesis::class]) - @Feature("Accounts") - @Query("FindAccountsByNameWithFilter") - @Story("Account queries accounts by name with a filter") - @SdkTestId("find_accounts_by_name_with_filter") - fun `find accounts by name with filter`(): Unit = runBlocking { - val filter = QueryFilters.startsWith("alice") - QueryBuilder.findAccountsByName(ALICE_ACCOUNT_NAME, filter) - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - .let { query -> - client.sendQuery(query) - }.also { accounts -> - assert(accounts.all { it.id.name == ALICE_ACCOUNT_NAME }) + assert(accounts.any { it.id.signatory == ALICE_PUBLIC_KEY }) + assert(accounts.any { it.id.signatory == BOB_PUBLIC_KEY }) } } @@ -202,28 +137,10 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { accounts -> - assert(accounts.all { it.id.domainId == DEFAULT_DOMAIN_ID }) + assert(accounts.all { it.id.domain == DEFAULT_DOMAIN_ID }) } } - @Test - @WithIroha([XorAndValAssets::class]) - @Feature("Accounts") - @Query("FindAccountsWithAsset") - @Story("Account queries accounts with a specific asset") - @SdkTestId("find_accounts_with_asset") - fun `find accounts with asset`(): Unit = runBlocking { - QueryBuilder.findAccountsWithAsset(XOR_DEFINITION_ID) - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query) } - .let { accounts -> - accounts.all { account -> - account.assets.any { it.key.definitionId == XOR_DEFINITION_ID } - } - }.also { assert(it) } - } - @Test @WithIroha([XorAndValAssets::class, AliceCanMintXor::class]) @Feature("Assets") @@ -232,13 +149,13 @@ class QueriesTest : IrohaTest() { @SdkTestId("find_total_asset_quantity_by_AssetDefinitionId") fun `find total asset quantity by AssetDefinitionId`(): Unit = runBlocking { val quantity = 10 - client.tx { mintAsset(AssetId(XOR_DEFINITION_ID, BOB_ACCOUNT_ID), quantity) } + client.tx { mintAsset(AssetId(definition = XOR_DEFINITION_ID, account = BOB_ACCOUNT_ID), quantity) } QueryBuilder.findTotalAssetQuantityByAssetDefinitionId(XOR_DEFINITION_ID) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } - .also { assertEquals(quantity + XorAndValAssets.XOR_QUANTITY, it.toInt()) } + .also { assertEquals(quantity + XorAndValAssets.XOR_QUANTITY, it.asInt()) } } @Test @@ -254,8 +171,8 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { assets -> - assert(assets.any { it.id.definitionId == XOR_DEFINITION_ID }) - assert(assets.any { it.id.definitionId == VAL_DEFINITION_ID }) + assert(assets.any { it.id.definition == XOR_DEFINITION_ID }) + assert(assets.any { it.id.definition == VAL_DEFINITION_ID }) } } @@ -272,7 +189,7 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { assets -> - assert(assets.all { it.id.definitionId.name == XOR_DEFINITION_ID.name }) + assert(assets.all { it.id.definition.name == XOR_DEFINITION_ID.name }) } } @@ -289,9 +206,9 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { assets -> - assert(assets.all { it.id.accountId == ALICE_ACCOUNT_ID }) - assert(assets.any { it.id.definitionId == XOR_DEFINITION_ID }) - assert(assets.any { it.id.definitionId == VAL_DEFINITION_ID }) + assert(assets.all { it.id.account == ALICE_ACCOUNT_ID }) + assert(assets.any { it.id.definition == XOR_DEFINITION_ID }) + assert(assets.any { it.id.definition == VAL_DEFINITION_ID }) } } @@ -311,8 +228,8 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { assets -> - assert(assets.all { it.id.definitionId == XOR_DEFINITION_ID }) - assert(assets.all { it.id.accountId.domainId == DEFAULT_DOMAIN_ID }) + assert(assets.all { it.id.definition == XOR_DEFINITION_ID }) + assert(assets.all { it.id.account.domain == DEFAULT_DOMAIN_ID }) } } @@ -323,14 +240,14 @@ class QueriesTest : IrohaTest() { @Story("Account queries asset quantity by asset ID") @SdkTestId("find_asset_quantity_by_ID") fun `find asset quantity by id`(): Unit = runBlocking { - val assetId = AssetId(XOR_DEFINITION_ID, ALICE_ACCOUNT_ID) + val assetId = AssetId(definition = XOR_DEFINITION_ID, account = ALICE_ACCOUNT_ID) QueryBuilder.findAssetQuantityById(assetId) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) }.also { quantity -> - assert(quantity == XorAndValAssets.XOR_QUANTITY.toLong()) + assert(quantity.asInt() == XorAndValAssets.XOR_QUANTITY) } } @@ -370,7 +287,7 @@ class QueriesTest : IrohaTest() { .let { query -> client.sendQuery(query) }.also { - assert(it == StoreAssetWithMetadata.ASSET_VALUE) + assertEquals(it, StoreAssetWithMetadata.ASSET_VALUE) } } @@ -382,21 +299,7 @@ class QueriesTest : IrohaTest() { @SdkTestId("find_asset_by_metadata_filters") @Disabled // https://github.com/hyperledger/iroha/issues/2697 fun `find asset by metadata filters`(): Unit = runBlocking { - val filter = GenericPredicateBox.Raw( - ValuePredicate.Container( - Container.ValueOfKey( - ValueOfKey( - StoreAssetWithMetadata.ASSET_KEY, - ValuePredicate.Identifiable( - StringPredicate.Is( - StoreAssetWithMetadata.ASSET_VALUE.string, - ), - ), - ), - ), - ), - ) - QueryBuilder.findAllAssets(filter) + QueryBuilder.findAllAssets() .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> @@ -407,7 +310,7 @@ class QueriesTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Assets") @Query("FindAssetDefinitionById") @Story("Account queries asset definition by ID") @@ -502,7 +405,7 @@ class QueriesTest : IrohaTest() { fun `find transactions by account id`(): Unit = runBlocking { client.sendTransaction { account(ALICE_ACCOUNT_ID) - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) buildSigned(ALICE_KEYPAIR) } @@ -513,12 +416,9 @@ class QueriesTest : IrohaTest() { client.sendQuery(query) }.let { txValues -> txValues.all { value -> - value.cast() - .value - .cast() - .signedTransactionV1 - .payload - .authority == ALICE_ACCOUNT_ID + value.transaction.value + .cast().signedTransactionV1 + .payload.authority == ALICE_ACCOUNT_ID } }.also { assert(it) @@ -526,22 +426,20 @@ class QueriesTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("PermissionTokens") @Query("FindPermissionTokensByAccountId") @Story("PermissionToken queries permission tokens by account id") @SdkTestId("find_permission_tokens_by_account_id") fun `find permission tokens by account id`(): Unit = runBlocking { - QueryBuilder.findPermissionTokensByAccountId(ALICE_ACCOUNT_ID) + QueryBuilder.findPermissionsByAccountId(ALICE_ACCOUNT_ID) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } .let { tokens -> - tokens.any { - "{\"asset_definition_id\":\"xor#wonderland\"}" == it.payload.string - } + tokens.any { "{\"asset_definition\":\"xor#wonderland\"}" == it.payload } }.also { assert(it) } @@ -556,7 +454,7 @@ class QueriesTest : IrohaTest() { fun `find transaction by hash`(): Unit = runBlocking { client.sendTransaction { account(ALICE_ACCOUNT_ID) - registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()) + registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()) buildSigned(ALICE_KEYPAIR) }.let { d -> withTimeout(txTimeout) { d.await() } @@ -574,10 +472,10 @@ class QueriesTest : IrohaTest() { .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } assertEquals( - DEFAULT_ASSET_DEFINITION_ID, + DEFAULT_ASSET_DEFINITION_ID.domain, txByHash.transaction.value - .extractInstruction() - .registerExpr.`object`.extractNewAssetDefinition().id, + .extractInstruction() + .registerBox.cast().registerOfDomain.`object`.id, ) txByHash.transaction.value .let { SignedTransaction.encode(it).hash() } @@ -623,12 +521,11 @@ class QueriesTest : IrohaTest() { @Story("Trigger queries triggers by domain ID") @SdkTestId("find_triggers_by_domain_id") fun `find triggers by domain ID`(): Unit = runBlocking { - val domainId = WithExecutableTrigger.TRIGGER_ID.domainId!! - QueryBuilder.findTriggersByDomainId(domainId) + QueryBuilder.findTriggersByAuthorityDomainId(ALICE_ACCOUNT_ID.domain) .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 == WithExecutableTrigger.TRIGGER_ID }) } } @Test @@ -656,109 +553,121 @@ class QueriesTest : IrohaTest() { @Story("Account queries all accounts with pagination and sorting by metadata key") @SdkTestId("pagination_plus_sorting_by_metadata_key") fun `pagination plus sorting by metadata key`(): Unit = runBlocking { - val keyU32 = RandomStringUtils.randomAlphabetic(5).asName() - val keyU128 = RandomStringUtils.randomAlphabetic(5).asName() + val key1 = RandomStringUtils.randomAlphabetic(5).asName() + val key2 = RandomStringUtils.randomAlphabetic(5).asName() - createAccount("new_000", mapOf(keyU32 to 1.asValue(), keyU128 to 1L.asValue())) - createAccount("new_111", mapOf(keyU32 to 0.asValue(), keyU128 to 0L.asValue())) - createAccount("new_222", mapOf(keyU32 to 2.asValue(), keyU128 to 2L.asValue())) + createAccount(metadata = mapOf(key1 to "1", key2 to "1")) + createAccount(metadata = mapOf(key1 to "0", key2 to "0")) + createAccount(metadata = mapOf(key1 to "2", key2 to "2")) - listOf(keyU32, keyU128).forEach { key -> - QueryBuilder.findAllAccounts(QueryFilters.startsWith("new_")) + listOf(key1, key2).forEach { key -> + QueryBuilder.findAllAccounts() .account(ALICE_ACCOUNT_ID) + .sorting(key.string) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, sorting = key.string) } + .let { query -> client.sendQuery(query) } .let { accounts -> - assertEquals(if (key == keyU32) 0.asValue() else 0L.asValue(), accounts[0].metadata.map[key]) - assertEquals(if (key == keyU32) 1.asValue() else 1L.asValue(), accounts[1].metadata.map[key]) - assertEquals(if (key == keyU32) 2.asValue() else 2L.asValue(), accounts[2].metadata.map[key]) + assertEquals("0", accounts[0].metadata.sortedMapOfName[key]) + assertEquals("1", accounts[1].metadata.sortedMapOfName[key]) + assertEquals("2", accounts[2].metadata.sortedMapOfName[key]) } } } @Test - @WithIroha([DefaultGenesis::class]) + @WithIroha([NewDomainWithMetadata::class]) @Feature("Accounts") @Query("FindAllAccountsWithPagination") @Story("Account queries all accounts with pagination after inserting some new accounts") @SdkTestId("pagination_works_correct_after_inserting_some_new_accounts") fun `pagination works correct after inserting some new accounts`(): Unit = runBlocking { val key = "ts".asName() + val limit = 3L - val metadata0 = Instant.now().toEpochMilli().asValue() - createAccount("new_000", mapOf(key to metadata0)) - val metadata1 = Instant.now().toEpochMilli().asValue() - createAccount("new_111", mapOf(key to metadata1)) - val metadata2 = Instant.now().toEpochMilli().asValue() - createAccount("new_222", mapOf(key to metadata2)) - val metadata3 = Instant.now().toEpochMilli().asValue() - createAccount("new_333", mapOf(key to metadata3)) - val metadata4 = Instant.now().toEpochMilli().asValue() - createAccount("new_444", mapOf(key to metadata4)) + val metadata0 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata0)) + val metadata1 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata1)) + val metadata2 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata2)) + val metadata3 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata3)) + val metadata4 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata4)) - QueryBuilder.findAllAccounts(QueryFilters.startsWith("new_")) + QueryBuilder.findAccountsByDomainId(NewDomainWithMetadata.DOMAIN_ID) .account(ALICE_ACCOUNT_ID) + .pagination(limit = limit) + .sorting(key) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, limit = 3, sorting = key.string) } + .let { query -> client.sendQuery(query) } .let { accounts -> - assertEquals(3, accounts.size) - assertEquals(metadata2, accounts[2].metadata.map[key]) + assertEquals(limit, accounts.size.toLong()) + assertEquals(metadata2, accounts[2].metadata.sortedMapOfName[key]) } - - QueryBuilder.findAllAccounts(QueryFilters.startsWith("new_")) + QueryBuilder.findAccountsByDomainId(NewDomainWithMetadata.DOMAIN_ID) .account(ALICE_ACCOUNT_ID) + .pagination(start = limit.toBigInteger(), limit = limit) + .sorting(key) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, 3, 3) } + .let { query -> client.sendQuery(query) } .let { accounts -> assertEquals(2, accounts.size) - assertEquals(metadata4, accounts[1].metadata.map[key]) + assertEquals(metadata4, accounts[1].metadata.sortedMapOfName[key]) } - val metadata5 = Instant.now().toEpochMilli().asValue() - createAccount("new_555", mapOf(key to metadata5)) - val metadata6 = Instant.now().toEpochMilli().asValue() - createAccount("new_666", mapOf(key to metadata6)) - val metadata7 = Instant.now().toEpochMilli().asValue() - createAccount("new_777", mapOf(key to metadata7)) - val metadata8 = Instant.now().toEpochMilli().asValue() - createAccount("new_888", mapOf(key to metadata8)) + val metadata5 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata5)) + val metadata6 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata6)) + val metadata7 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata7)) + val metadata8 = Instant.now().toEpochMilli().toString() + createAccount(domainId = NewDomainWithMetadata.DOMAIN_ID, metadata = mapOf(key to metadata8)) - QueryBuilder.findAllAccounts(QueryFilters.startsWith("new_")) + QueryBuilder.findAccountsByDomainId(NewDomainWithMetadata.DOMAIN_ID) .account(ALICE_ACCOUNT_ID) + .pagination(start = BigInteger.valueOf(2).multiply(limit.toBigInteger()), limit = limit) + .sorting(key) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, 6, 3) } + .let { query -> client.sendQuery(query) } .let { accounts -> assertEquals(3, accounts.size) - assertEquals(metadata6, accounts[0].metadata.map[key]) - assertEquals(metadata8, accounts[2].metadata.map[key]) + assertEquals(metadata6, accounts[0].metadata.sortedMapOfName[key]) + assertEquals(metadata8, accounts[2].metadata.sortedMapOfName[key]) } + print(metadata5) + print(metadata7) } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Accounts") @Query("FindAllAccountsWithPagination") @Story("Account queries all accounts with pagination") @SdkTestId("find_all_account_with_pagination") fun `find all account with pagination`(): Unit = runBlocking { + val limit = 5L + val start = 3L var accounts = QueryBuilder.findAllAccounts() .account(ALICE_ACCOUNT_ID) + .pagination(limit = 5) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, limit = 5) } + .let { query -> client.sendQuery(query) } assertEquals(3, accounts.size) - createAccount("foo") - createAccount("bar") + repeat(2) { createAccount() } accounts = QueryBuilder.findAllAccounts() .account(ALICE_ACCOUNT_ID) + .pagination(start = BigInteger.valueOf(start), limit = limit) .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query, 3, 5) } - assertEquals(2, accounts.size) + .let { query -> client.sendQuery(query) } + assertEquals(limit - start, accounts.size.toLong()) } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Transactions") @Query("FindAllTransactions") @Story("Account queries all transactions") @@ -778,12 +687,12 @@ class QueriesTest : IrohaTest() { .buildSigned(ALICE_KEYPAIR) .let { client.sendQuery(it) } .also { txs -> - assertTrue(txs.size == 7) // 5 + 2 genesis txs + assertTrue(txs.size == 9) // 5 + 4 genesis txs } } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Blocks") @Query("FindAllBlocks") @Story("Account queries all blocks") @@ -806,7 +715,7 @@ class QueriesTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Feature("Blocks") @Query("FindAllBlockHeaders") @Story("Account queries all block headers") @@ -840,10 +749,7 @@ class QueriesTest : IrohaTest() { .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } .also { ids -> - assertContains( - ids, - AliceHasRoleWithAccessToBobsMetadata.ROLE_ID, - ) + assertContains(ids, AliceHasRoleWithAccessToBobsMetadata.ROLE_ID) } } @@ -890,15 +796,11 @@ class QueriesTest : IrohaTest() { @SdkTestId("find_role_by_role_ID") fun `find role by ID`(): Unit = runBlocking { val roleId = AliceHasRoleWithAccessToBobsMetadata.ROLE_ID - try { - QueryBuilder.findRoleByRoleId(roleId) - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query) } - .also { role -> assertEquals(role.id, roleId) } - } catch (e: Exception) { - println(e) - } + QueryBuilder.findRoleByRoleId(roleId) + .account(ALICE_ACCOUNT_ID) + .buildSigned(ALICE_KEYPAIR) + .let { query -> client.sendQuery(query) } + .also { role -> assertEquals(role.id, roleId) } } @Test @@ -910,7 +812,7 @@ class QueriesTest : IrohaTest() { fun `find asset definitions with or filter`(): Unit = runBlocking { val definitionId = AliceWithTestAssets.TEST_ASSET_DEFINITION_ID val filter = QueryFilters.or( - StringPredicate.Is("${definitionId.name.string}#${definitionId.domainId.name.string}"), + StringPredicate.Is("${definitionId.name.string}#${definitionId.domain.name.string}"), ) QueryBuilder.findAllAssetsDefinitions(filter) .account(ALICE_ACCOUNT_ID) @@ -923,23 +825,6 @@ class QueriesTest : IrohaTest() { } } - @Test - @WithIroha([DefaultGenesis::class]) - @Feature("Permissions") - @Query("FindPermissionTokenSchema") - @Story("Transaction queries all permission token ids") - @SdkTestId("find_all_permission_token_ids") - fun `find all permission token ids`(): Unit = runBlocking { - val permissionTokenSchema = QueryBuilder.findPermissionTokenIdsSchema() - .account(ALICE_ACCOUNT_ID) - .buildSigned(ALICE_KEYPAIR) - .let { query -> client.sendQuery(query) } - assertEquals(permissionTokenSchema.tokenIds.size, Permissions.values().size) - - val expectedPermissions = Permissions.values().map { it.type }.toList() - assertTrue(permissionTokenSchema.tokenIds.containsAll(expectedPermissions)) - } - @WithIroha([WithManyDomains::class]) @Story( "Iroha2 returns 10 results per request. This test checks new internal implementation of cursor mechanism" + @@ -955,13 +840,14 @@ class QueriesTest : IrohaTest() { } private suspend fun createAccount( - name: String, - metadata: Map = mapOf(), + domainId: DomainId = DEFAULT_DOMAIN_ID, + keyPair: KeyPair = generateKeyPair(), + metadata: Map = mapOf(), ) { - val newAccountId = AccountId(DEFAULT_DOMAIN_ID, name.asName()) + val newAccountId = AccountId(domainId, keyPair.public.toIrohaPublicKey()) client.sendTransaction { accountId = ALICE_ACCOUNT_ID - registerAccount(newAccountId, listOf(), Metadata(metadata)) + registerAccount(newAccountId, Metadata(metadata)) buildSigned(ALICE_KEYPAIR) }.also { d -> withTimeout(txTimeout) { d.await() } 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 50425f8cb..f28aa9b96 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 @@ -7,28 +7,25 @@ import jp.co.soramitsu.iroha2.annotations.Sdk import jp.co.soramitsu.iroha2.annotations.SdkTestId import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.generated.AccountId -import jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.AssetType 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.InstructionExpr +import jp.co.soramitsu.iroha2.generated.EventFilterBox +import jp.co.soramitsu.iroha2.generated.InstructionBox import jp.co.soramitsu.iroha2.generated.Metadata import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.OriginFilterOfTriggerEvent import jp.co.soramitsu.iroha2.generated.Repeats -import jp.co.soramitsu.iroha2.generated.TriggerEventFilter import jp.co.soramitsu.iroha2.generated.TriggerId -import jp.co.soramitsu.iroha2.generated.TriggeringFilterBox 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 import jp.co.soramitsu.iroha2.testengine.ALICE_KEYPAIR -import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToBurn +import jp.co.soramitsu.iroha2.testengine.ALICE_PUBLIC_KEY +import jp.co.soramitsu.iroha2.testengine.AliceHas100XorAndPermissionToMintAndBurn import jp.co.soramitsu.iroha2.testengine.BOB_ACCOUNT_ID import jp.co.soramitsu.iroha2.testengine.DEFAULT_ASSET_ID import jp.co.soramitsu.iroha2.testengine.DEFAULT_DOMAIN_ID +import jp.co.soramitsu.iroha2.testengine.IROHA_CONFIG_DELIMITER import jp.co.soramitsu.iroha2.testengine.IrohaTest import jp.co.soramitsu.iroha2.testengine.WithIroha import jp.co.soramitsu.iroha2.testengine.XOR_DEFINITION_ID @@ -43,6 +40,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import java.math.BigInteger import java.security.KeyPair +import java.time.Duration import java.time.Instant import java.util.Date import kotlin.test.assertEquals @@ -54,7 +52,7 @@ import kotlin.test.assertNotNull class TriggersTest : IrohaTest() { @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Story("Data created trigger mints asset upon asset definition creation") @SdkTestId("data_created_trigger") fun `data created trigger`(): Unit = runBlocking { @@ -71,13 +69,11 @@ class TriggersTest : IrohaTest() { assertNotNull(asset) // Check default asset quantity before trigger - val prevQuantity = checkDefaultDomainQuantity() + val prevQuantity = checkDefaultAssetQuantity() assertEquals(100L, prevQuantity) - val filter = Filters.data( - EntityFilters.byAssetDefinition( - eventFilter = AssetDefinitionEventFilter.ByCreated(), - ), + val filter = EventFilterBox.Data( + EntityFilters.byAssetDefinition(1), ) client.sendTransaction { accountId = ALICE_ACCOUNT_ID @@ -99,12 +95,12 @@ class TriggersTest : IrohaTest() { createNewAsset(newAssetName, assetDefinitions.size) // check new quantity after trigger is run - val newQuantity = checkDefaultDomainQuantity() + val newQuantity = checkDefaultAssetQuantity() assertEquals(prevQuantity + 1L, newQuantity) } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @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 { @@ -119,7 +115,7 @@ class TriggersTest : IrohaTest() { assertEquals(1, assetDefinitions.size) // check DEFAULT_ASSET_ID quantity before trigger - val prevQuantity = checkDefaultDomainQuantity() + val prevQuantity = checkDefaultAssetQuantity() assertEquals(100L, prevQuantity) // register pre commit trigger @@ -137,7 +133,7 @@ class TriggersTest : IrohaTest() { } // check DEFAULT_ASSET_ID quantity after trigger is run - var newQuantity = checkDefaultDomainQuantity() + var newQuantity = checkDefaultAssetQuantity() assertEquals(110L, newQuantity) // register new asset @@ -145,7 +141,7 @@ class TriggersTest : IrohaTest() { createNewAsset(newAssetName, assetDefinitions.size) // check DEFAULT_ASSET_ID quantity after trigger is run - newQuantity = checkDefaultDomainQuantity() + newQuantity = checkDefaultAssetQuantity() assertEquals(120L, newQuantity) // transfer asset instruction just to test trigger @@ -158,12 +154,12 @@ class TriggersTest : IrohaTest() { } // check DEFAULT_ASSET_ID quantity after trigger is run - newQuantity = checkDefaultDomainQuantity() + newQuantity = checkDefaultAssetQuantity() assertEquals(30L, newQuantity) } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Story("Executable trigger mints asset") @SdkTestId("executable_trigger") fun `executable trigger`(): Unit = runBlocking { @@ -187,7 +183,7 @@ class TriggersTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class], configs = ["LOG_LEVEL${IROHA_CONFIG_DELIMITER}TRACE"]) @Story("Endless time trigger decreases asset quantity continuously") @SdkTestId("endless_time_trigger") fun `endless time trigger`(): Unit = runBlocking { @@ -201,11 +197,12 @@ class TriggersTest : IrohaTest() { sendAndWait10Txs() delay(3000) - assert(readQuantity() <= 90L) + val q = readQuantity() + assert(q <= 90L) } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @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 { @@ -223,18 +220,15 @@ class TriggersTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @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 and update trigger metadata`(): Unit = runBlocking { val triggerId = TriggerId(name = "wasm_trigger".asName()) - val currentTime = Date().time / 1000 - val filter = TriggeringFilterBox.Time( - EventFilters.timeEventFilter( - Duration(BigInteger.valueOf(currentTime), 0), - Duration(BigInteger.valueOf(1L), 0), - ), + val currentTime = Date().time + 10000 + val filter = EventFilterBox.Time( + EventFilters.timeEventFilter(BigInteger.valueOf(currentTime), BigInteger.valueOf(1000L)), ) val wasm = this.javaClass.classLoader .getResource("create_nft_for_alice_smartcontract.wasm") @@ -250,12 +244,14 @@ class TriggersTest : IrohaTest() { filter, ) } - keepNetworkBusyAndCheckAssetDefinitionIds() - val testKey = "key" - val testValue = "value" - client.tx { setKeyValue(triggerId, testKey.asName(), testValue.asValue()) } + val testKey = "key02357123" + val testValue = "value986441123" + client.tx { setKeyValue(triggerId, testKey.asName(), testValue) } + + delay(15000) + QueryBuilder.findTriggerById(triggerId) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) @@ -264,7 +260,7 @@ class TriggersTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Story("Wasm trigger mints NFT for every user when trigger metadata is updated") @SdkTestId("wasm_trigger_to_mint_nft_for_every_user_on_update_trigger_metadata_event") fun `wasm trigger to mint nft for every user on update trigger metadata event`(): Unit = runBlocking { @@ -272,14 +268,8 @@ class TriggersTest : IrohaTest() { val setKeyValueTriggerId = TriggerId(name = "update_trigger".asName()) val filter = Filters.data( - EntityFilters.byTrigger( - OriginFilterOfTriggerEvent( - wasmTriggerId, - ), - TriggerEventFilter.ByMetadataInserted(), - ), + EntityFilters.byTrigger(1, wasmTriggerId), ) - val wasm = this.javaClass.classLoader .getResource("create_nft_for_alice_smartcontract.wasm") .readBytes() @@ -294,13 +284,12 @@ class TriggersTest : IrohaTest() { filter, ) } - val testKey = "key" val testValue = "value" client.tx { registerExecutableTrigger( setKeyValueTriggerId, - listOf(Instructions.setKeyValue(wasmTriggerId, testKey.asName(), testValue.asValue())), + listOf(Instructions.setKeyValue(wasmTriggerId, testKey.asName(), testValue)), Repeats.Exactly(1L), ALICE_ACCOUNT_ID, ) @@ -317,7 +306,7 @@ class TriggersTest : IrohaTest() { } @Test - @WithIroha([AliceHas100XorAndPermissionToBurn::class]) + @WithIroha([AliceHas100XorAndPermissionToMintAndBurn::class]) @Story("Unregister an executable trigger") @SdkTestId("unregister_executable_trigger") fun `unregister executable trigger`(): Unit = runBlocking { @@ -359,7 +348,7 @@ class TriggersTest : IrohaTest() { repeat(10) { i -> client.sendTransaction { accountId = ALICE_ACCOUNT_ID - setKeyValue(ALICE_ACCOUNT_ID, "key$i".asName(), "value$i".asValue()) + setKeyValue(ALICE_ACCOUNT_ID, "key$i".asName(), "value$i") buildSigned(ALICE_KEYPAIR) }.also { d -> delay(1000) @@ -377,13 +366,13 @@ class TriggersTest : IrohaTest() { .account(accountId) .buildSigned(keyPair) .let { query -> client.sendQuery(query) } - .value.cast().u32 + .value.cast().numeric.asLong() } private suspend fun sendAndAwaitTimeTrigger( triggerId: TriggerId, repeats: Repeats, - instruction: InstructionExpr, + instruction: InstructionBox, accountId: AccountId = ALICE_ACCOUNT_ID, ) { client.sendTransaction { @@ -394,8 +383,8 @@ class TriggersTest : IrohaTest() { repeats, accountId, EventFilters.timeEventFilter( - Duration(BigInteger.valueOf(Instant.now().epochSecond), 0L), - Duration(BigInteger.valueOf(1L), 0L), + BigInteger.valueOf(Instant.now().toEpochMilli()), + BigInteger.valueOf(500L), ), ) buildSigned(ALICE_KEYPAIR) @@ -405,10 +394,10 @@ class TriggersTest : IrohaTest() { } private suspend fun createNewAsset(assetName: String, prevSize: Int) { - val newAsset = AssetDefinitionId(assetName.asName(), DEFAULT_DOMAIN_ID) + val newAsset = AssetDefinitionId(DEFAULT_DOMAIN_ID, assetName.asName()) client.sendTransaction { accountId = ALICE_ACCOUNT_ID - registerAssetDefinition(newAsset, AssetValueType.Quantity()) + registerAssetDefinition(newAsset, AssetType.numeric()) buildSigned(ALICE_KEYPAIR) }.also { d -> withTimeout(txTimeout) { d.await() } @@ -424,43 +413,42 @@ class TriggersTest : IrohaTest() { assertNotNull(asset) } - private suspend fun checkDefaultDomainQuantity(): Long { - return QueryBuilder.findDomainById(DEFAULT_DOMAIN_ID) + private suspend fun checkDefaultAssetQuantity(): Long { + return QueryBuilder.findAssetById(DEFAULT_ASSET_ID) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } - .accounts - .filter { it.key.name == ALICE_ACCOUNT_NAME } - .map { it.value.assets[DEFAULT_ASSET_ID] } - .map { (it?.value as AssetValue.Quantity).u32 } - .first() + .value.cast() + .numeric.asLong() } private suspend fun keepNetworkBusyAndCheckAssetDefinitionIds() { // send some transactions to keep Iroha2 network busy - repeat(2) { i -> + repeat(5) { i -> client.sendTransaction { accountId = ALICE_ACCOUNT_ID - setKeyValue(ALICE_ACCOUNT_ID, "test$i".asName(), "test$i".asValue()) + setKeyValue(ALICE_ACCOUNT_ID, "test$i".asName(), "test$i") buildSigned(ALICE_KEYPAIR) }.also { d -> - withTimeout(txTimeout) { d.await() } + withTimeout(Duration.ofSeconds(60)) { d.await() } } + delay(500) } QueryBuilder.findAssetsByAccountId(ALICE_ACCOUNT_ID) .account(ALICE_ACCOUNT_ID) .buildSigned(ALICE_KEYPAIR) .let { query -> client.sendQuery(query) } .also { assets -> + val expectedDefinition = AssetDefinitionId( + DEFAULT_DOMAIN_ID, + "nft_number_1_for_${ALICE_PUBLIC_KEY.payload.toHex(true)}".asName(), + ) assert(assets.size > 1) - assert(assets.all { it.id.accountId == ALICE_ACCOUNT_ID }) - assert(assets.any { it.id.definitionId == XOR_DEFINITION_ID }) + assert(assets.all { it.id.account == ALICE_ACCOUNT_ID }) + assert(assets.any { it.id.definition == XOR_DEFINITION_ID }) assert( assets.any { - it.id.definitionId == AssetDefinitionId( - "nft_number_1_for_alice".asName(), - DEFAULT_DOMAIN_ID, - ) + it.id.definition.asString().lowercase() == expectedDefinition.asString().lowercase() }, ) } 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 373e63e6d..97a077d06 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 @@ -1,29 +1,29 @@ package jp.co.soramitsu.iroha2.testengine -import jp.co.soramitsu.iroha2.ACCOUNT_ID_DELIMITER import jp.co.soramitsu.iroha2.Genesis import jp.co.soramitsu.iroha2.Permissions -import jp.co.soramitsu.iroha2.asAccountId import jp.co.soramitsu.iroha2.asDomainId import jp.co.soramitsu.iroha2.asJsonString import jp.co.soramitsu.iroha2.asName -import jp.co.soramitsu.iroha2.asString -import jp.co.soramitsu.iroha2.asStringWithJson -import jp.co.soramitsu.iroha2.asValue import jp.co.soramitsu.iroha2.generateKeyPair +import jp.co.soramitsu.iroha2.generatePublicKey import jp.co.soramitsu.iroha2.generated.AccountId 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.AssetType +import jp.co.soramitsu.iroha2.generated.ChainId import jp.co.soramitsu.iroha2.generated.DomainId -import jp.co.soramitsu.iroha2.generated.IdBox -import jp.co.soramitsu.iroha2.generated.InstructionExpr +import jp.co.soramitsu.iroha2.generated.InstructionBox import jp.co.soramitsu.iroha2.generated.Metadata -import jp.co.soramitsu.iroha2.generated.PermissionToken -import jp.co.soramitsu.iroha2.generated.RawGenesisBlock +import jp.co.soramitsu.iroha2.generated.NonZeroOfu64 +import jp.co.soramitsu.iroha2.generated.Parameter +import jp.co.soramitsu.iroha2.generated.Permission +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction import jp.co.soramitsu.iroha2.generated.Repeats import jp.co.soramitsu.iroha2.generated.RoleId +import jp.co.soramitsu.iroha2.generated.SmartContractParameter import jp.co.soramitsu.iroha2.generated.TriggerId +import jp.co.soramitsu.iroha2.numeric import jp.co.soramitsu.iroha2.toIrohaPublicKey import jp.co.soramitsu.iroha2.transaction.Instructions import org.apache.commons.lang3.RandomStringUtils.randomAlphabetic @@ -35,26 +35,21 @@ import kotlin.random.Random.Default.nextDouble /** * Create a default genesis where there is just one domain with only Alice and Bob in it */ -open class DefaultGenesis : Genesis(rawGenesisBlock()) +open class DefaultGenesis(transaction: RawGenesisTransaction? = null) : Genesis(transaction ?: rawGenesisTx()) open class AliceCanUpgradeExecutor : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.grantPermissionToken( Permissions.CanUpgradeExecutor, - "", - ALICE_ACCOUNT_ID, + destinationId = ALICE_ACCOUNT_ID, ), ), ) open class WithDomainTransferredToBob : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerDomain(DOMAIN_ID), - Instructions.transferDomainOwnership( - "$GENESIS$ACCOUNT_ID_DELIMITER$GENESIS".asAccountId(), - IdBox.DomainId(DOMAIN_ID), - BOB_ACCOUNT_ID, - ), + Instructions.transferDomainOwnership(GENESIS_ACCOUNT, DOMAIN_ID, BOB_ACCOUNT_ID), ), ) { companion object { @@ -63,17 +58,16 @@ open class WithDomainTransferredToBob : Genesis( } open class AliceCanUnregisterAnyPeer : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.grantPermissionToken( Permissions.CanUnregisterAnyPeer, - "", - ALICE_ACCOUNT_ID, + destinationId = ALICE_ACCOUNT_ID, ), ), ) open class AliceAndBobHasPermissionToMintPublicKeys : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.grantPermissionToken( Permissions.CanMintUserPublicKeys, ALICE_ACCOUNT_ID.asJsonString(), @@ -88,7 +82,7 @@ open class AliceAndBobHasPermissionToMintPublicKeys : Genesis( ) open class AliceHasPermissionToUnregisterDomain : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerDomain(NEW_DOMAIN_ID), Instructions.grantPermissionToken( Permissions.CanUnregisterDomain, @@ -103,7 +97,7 @@ open class AliceHasPermissionToUnregisterDomain : Genesis( } open class WithManyDomains : Genesis( - rawGenesisBlock( + rawGenesisTx( *registerDomains(DOMAINS_COUNT), ), ) { @@ -112,8 +106,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()))) } @@ -124,16 +118,16 @@ fun registerDomains(count: Int): Array { * Give Alice access to Bob's metadata */ open class AliceHasRoleWithAccessToBobsMetadata : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerRole( ROLE_ID, - PermissionToken( - Permissions.CanSetKeyValueInUserAccount.type, - BOB_ACCOUNT_ID.asJsonString().asStringWithJson(), + Permission( + Permissions.CanSetKeyValueInAccount.type, + BOB_ACCOUNT_ID.asJsonString(true), ), - PermissionToken( - Permissions.CanRemoveKeyValueInUserAccount.type, - BOB_ACCOUNT_ID.asJsonString().asStringWithJson(), + Permission( + Permissions.CanRemoveKeyValueInAccount.type, + BOB_ACCOUNT_ID.asJsonString(true), ), ), Instructions.grantRole(ROLE_ID, ALICE_ACCOUNT_ID), @@ -147,15 +141,28 @@ open class AliceHasRoleWithAccessToBobsMetadata : Genesis( /** * Give Alice 100 XOR and the permission to burn them */ -open class AliceHas100XorAndPermissionToBurn : Genesis( - rawGenesisBlock( - Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()), +open class AliceHas100XorAndPermissionToMintAndBurn : Genesis( + rawGenesisTx( + Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()), Instructions.mintAsset(DEFAULT_ASSET_ID, 100), Instructions.grantPermissionToken( - Permissions.CanMintUserAssetDefinitionsToken, + Permissions.CanMintAssetWithDefinition, + DEFAULT_ASSET_DEFINITION_ID.asJsonString(), + ALICE_ACCOUNT_ID, + ), + Instructions.grantPermissionToken( + Permissions.CanBurnAssetWithDefinition, DEFAULT_ASSET_DEFINITION_ID.asJsonString(), ALICE_ACCOUNT_ID, ), + params = listOf( + Parameter.SmartContract( + SmartContractParameter.Fuel(NonZeroOfu64(BigInteger.valueOf(5500000000))), + ), + Parameter.Executor( + SmartContractParameter.Fuel(NonZeroOfu64(BigInteger.valueOf(5500000000))), + ), + ), ), ) @@ -163,14 +170,14 @@ open class AliceHas100XorAndPermissionToBurn : Genesis( * Give Alice test assets */ open class AliceWithTestAssets : Genesis( - rawGenesisBlock( - Instructions.registerAssetDefinition(TEST_ASSET_DEFINITION_ID, AssetValueType.Store()), - Instructions.registerAssetDefinition(TEST_ASSET_DEFINITION_ID2, AssetValueType.Store()), + rawGenesisTx( + Instructions.registerAssetDefinition(TEST_ASSET_DEFINITION_ID, AssetType.Store()), + Instructions.registerAssetDefinition(TEST_ASSET_DEFINITION_ID2, AssetType.Store()), ), ) { companion object { - val TEST_ASSET_DEFINITION_ID = AssetDefinitionId("test".asName(), DEFAULT_DOMAIN_ID) - val TEST_ASSET_DEFINITION_ID2 = AssetDefinitionId("test2".asName(), DEFAULT_DOMAIN_ID) + val TEST_ASSET_DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "test".asName()) + val TEST_ASSET_DEFINITION_ID2 = AssetDefinitionId(DEFAULT_DOMAIN_ID, "test2".asName()) } } @@ -178,8 +185,8 @@ open class AliceWithTestAssets : Genesis( * Register an executable trigger without instructions */ open class WithExecutableTrigger : Genesis( - rawGenesisBlock( - Instructions.registerExecutableTrigger( + rawGenesisTx( + Instructions.registerTrigger( TRIGGER_ID, listOf(), Repeats.Exactly(1L), @@ -189,7 +196,7 @@ open class WithExecutableTrigger : Genesis( ), ) { companion object { - val TRIGGER_ID = TriggerId(DEFAULT_DOMAIN_ID, "some_trigger".asName()) + val TRIGGER_ID = TriggerId("some_trigger".asName()) } } @@ -197,15 +204,15 @@ open class WithExecutableTrigger : Genesis( * Mint 100 XOR for Alice and Bob */ open class AliceAndBobEachHave100Xor : Genesis( - rawGenesisBlock( - Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()), + rawGenesisTx( + Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()), Instructions.grantPermissionToken( - Permissions.CanTransferAssetsWithDefinition, + Permissions.CanTransferAssetWithDefinition, DEFAULT_ASSET_DEFINITION_ID.asJsonString(), ALICE_ACCOUNT_ID, ), Instructions.grantPermissionToken( - Permissions.CanTransferAssetsWithDefinition, + Permissions.CanTransferAssetWithDefinition, DEFAULT_ASSET_DEFINITION_ID.asJsonString(), BOB_ACCOUNT_ID, ), @@ -214,7 +221,7 @@ open class AliceAndBobEachHave100Xor : Genesis( ), ) { companion object { - val BOB_ASSET_ID = AssetId(DEFAULT_ASSET_DEFINITION_ID, BOB_ACCOUNT_ID) + val BOB_ASSET_ID = AssetId(BOB_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID) } } @@ -222,10 +229,10 @@ open class AliceAndBobEachHave100Xor : Genesis( * Create a Store asset with metadata */ open class StoreAssetWithMetadata : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerAssetDefinition( DEFINITION_ID, - AssetValueType.Store(), + AssetType.Store(), Metadata(mapOf(ASSET_KEY to ASSET_VALUE)), ), Instructions.setKeyValue(ASSET_ID, ASSET_KEY, ASSET_VALUE), @@ -233,16 +240,16 @@ open class StoreAssetWithMetadata : Genesis( ) { companion object { val ASSET_KEY = "key".asName() - val ASSET_VALUE = RandomStringUtils.randomAlphabetic(50).asValue() - val DEFINITION_ID = AssetDefinitionId("foo".asName(), DEFAULT_DOMAIN_ID) - val ASSET_ID = AssetId(DEFINITION_ID, ALICE_ACCOUNT_ID) + val ASSET_VALUE: String = RandomStringUtils.randomAlphabetic(50) + val DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "foo".asName()) + val ASSET_ID = AssetId(ALICE_ACCOUNT_ID, DEFINITION_ID) } } open class AliceCanMintXor : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.grantPermissionToken( - Permissions.CanMintUserAssetDefinitionsToken, + Permissions.CanMintAssetWithDefinition, XOR_DEFINITION_ID.asJsonString(), ALICE_ACCOUNT_ID, ), @@ -253,12 +260,12 @@ open class AliceCanMintXor : Genesis( * Create XOR and VAL assets with one token for each and metadata */ open class XorAndValAssets : Genesis( - rawGenesisBlock( - Instructions.registerAssetDefinition(XOR_DEFINITION_ID, AssetValueType.Quantity()), - Instructions.mintAsset(AssetId(XOR_DEFINITION_ID, ALICE_ACCOUNT_ID), XOR_QUANTITY), + rawGenesisTx( + Instructions.registerAssetDefinition(XOR_DEFINITION_ID, AssetType.numeric()), + Instructions.mintAsset(AssetId(ALICE_ACCOUNT_ID, XOR_DEFINITION_ID), XOR_QUANTITY), - Instructions.registerAssetDefinition(VAL_DEFINITION_ID, AssetValueType.Quantity()), - Instructions.mintAsset(AssetId(VAL_DEFINITION_ID, ALICE_ACCOUNT_ID), VAL_QUANTITY), + Instructions.registerAssetDefinition(VAL_DEFINITION_ID, AssetType.numeric()), + Instructions.mintAsset(AssetId(ALICE_ACCOUNT_ID, VAL_DEFINITION_ID), VAL_QUANTITY), ), ) { companion object { @@ -271,21 +278,19 @@ open class XorAndValAssets : Genesis( * Create a new account with metadata */ open class NewAccountWithMetadata : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerAccount( id = ACCOUNT_ID, - signatories = listOf(KEYPAIR.public.toIrohaPublicKey()), metadata = Metadata(mapOf(KEY to VALUE)), ), ), ) { companion object { - val ACCOUNT_NAME = "foo".asName() - val KEY = "key".asName() + const val VALUE = "value" - val VALUE = "value".asValue() - val ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, ACCOUNT_NAME) + val KEY = "key".asName() val KEYPAIR = generateKeyPair() + val ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, KEYPAIR.public.toIrohaPublicKey()) } } @@ -293,16 +298,17 @@ open class NewAccountWithMetadata : Genesis( * Create a new domain with metadata */ open class NewDomainWithMetadata : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerDomain( domainId = DOMAIN_ID, metadata = mapOf(KEY to VALUE), ), + Instructions.transferDomainOwnership(GENESIS_ACCOUNT, DOMAIN_ID, ALICE_ACCOUNT_ID), ), ) { companion object { val KEY = "key".asName() - val VALUE = "value".asValue() + val VALUE = "value" val DOMAIN_ID = DomainId("foo_domain".asName()) } } @@ -311,7 +317,7 @@ open class NewDomainWithMetadata : Genesis( * Create a new domain */ open class NewDomain : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerDomain(DOMAIN_ID), ), ) { @@ -324,17 +330,18 @@ open class NewDomain : Genesis( * Specific genesis to test multiple genesis case */ open class RubbishToTestMultipleGenesis : Genesis( - rawGenesisBlock( - Instructions.registerDomain(DEFAULT_DOMAIN_ID, mapOf(DOMAIN_KEY_VALUE.asName() to DOMAIN_KEY_VALUE.asValue())), + rawGenesisTx( + Instructions.registerDomain( + DEFAULT_DOMAIN_ID, + mapOf(DOMAIN_KEY_VALUE.asName() to DOMAIN_KEY_VALUE), + ), Instructions.registerAccount( ALICE_ACCOUNT_ID, - listOf(ALICE_KEYPAIR.public.toIrohaPublicKey()), - Metadata(mapOf(ALICE_KEY_VALUE.asName() to ALICE_KEY_VALUE.asValue())), + Metadata(mapOf(ALICE_KEY_VALUE.asName() to ALICE_KEY_VALUE)), ), Instructions.registerAccount( BOB_ACCOUNT_ID, - listOf(BOB_KEYPAIR.public.toIrohaPublicKey()), - Metadata(mapOf(BOB_KEY_VALUE.asName() to BOB_KEY_VALUE.asValue())), + Metadata(mapOf(BOB_KEY_VALUE.asName() to BOB_KEY_VALUE)), ), ), ) { @@ -349,62 +356,69 @@ open class RubbishToTestMultipleGenesis : Genesis( * To test serializers */ open class FatGenesis : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.registerDomain( randomAlphabetic(10).asDomainId(), - mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10).asValue()), + mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10)), ), Instructions.registerAccount( - "${randomAlphabetic(10)}@${DEFAULT_DOMAIN_ID.asString()}".asAccountId(), - listOf(generateKeyPair().public.toIrohaPublicKey()), - Metadata(mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10).asValue())), + AccountId(domain = DEFAULT_DOMAIN_ID, signatory = generatePublicKey()), + Metadata(mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10))), ), - Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetValueType.Quantity()), + Instructions.registerAssetDefinition(DEFAULT_ASSET_DEFINITION_ID, AssetType.numeric()), Instructions.grantPermissionToken( - Permissions.CanTransferAssetsWithDefinition, + Permissions.CanTransferAssetWithDefinition, DEFAULT_ASSET_DEFINITION_ID.asJsonString(), ALICE_ACCOUNT_ID, ), Instructions.grantPermissionToken( - Permissions.CanTransferAssetsWithDefinition, + Permissions.CanTransferAssetWithDefinition, DEFAULT_ASSET_DEFINITION_ID.asJsonString(), BOB_ACCOUNT_ID, ), Instructions.registerAssetDefinition( DEFINITION_ID, - AssetValueType.Store(), - Metadata(mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10).asValue())), + AssetType.Store(), + Metadata(mapOf(randomAlphabetic(10).asName() to randomAlphabetic(10))), ), Instructions.registerRole( ROLE_ID, - PermissionToken( - Permissions.CanSetKeyValueInUserAccount.type, - BOB_ACCOUNT_ID.asJsonString().asStringWithJson(), + Permission( + Permissions.CanSetKeyValueInAccount.type, + BOB_ACCOUNT_ID.asJsonString(true), ), - PermissionToken( - Permissions.CanRemoveKeyValueInUserAccount.type, - BOB_ACCOUNT_ID.asJsonString().asStringWithJson(), + Permission( + Permissions.CanRemoveKeyValueInAccount.type, + BOB_ACCOUNT_ID.asJsonString(true), ), ), Instructions.grantRole(ROLE_ID, ALICE_ACCOUNT_ID), - Instructions.mintAsset(AssetId(DEFAULT_ASSET_DEFINITION_ID, BOB_ACCOUNT_ID), 100), - Instructions.burnAsset(AssetId(DEFAULT_ASSET_DEFINITION_ID, BOB_ACCOUNT_ID), 100), - Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), Int.MAX_VALUE.asValue()), - Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), (Int.MAX_VALUE * 10L).asValue()), - Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), nextDouble().asValue()), - Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), BigDecimal(nextDouble()).asValue()), + Instructions.mintAsset(AssetId(BOB_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID), 100), + Instructions.burnAsset(AssetId(BOB_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID), 100), + Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), Int.MAX_VALUE.toString()), + Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), (Int.MAX_VALUE * 10L).toString()), + Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), nextDouble().toString()), Instructions.setKeyValue( ASSET_ID, randomAlphabetic(10).asName(), - (BigInteger.valueOf(Long.MAX_VALUE) * BigInteger.valueOf(2)).asValue(), + BigDecimal(nextDouble()).toString(), + ), + Instructions.setKeyValue( + ASSET_ID, + randomAlphabetic(10).asName(), + (BigInteger.valueOf(Long.MAX_VALUE) * BigInteger.valueOf(2)).toString(), + ), + Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), randomAlphabetic(10)), + Instructions.setKeyValue( + DEFAULT_DOMAIN_ID, + randomAlphabetic(10).asName(), + randomAlphabetic(10), ), - Instructions.setKeyValue(ASSET_ID, randomAlphabetic(10).asName(), randomAlphabetic(10).asValue()), - Instructions.setKeyValue(DEFAULT_DOMAIN_ID, randomAlphabetic(10).asName(), randomAlphabetic(10).asValue()), ), ) { companion object { - val DEFINITION_ID = AssetDefinitionId("foo".asName(), DEFAULT_DOMAIN_ID) - val ASSET_ID = AssetId(DEFINITION_ID, BOB_ACCOUNT_ID) + val DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "foo".asName()) + val ASSET_ID = AssetId(BOB_ACCOUNT_ID, DEFINITION_ID) val ROLE_ID = RoleId("USER_METADATA_ACCESS".asName()) } } @@ -413,29 +427,32 @@ open class FatGenesis : Genesis( * Grant permission token to unregister any role */ open class BobCanUnregisterAnyRole : Genesis( - rawGenesisBlock( + rawGenesisTx( Instructions.grantPermissionToken( - permission = Permissions.CanUnregisterAnyRole.type.string, - target = BOB_ACCOUNT_ID, + permission = Permissions.CanUnregisterAnyRole, + destinationId = BOB_ACCOUNT_ID, ), + transferTo = BOB_ACCOUNT_ID, ), ) /** - * Return [RawGenesisBlock] with instructions to init genesis block + * Return [RawGenesisTransaction] with instructions to init genesis */ -fun rawGenesisBlock(vararg isi: InstructionExpr) = RawGenesisBlock( - listOf( +fun rawGenesisTx( + vararg isi: InstructionBox, + params: List = emptyList(), + transferTo: AccountId = ALICE_ACCOUNT_ID, +) = RawGenesisTransaction( + chain = ChainId("00000000-0000-0000-0000-000000000000"), + executor = Genesis.EXECUTOR_FILE_NAME, + parameters = params, + instructions = listOf( Instructions.registerDomain(DEFAULT_DOMAIN_ID), - Instructions.registerAccount( - ALICE_ACCOUNT_ID, - listOf(ALICE_KEYPAIR.public.toIrohaPublicKey()), - ), - Instructions.registerAccount( - BOB_ACCOUNT_ID, - listOf(BOB_KEYPAIR.public.toIrohaPublicKey()), - ), + Instructions.registerAccount(ALICE_ACCOUNT_ID, Metadata(emptyMap())), + Instructions.registerAccount(BOB_ACCOUNT_ID, Metadata(emptyMap())), + Instructions.transferDomainOwnership(GENESIS_ACCOUNT, DEFAULT_DOMAIN_ID, transferTo), *isi, - ).let { listOf(it) }, - Genesis.executorMode, + ), + topology = emptyList(), ) diff --git a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/util/ExtensionTest.kt b/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/util/ExtensionTest.kt deleted file mode 100644 index bfac466d0..000000000 --- a/modules/client/src/test/kotlin/jp/co/soramitsu/iroha2/util/ExtensionTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -package jp.co.soramitsu.iroha2.util - -import jp.co.soramitsu.iroha2.ACCOUNT_ID_DELIMITER -import jp.co.soramitsu.iroha2.ASSET_ID_DELIMITER -import jp.co.soramitsu.iroha2.asAccountId -import jp.co.soramitsu.iroha2.asAssetDefinitionId -import jp.co.soramitsu.iroha2.asAssetId -import jp.co.soramitsu.iroha2.asString -import org.junit.jupiter.api.Test - -class ExtensionTest { - - @Test - fun `account ID conversion`() { - val id = "account${ACCOUNT_ID_DELIMITER}domain".asAccountId() - id.asString() - } - - @Test - fun `asset definition ID conversion`() { - val id = "asset${ASSET_ID_DELIMITER}domain".asAssetDefinitionId() - id.asString() - } - - @Test - fun `asset ID conversion`() { - val definitionId = "asset${ASSET_ID_DELIMITER}domain".asAssetDefinitionId() - val accountId = "account${ACCOUNT_ID_DELIMITER}domain".asAccountId() - val assetId = (definitionId.asString() + ASSET_ID_DELIMITER + accountId.asString()).asAssetId() - assetId.asString() - } - - @Test - fun `asset ID with account domain conversion`() { - val accountId = "account${ACCOUNT_ID_DELIMITER}domain".asAccountId() - val assetId = "asset$ASSET_ID_DELIMITER$ASSET_ID_DELIMITER${accountId.asString()}".asAssetId() - assetId.asString() - } -} 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 515a2dfa3..272357a69 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/create_nft_for_alice_smartcontract/.cargo/config.toml b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/.cargo/config.toml similarity index 100% rename from modules/client/src/test/create_nft_for_alice_smartcontract/.cargo/config.toml rename to modules/client/src/test/resources/create_nft_for_alice_smartcontract/.cargo/config.toml diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/Cargo.toml similarity index 89% rename from modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml rename to modules/client/src/test/resources/create_nft_for_alice_smartcontract/Cargo.toml index 64f8753c9..a723e6eb4 100644 --- a/modules/client/src/test/create_nft_for_alice_smartcontract/Cargo.toml +++ b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "create_nft_for_alice_smartcontract" -version = "2.0.0-pre-rc.3" +version = "2.0.0-pre-rc.22.2" # TODO: teams are being deprecated update the authors URL authors = ["Iroha 2 team "] edition = "2021" @@ -22,7 +22,9 @@ 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_trigger = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } +iroha_trigger = { git = "https://github.com/hyperledger/iroha/", tag = "v2.0.0-pre-rc.22.2", features = ["debug"] } + +getrandom = { version = "0.2", features = ["custom"] } lol_alloc = "0.4.0" panic-halt = "0.2.0" diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/README.md b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/README.md similarity index 100% rename from modules/client/src/test/create_nft_for_alice_smartcontract/README.md rename to modules/client/src/test/resources/create_nft_for_alice_smartcontract/README.md diff --git a/modules/client/src/test/resources/create_nft_for_alice_smartcontract/build.sh b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/build.sh new file mode 100755 index 000000000..b80cf0267 --- /dev/null +++ b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cargo +nightly-2024-04-18 build --release -Zbuild-std -Zbuild-std-features=panic_immediate_abort +cp ./target/wasm32-unknown-unknown/release/create_nft_for_alice_smartcontract.wasm ../create_nft_for_alice_smartcontract.wasm diff --git a/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/src/lib.rs similarity index 56% rename from modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs rename to modules/client/src/test/resources/create_nft_for_alice_smartcontract/src/lib.rs index 431f27fb9..f4389fbc5 100644 --- a/modules/client/src/test/create_nft_for_alice_smartcontract/src/lib.rs +++ b/modules/client/src/test/resources/create_nft_for_alice_smartcontract/src/lib.rs @@ -8,53 +8,53 @@ extern crate alloc; #[cfg(not(test))] extern crate panic_halt; -use alloc::{format, string::ToString, vec::Vec}; +use alloc::{format, string::ToString}; use lol_alloc::{FreeListAllocator, LockedAllocator}; #[global_allocator] static ALLOC: LockedAllocator = LockedAllocator::new(FreeListAllocator::new()); -use iroha_trigger::{data_model::prelude::*, debug::DebugUnwrapExt, smart_contract::QueryHost}; +use iroha_trigger::{prelude::*}; #[iroha_trigger::main] -fn smartcontract_entry_point(_id: TriggerId, _owner: AccountId, _event: Event) { - let account_id: AccountId = "alice@wonderland".parse().unwrap(); - let limits = MetadataLimits::new(256, 256); - let mut metadata = Metadata::new(); - +fn main(_id: TriggerId, _owner: AccountId, _event: EventBox) { + let account_id: AccountId = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland".parse().unwrap(); + let mut metadata = Metadata::default(); let name = format!( "nft_for_{}_in_{}", - account_id.name(), - account_id.domain_id() + account_id.signatory(), + account_id.domain() ) .parse() .dbg_unwrap(); - metadata - .insert_with_limits(name, true.into(), limits) - .dbg_unwrap(); + metadata.insert(name, true); let nft_id = generate_new_nft_id(&account_id); let nft_definition = AssetDefinition::store(nft_id.clone()) .mintable_once() .with_metadata(metadata); - RegisterExpr::new(nft_definition).execute().dbg_unwrap(); - SetKeyValueExpr::new( + Register::asset_definition(nft_definition) + .execute() + .dbg_unwrap(); + SetKeyValue::asset( AssetId::new(nft_id, account_id), "has_this_nft".parse::().dbg_unwrap(), - Value::Bool(true), + true, ) .execute() .dbg_unwrap(); } fn generate_new_nft_id(account_id: &AccountId) -> AssetDefinitionId { - let query = FindAssetsByAccountId::new(account_id.clone()); - let assets: Vec = query.execute().dbg_unwrap(); + let assets = FindAssetsByAccountId::new(account_id.clone()) + .execute() + .dbg_unwrap(); let new_number = assets .into_iter() - .filter(|asset| asset.id().definition_id().to_string().starts_with("nft_")) + .map(|res| res.dbg_unwrap()) + .filter(|asset| asset.id().definition().to_string().starts_with("nft_")) .count() .checked_add(1) .dbg_unwrap(); @@ -62,8 +62,8 @@ fn generate_new_nft_id(account_id: &AccountId) -> AssetDefinitionId { format!( "nft_number_{}_for_{}#{}", new_number, - account_id.name(), - account_id.domain_id() + account_id.signatory(), + account_id.domain() ) .parse() .dbg_unwrap() diff --git a/modules/client/src/test/resources/executor.wasm b/modules/client/src/test/resources/executor.wasm old mode 100755 new mode 100644 index d82fc4924..f51b51123 Binary files a/modules/client/src/test/resources/executor.wasm and b/modules/client/src/test/resources/executor.wasm differ diff --git a/modules/client/src/test/executor/.cargo/config.toml b/modules/client/src/test/resources/executor/.cargo/config.toml similarity index 100% rename from modules/client/src/test/executor/.cargo/config.toml rename to modules/client/src/test/resources/executor/.cargo/config.toml diff --git a/modules/client/src/test/executor/Cargo.toml b/modules/client/src/test/resources/executor/Cargo.toml similarity index 82% rename from modules/client/src/test/executor/Cargo.toml rename to modules/client/src/test/resources/executor/Cargo.toml index c3339dfb3..bbaa34bf1 100644 --- a/modules/client/src/test/executor/Cargo.toml +++ b/modules/client/src/test/resources/executor/Cargo.toml @@ -19,8 +19,9 @@ codegen-units = 1 # Further reduces binary size but increases compilation time crate-type = ['cdylib'] [dependencies] -iroha_executor = { git = "https://github.com/hyperledger/iroha/", branch = "iroha2-stable", features = ["debug"] } +iroha_executor = { git = "https://github.com/hyperledger/iroha/", tag = "v2.0.0-pre-rc.22.1", features = ["debug"] } -lol_alloc = "0.4.0" +getrandom = { version = "0.2", features = ["custom"] } +dlmalloc = { version = "0.2.6", features = ["global"] } panic-halt = "0.2.0" diff --git a/modules/client/src/test/executor/build.sh b/modules/client/src/test/resources/executor/build.sh similarity index 53% rename from modules/client/src/test/executor/build.sh rename to modules/client/src/test/resources/executor/build.sh index 9a6e9d9c2..0e095603f 100755 --- a/modules/client/src/test/executor/build.sh +++ b/modules/client/src/test/resources/executor/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_executor.wasm ../resources/executor.wasm +cargo +nightly-2024-04-18 build --release -Zbuild-std -Zbuild-std-features=panic_immediate_abort +cp ./target/wasm32-unknown-unknown/release/iroha_java_executor.wasm ../executor.wasm diff --git a/modules/client/src/test/resources/executor/src/lib.rs b/modules/client/src/test/resources/executor/src/lib.rs new file mode 100644 index 000000000..9fc907296 --- /dev/null +++ b/modules/client/src/test/resources/executor/src/lib.rs @@ -0,0 +1,52 @@ +//! Iroha default executor. + +#![no_std] + +extern crate alloc; +#[cfg(not(test))] +extern crate panic_halt; + +use dlmalloc::GlobalDlmalloc; +use iroha_executor::{debug::dbg_panic, prelude::*, DataModelBuilder}; + +#[global_allocator] +static ALLOC: GlobalDlmalloc = GlobalDlmalloc; + +getrandom::register_custom_getrandom!(iroha_executor::stub_getrandom); + +/// Executor that replaces some of [`Validate`]'s methods with sensible defaults +/// +/// # Warning +/// +/// The defaults are not guaranteed to be stable. +#[derive(Debug, Clone, Constructor, Visit, Validate, ValidateEntrypoints)] +pub struct Executor { + verdict: Result, + block_height: u64, +} + +impl Executor { + fn ensure_genesis(block_height: u64) { + if block_height != 0 { + dbg_panic( + "Default Executor is intended to be used only in genesis. \ + Write your own executor if you need to upgrade executor on existing chain.", + ); + } + } +} + +/// 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 executor will stay unchanged. +#[entrypoint] +fn migrate(block_height: u64) { + Executor::ensure_genesis(block_height); + DataModelBuilder::with_default_permissions().build_and_set(); +} diff --git a/modules/client/src/test/resources/genesis.json b/modules/client/src/test/resources/genesis.json index 657cb63b7..955c808b0 100644 --- a/modules/client/src/test/resources/genesis.json +++ b/modules/client/src/test/resources/genesis.json @@ -1,52 +1,45 @@ { - "transactions": [ - [ - { - "Register": { - "NewDomain": { - "id": "wonderland", - "metadata": {} - } + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "./executor.wasm", + "parameters": [], + "instructions": [ + { + "Register": { + "Domain": { + "id": "wonderland", + "metadata": {} } - }, - { - "Register": { - "NewAccount": { - "id": "alice@wonderland", - "signatories": [ - "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1" - ], - "metadata": {} - } + } + }, + { + "Register": { + "Account": { + "id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "metadata": {} } - }, - { - "Register": { - "NewAccount": { - "id": "bob@wonderland", - "signatories": [ - "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" - ], - "metadata": {} - } + } + }, + { + "Register": { + "Account": { + "id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland", + "metadata": {} } - }, - { - "Grant": { + } + }, + { + "Grant": { + "Permission": { "object": { - "PermissionToken": { - "definition_id": "CanSetKeyValueInUserAccount", - "payload": { - "account_id": "alice@wonderland" - } + "name": "CanSetKeyValueInAccount", + "payload": { + "account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } }, - "destination_id": { - "AccountId": "bob@wonderland" - } + "destination": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland" } } - ] + } ], - "executor": "./executor.wasm" + "topology": [] } diff --git a/modules/client/src/test/resources/junit-platform.properties b/modules/client/src/test/resources/junit-platform.properties index 1d27b78fb..eac631d4a 100644 --- a/modules/client/src/test/resources/junit-platform.properties +++ b/modules/client/src/test/resources/junit-platform.properties @@ -1 +1,2 @@ -junit.jupiter.execution.parallel.enabled=true +#junit.jupiter.execution.parallel.enabled=true +#junit.jupiter.execution.logging.level.debug=enabled diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/AbstractGenerator.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/AbstractGenerator.kt index 7596d0212..49fe2c233 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/AbstractGenerator.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/AbstractGenerator.kt @@ -5,6 +5,7 @@ import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier import com.squareup.kotlinpoet.ParameterSpec +import com.squareup.kotlinpoet.ParameterizedTypeName import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy import com.squareup.kotlinpoet.PropertySpec import com.squareup.kotlinpoet.TypeName @@ -64,16 +65,17 @@ abstract class AbstractGenerator> { false -> className } } - - val builder = TypeSpec.companionObjectBuilder() + val companionBuilder = TypeSpec.companionObjectBuilder() .addSuperinterface(SCALE_READER.parameterizedBy(thisType)) .addSuperinterface(SCALE_WRITER.parameterizedBy(thisType)) .addFunction(readFun(thisType, blueprint)) .addFunction(writeFun(thisType, blueprint)) - return when (blueprint.properties.isEmpty() && KModifier.SEALED !in clazz.modifiers) { - true -> builder.addFunction(variantEqualsFun(blueprint)).addFunction(variantHashcodeFun(blueprint)) - false -> builder + return when { + blueprint.properties.isEmpty() && KModifier.SEALED !in clazz.modifiers -> { + companionBuilder.addFunction(variantEqualsFun(blueprint)).addFunction(variantHashcodeFun(blueprint)) + } + else -> companionBuilder } } @@ -194,4 +196,10 @@ abstract class AbstractGenerator> { .returns(Int::class) .build() } + + protected fun TypeName.extractName() = when (this) { + is ParameterizedTypeName -> this.rawType.canonicalName + is ClassName -> this.canonicalName + else -> throw RuntimeException("Unexpected type: $this") + } } diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/EnumGenerator.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/EnumGenerator.kt index 131073d44..efe137751 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/EnumGenerator.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/EnumGenerator.kt @@ -27,7 +27,6 @@ object EnumGenerator : AbstractGenerator() { override fun implConstructor(blueprint: EnumBlueprint, clazz: TypeSpec.Builder) = Unit override fun implFunctions(blueprint: EnumBlueprint, clazz: TypeSpec.Builder) { - true in blueprint.variants.map { it.properties.isEmpty() } clazz.addFunction( FunSpec.builder("discriminant") .addModifiers(KModifier.ABSTRACT) @@ -35,20 +34,7 @@ object EnumGenerator : AbstractGenerator() { .build(), ) if (true in blueprint.variants.map { it.properties.isEmpty() }) { - clazz.addFunction( - FunSpec.builder("equals") - .addParameter(ParameterSpec.builder("other", ANY_TYPE.copy(nullable = true)).build()) - .addCode(equalsCode(blueprint)) - .addModifiers(KModifier.OVERRIDE) - .returns(Boolean::class.java) - .build(), - ).addFunction( - FunSpec.builder("hashCode") - .addCode(hashcodeCode(blueprint)) - .addModifiers(KModifier.OVERRIDE) - .returns(Int::class.java) - .build(), - ) + clazz.addFunction(equalsFun(blueprint)).addFunction(hashCodeFun(blueprint)) } } @@ -85,6 +71,23 @@ object EnumGenerator : AbstractGenerator() { clazz.addSuperinterface(ModelEnum::class) } + private fun hashCodeFun(blueprint: EnumBlueprint): FunSpec { + return FunSpec.builder("hashCode") + .addCode(hashcodeCode(blueprint)) + .addModifiers(KModifier.OVERRIDE) + .returns(Int::class.java) + .build() + } + + private fun equalsFun(blueprint: EnumBlueprint): FunSpec { + return FunSpec.builder("equals") + .addParameter(ParameterSpec.builder("other", ANY_TYPE.copy(nullable = true)).build()) + .addCode(equalsCode(blueprint)) + .addModifiers(KModifier.OVERRIDE) + .returns(Boolean::class.java) + .build() + } + private fun equalsCode(blueprint: EnumBlueprint): CodeBlock { val codeBlock = CodeBlock.builder().add("return when(this) {\n") diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/Scale.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/Scale.kt index 0fc833f69..48ed9bd27 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/Scale.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/Scale.kt @@ -154,7 +154,7 @@ private fun CompositeType.scaleReadImpl(): CodeBlock { private fun OptionType.scaleReadImpl(): CodeBlock { return when (this.innerType.requireValue()) { - is U32Type, U16Type, StringType -> CodeBlock.of("reader.readNullable()") + is U64Type, U32Type, U16Type, StringType -> CodeBlock.of("reader.readNullable()") else -> resolveKotlinType(this).let { type -> CodeBlock.of( "reader.readNullable(%1T) as %2T", @@ -212,7 +212,7 @@ private fun FixedPointType.scaleWriteImpl(propName: CodeBlock): CodeBlock { private fun OptionType.scaleWriteImpl(propName: CodeBlock): CodeBlock { return when (this.innerType.requireValue()) { - is U32Type, U16Type, StringType -> CodeBlock.of( + is U64Type, U32Type, U16Type, StringType -> CodeBlock.of( "writer.writeNullable(%L)", propName, ) diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/StructGenerator.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/StructGenerator.kt index 4c770a37f..7cef21f34 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/StructGenerator.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/codegen/generator/StructGenerator.kt @@ -1,6 +1,10 @@ package jp.co.soramitsu.iroha2.codegen.generator +import com.squareup.kotlinpoet.FunSpec +import com.squareup.kotlinpoet.KModifier +import com.squareup.kotlinpoet.ParameterSpec import com.squareup.kotlinpoet.TypeSpec +import com.squareup.kotlinpoet.asTypeName import jp.co.soramitsu.iroha2.codegen.blueprint.StructBlueprint /** @@ -12,4 +16,56 @@ object StructGenerator : AbstractGenerator() { super.implKDoc(blueprint, clazz) clazz.addKdoc("\n\nGenerated from '${blueprint.source.name}' regular structure") } + + override fun implFunctions(blueprint: StructBlueprint, clazz: TypeSpec.Builder) { + super.implFunctions(blueprint, clazz) + + if (blueprint.properties.any { it.typeName.extractName() == ByteArray::class.qualifiedName }) { + clazz.addFunction(equalsFun(blueprint)).addFunction(hashCodeFun(blueprint)) + } + } + + private fun hashCodeFun(blueprint: StructBlueprint): FunSpec { + return FunSpec.builder("hashCode") + .addModifiers(KModifier.OVERRIDE) + .returns(Int::class) + .apply { + when (blueprint.properties.isEmpty()) { + true -> addStatement("return 0") + false -> { + val firstProperty = blueprint.properties[0] + when (blueprint.properties[0].typeName) { + ByteArray::class.asTypeName() -> addCode("return %L.%L()", firstProperty.name, "contentHashCode") + else -> addCode("return %L.%L()", firstProperty.name, "hashCode") + } + for ((property, type) in blueprint.properties.drop(1)) { + addCode(" * 31") + when (type) { + ByteArray::class.asTypeName() -> addCode(" + %L.contentHashCode()", property) + else -> addCode(" + %L.hashCode()", property) + } + } + addCode("\n") + } + } + }.build() + } + + private fun equalsFun(blueprint: StructBlueprint): FunSpec { + return FunSpec.builder("equals") + .addModifiers(KModifier.OVERRIDE) + .addParameter(ParameterSpec.builder("other", ANY_TYPE.copy(nullable = true)).build()) + .returns(Boolean::class) + .addStatement("if (this === other) return true") + .addStatement("if (other !is %L) return false", blueprint.className) + .apply { + for ((property, type) in blueprint.properties) { + when (type) { + ByteArray::class.asTypeName() -> addStatement("if (!%L.contentEquals(other.%L)) return false", property, property) + else -> addStatement("if (%L != other.%L) return false", property, property) + } + } + addStatement("return true") + }.build() + } } 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 1edc96eac..96eec8b50 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 @@ -52,6 +52,9 @@ class SchemaReader { return source to source.replace("<", "Of") .replace(", ", "And") .replace(">", "") + } else if (this.contains("Option>( BooleanResolver, SortedMapResolver, + BitMapResolver, OptionResolver, VectorResolver, SortedVectorResolver, @@ -94,6 +96,25 @@ object BooleanResolver : Resolver { } } +/** + * Resolver for [MapType] + */ +object BitMapResolver : Resolver { + + const val NAME = "Bitmap" + + override fun resolve(name: String, typeValue: Any?, schemaParser: SchemaParser): UIntType? { + when (typeValue) { + is Map<*, *> -> if (typeValue.keys.first() != NAME) return null + else -> return null + } + + val type = (typeValue[NAME] as Map)["repr"].toString() + + return UIntResolver.resolve(type, typeValue, schemaParser) + } +} + /** * Resolver for [MapType] */ @@ -124,10 +145,19 @@ object SortedMapResolver : Resolver { */ abstract class WrapperResolver(open val wrapperName: String) : Resolver { override fun resolve(name: String, typeValue: Any?, schemaParser: SchemaParser): T? { - if (!name.startsWith("$wrapperName<")) return null - val innerTypeName = name.removeSurrounding("$wrapperName<", ">") - val innerType = schemaParser.createAndGetNest(innerTypeName) - return createWrapper(name, innerType) + return when { + name.startsWith("$wrapperName<") -> { + val innerTypeName = name.removeSurrounding("$wrapperName<", ">") + val innerType = schemaParser.createAndGetNest(innerTypeName) + createWrapper(name, innerType) + } + name.startsWith("${wrapperName}Of") -> { + val innerTypeName = name.replace("${wrapperName}Of", "") + val innerType = schemaParser.createAndGetNest(innerTypeName) + createWrapper(name, innerType) + } + else -> null + } } /** @@ -422,7 +452,7 @@ data class TypeNest(val name: String, var value: Type?) { private var resolutionInProgress: Boolean = false - fun requireValue() = value ?: throw IllegalArgumentException("Type is not resolved: $name") + fun requireValue() = value ?: NullType fun notResolvedTypes(): Set { if (resolutionInProgress) { diff --git a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/type/Common.kt b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/type/Common.kt index 294e430a3..a3e0e330f 100644 --- a/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/type/Common.kt +++ b/modules/codegen/src/main/kotlin/jp/co/soramitsu/iroha2/type/Common.kt @@ -11,6 +11,11 @@ sealed class Type(open val name: String) { open fun notResolvedTypes(): Set = setOf() } +/** + * Boolean type + */ +object NullType : Type("null") + /** * Boolean type */ diff --git a/modules/codegen/src/main/resources/schema.json b/modules/codegen/src/main/resources/schema.json index 9c66e9410..a77385493 100644 --- a/modules/codegen/src/main/resources/schema.json +++ b/modules/codegen/src/main/resources/schema.json @@ -5,18 +5,6 @@ "name": "id", "type": "AccountId" }, - { - "name": "assets", - "type": "SortedMap" - }, - { - "name": "signatories", - "type": "SortedVec" - }, - { - "name": "signature_check_condition", - "type": "SignatureCheckCondition" - }, { "name": "metadata", "type": "Metadata" @@ -25,161 +13,145 @@ }, "AccountEvent": { "Enum": [ - { - "tag": "Asset", - "discriminant": 0, - "type": "AssetEvent" - }, { "tag": "Created", - "discriminant": 1, + "discriminant": 0, "type": "Account" }, { "tag": "Deleted", - "discriminant": 2, - "type": "AccountId" - }, - { - "tag": "AuthenticationAdded", - "discriminant": 3, + "discriminant": 1, "type": "AccountId" }, { - "tag": "AuthenticationRemoved", - "discriminant": 4, - "type": "AccountId" + "tag": "Asset", + "discriminant": 2, + "type": "AssetEvent" }, { "tag": "PermissionAdded", - "discriminant": 5, + "discriminant": 3, "type": "AccountPermissionChanged" }, { "tag": "PermissionRemoved", - "discriminant": 6, + "discriminant": 4, "type": "AccountPermissionChanged" }, { - "tag": "RoleRevoked", - "discriminant": 7, + "tag": "RoleGranted", + "discriminant": 5, "type": "AccountRoleChanged" }, { - "tag": "RoleGranted", - "discriminant": 8, + "tag": "RoleRevoked", + "discriminant": 6, "type": "AccountRoleChanged" }, { "tag": "MetadataInserted", - "discriminant": 9, + "discriminant": 7, "type": "MetadataChanged" }, { "tag": "MetadataRemoved", - "discriminant": 10, + "discriminant": 8, "type": "MetadataChanged" } ] }, "AccountEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 - }, - { - "tag": "ByDeleted", - "discriminant": 1 - }, - { - "tag": "ByAuthenticationAdded", - "discriminant": 2 - }, - { - "tag": "ByAuthenticationRemoved", - "discriminant": 3 - }, - { - "tag": "ByPermissionAdded", - "discriminant": 4 - }, - { - "tag": "ByPermissionRemoved", - "discriminant": 5 - }, - { - "tag": "ByRoleRevoked", - "discriminant": 6 - }, - { - "tag": "ByRoleGranted", - "discriminant": 7 - }, - { - "tag": "ByMetadataInserted", - "discriminant": 8 - }, - { - "tag": "ByMetadataRemoved", - "discriminant": 9 - }, - { - "tag": "ByAsset", - "discriminant": 10, - "type": "FilterOpt" - } - ] - }, - "AccountFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" - }, - { - "name": "event_filter", - "type": "FilterOpt" - } - ] + "name": "id_matcher", + "type": "Option" + }, + { + "name": "event_set", + "type": "AccountEventSet" + } + ] + }, + "AccountEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "AnyAsset", + "mask": 4 + }, + { + "name": "PermissionAdded", + "mask": 8 + }, + { + "name": "PermissionRemoved", + "mask": 16 + }, + { + "name": "RoleGranted", + "mask": 32 + }, + { + "name": "RoleRevoked", + "mask": 64 + }, + { + "name": "MetadataInserted", + "mask": 128 + }, + { + "name": "MetadataRemoved", + "mask": 256 + } + ] + } }, "AccountId": { "Struct": [ { - "name": "domain_id", + "name": "domain", "type": "DomainId" }, { - "name": "name", - "type": "Name" + "name": "signatory", + "type": "PublicKey" } ] }, "AccountPermissionChanged": { "Struct": [ { - "name": "account_id", + "name": "account", "type": "AccountId" }, { - "name": "permission_id", - "type": "Name" + "name": "permission", + "type": "Permission" } ] }, "AccountRoleChanged": { "Struct": [ { - "name": "account_id", + "name": "account", "type": "AccountId" }, { - "name": "role_id", + "name": "role", "type": "RoleId" } ] }, - "Action": { + "Action": { "Struct": [ { "name": "executable", @@ -195,7 +167,7 @@ }, { "name": "filter", - "type": "TriggeringFilterBox" + "type": "EventFilterBox" }, { "name": "metadata", @@ -203,18 +175,6 @@ } ] }, - "Add": { - "Struct": [ - { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" - } - ] - }, "Algorithm": { "Enum": [ { @@ -235,30 +195,6 @@ } ] }, - "And": { - "Struct": [ - { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" - } - ] - }, - "Array, 8>": { - "Array": { - "type": "Interval", - "len": 8 - } - }, - "Array, 4>": { - "Array": { - "type": "Interval", - "len": 4 - } - }, "Array": { "Array": { "type": "u16", @@ -292,7 +228,7 @@ "AssetChanged": { "Struct": [ { - "name": "asset_id", + "name": "asset", "type": "AssetId" }, { @@ -308,8 +244,8 @@ "type": "AssetDefinitionId" }, { - "name": "value_type", - "type": "AssetValueType" + "name": "type", + "type": "AssetType" }, { "name": "mintable", @@ -337,97 +273,100 @@ "type": "AssetDefinition" }, { - "tag": "MintabilityChanged", + "tag": "Deleted", "discriminant": 1, "type": "AssetDefinitionId" }, { - "tag": "OwnerChanged", + "tag": "MetadataInserted", "discriminant": 2, - "type": "AssetDefinitionOwnerChanged" + "type": "MetadataChanged" }, { - "tag": "Deleted", + "tag": "MetadataRemoved", "discriminant": 3, - "type": "AssetDefinitionId" + "type": "MetadataChanged" }, { - "tag": "MetadataInserted", + "tag": "MintabilityChanged", "discriminant": 4, - "type": "MetadataChanged" + "type": "AssetDefinitionId" }, { - "tag": "MetadataRemoved", + "tag": "TotalQuantityChanged", "discriminant": 5, - "type": "MetadataChanged" + "type": "AssetDefinitionTotalQuantityChanged" }, { - "tag": "TotalQuantityChanged", + "tag": "OwnerChanged", "discriminant": 6, - "type": "AssetDefinitionTotalQuantityChanged" + "type": "AssetDefinitionOwnerChanged" } ] }, "AssetDefinitionEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 - }, - { - "tag": "ByMintabilityChanged", - "discriminant": 1 - }, - { - "tag": "ByOwnerChanged", - "discriminant": 2 - }, - { - "tag": "ByDeleted", - "discriminant": 3 - }, - { - "tag": "ByMetadataInserted", - "discriminant": 4 - }, - { - "tag": "ByMetadataRemoved", - "discriminant": 5 - }, - { - "tag": "ByTotalQuantityChanged", - "discriminant": 6 - } - ] - }, - "AssetDefinitionFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" - }, - { - "name": "event_filter", - "type": "FilterOpt" - } - ] + "name": "id_matcher", + "type": "Option" + }, + { + "name": "event_set", + "type": "AssetDefinitionEventSet" + } + ] + }, + "AssetDefinitionEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "MetadataInserted", + "mask": 4 + }, + { + "name": "MetadataRemoved", + "mask": 8 + }, + { + "name": "MintabilityChanged", + "mask": 16 + }, + { + "name": "TotalQuantityChanged", + "mask": 32 + }, + { + "name": "OwnerChanged", + "mask": 64 + } + ] + } }, "AssetDefinitionId": { "Struct": [ { - "name": "name", - "type": "Name" + "name": "domain", + "type": "DomainId" }, { - "name": "domain_id", - "type": "DomainId" + "name": "name", + "type": "Name" } ] }, "AssetDefinitionOwnerChanged": { "Struct": [ { - "name": "asset_definition_id", + "name": "asset_definition", "type": "AssetDefinitionId" }, { @@ -439,12 +378,12 @@ "AssetDefinitionTotalQuantityChanged": { "Struct": [ { - "name": "asset_definition_id", + "name": "asset_definition", "type": "AssetDefinitionId" }, { "name": "total_amount", - "type": "NumericValue" + "type": "Numeric" } ] }, @@ -483,98 +422,98 @@ ] }, "AssetEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 - }, - { - "tag": "ByDeleted", - "discriminant": 1 - }, - { - "tag": "ByAdded", - "discriminant": 2 - }, - { - "tag": "ByRemoved", - "discriminant": 3 - }, - { - "tag": "ByMetadataInserted", - "discriminant": 4 - }, - { - "tag": "ByMetadataRemoved", - "discriminant": 5 - } - ] - }, - "AssetFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" - }, - { - "name": "event_filter", - "type": "FilterOpt" - } - ] + "name": "id_matcher", + "type": "Option" + }, + { + "name": "event_set", + "type": "AssetEventSet" + } + ] + }, + "AssetEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "Added", + "mask": 4 + }, + { + "name": "Removed", + "mask": 8 + }, + { + "name": "MetadataInserted", + "mask": 16 + }, + { + "name": "MetadataRemoved", + "mask": 32 + } + ] + } }, "AssetId": { "Struct": [ { - "name": "definition_id", - "type": "AssetDefinitionId" + "name": "account", + "type": "AccountId" }, { - "name": "account_id", - "type": "AccountId" + "name": "definition", + "type": "AssetDefinitionId" } ] }, - "AssetValue": { + "AssetTransferBox": { "Enum": [ { - "tag": "Quantity", + "tag": "Numeric", "discriminant": 0, - "type": "u32" - }, - { - "tag": "BigQuantity", - "discriminant": 1, - "type": "u128" - }, - { - "tag": "Fixed", - "discriminant": 2, - "type": "Fixed" + "type": "Transfer" }, { "tag": "Store", - "discriminant": 3, - "type": "Metadata" + "discriminant": 1, + "type": "Transfer" } ] }, - "AssetValueType": { + "AssetType": { "Enum": [ { - "tag": "Quantity", - "discriminant": 0 + "tag": "Numeric", + "discriminant": 0, + "type": "NumericSpec" }, { - "tag": "BigQuantity", + "tag": "Store", "discriminant": 1 - }, + } + ] + }, + "AssetValue": { + "Enum": [ { - "tag": "Fixed", - "discriminant": 2 + "tag": "Numeric", + "discriminant": 0, + "type": "Numeric" }, { "tag": "Store", - "discriminant": 3 + "discriminant": 1, + "type": "Metadata" } ] }, @@ -586,33 +525,24 @@ }, { "name": "predicate", - "type": "ValuePredicate" - } - ] - }, - "BatchedResponse": { - "Enum": [ - { - "tag": "V1", - "discriminant": 1, - "type": "BatchedResponseV1" + "type": "QueryOutputPredicate" } ] }, - "BatchedResponse>": { + "BatchedResponse": { "Enum": [ { "tag": "V1", "discriminant": 1, - "type": "BatchedResponseV1>" + "type": "BatchedResponseV1" } ] }, - "BatchedResponseV1": { + "BatchedResponseV1": { "Struct": [ { "name": "batch", - "type": "Value" + "type": "QueryOutputBox" }, { "name": "cursor", @@ -620,27 +550,27 @@ } ] }, - "BatchedResponseV1>": { + "BlockEvent": { "Struct": [ { - "name": "batch", - "type": "Vec" + "name": "header", + "type": "BlockHeader" }, { - "name": "cursor", - "type": "ForwardCursor" + "name": "status", + "type": "BlockStatus" } ] }, - "BinaryOpIncompatibleNumericValueTypesError": { + "BlockEventFilter": { "Struct": [ { - "name": "left", - "type": "NumericValue" + "name": "height", + "type": "Option>" }, { - "name": "right", - "type": "NumericValue" + "name": "status", + "type": "Option" } ] }, @@ -648,23 +578,23 @@ "Struct": [ { "name": "height", - "type": "u64" + "type": "NonZero" }, { - "name": "timestamp_ms", - "type": "u64" + "name": "prev_block_hash", + "type": "Option>" }, { - "name": "previous_block_hash", - "type": "Option>" + "name": "transactions_hash", + "type": "HashOf>" }, { - "name": "transactions_hash", - "type": "Option>>" + "name": "creation_time_ms", + "type": "u64" }, { "name": "view_change_index", - "type": "u64" + "type": "u32" }, { "name": "consensus_estimation_ms", @@ -673,23 +603,36 @@ ] }, "BlockMessage": "SignedBlock", - "BlockPayload": { + "BlockParameter": { + "Enum": [ + { + "tag": "MaxTransactions", + "discriminant": 0, + "type": "NonZero" + } + ] + }, + "BlockParameters": { "Struct": [ { - "name": "header", - "type": "BlockHeader" - }, + "name": "max_transactions", + "type": "NonZero" + } + ] + }, + "BlockPayload": { + "Struct": [ { - "name": "commit_topology", - "type": "UniqueVec" + "name": "header", + "type": "BlockHeader" }, { "name": "transactions", - "type": "Vec" + "type": "Vec" }, { "name": "event_recommendations", - "type": "Vec" + "type": "Vec" } ] }, @@ -701,1107 +644,832 @@ } ] }, - "BlockSubscriptionRequest": "NonZero", - "BurnExpr": { - "Struct": [ + "BlockSignature": { + "Tuple": [ + "u64", + "SignatureOf" + ] + }, + "BlockStatus": { + "Enum": [ { - "name": "object", - "type": "EvaluatesTo" + "tag": "Approved", + "discriminant": 0 + }, + { + "tag": "Rejected", + "discriminant": 1, + "type": "BlockRejectionReason" + }, + { + "tag": "Committed", + "discriminant": 2 }, { - "name": "destination_id", - "type": "EvaluatesTo" + "tag": "Applied", + "discriminant": 3 } ] }, - "ConditionalExpr": { + "BlockSubscriptionRequest": "NonZero", + "Burn": { "Struct": [ { - "name": "condition", - "type": "EvaluatesTo" - }, - { - "name": "then", - "type": "InstructionExpr" + "name": "object", + "type": "Numeric" }, { - "name": "otherwise", - "type": "Option" + "name": "destination", + "type": "AssetId" } ] }, - "ConfigurationEvent": { - "Enum": [ - { - "tag": "Changed", - "discriminant": 0, - "type": "ParameterId" - }, + "Burn": { + "Struct": [ { - "tag": "Created", - "discriminant": 1, - "type": "ParameterId" + "name": "object", + "type": "u32" }, { - "tag": "Deleted", - "discriminant": 2, - "type": "ParameterId" + "name": "destination", + "type": "TriggerId" } ] }, - "Container": { + "BurnBox": { "Enum": [ { - "tag": "Any", + "tag": "Asset", "discriminant": 0, - "type": "ValuePredicate" + "type": "Burn" }, { - "tag": "All", + "tag": "TriggerRepetitions", "discriminant": 1, - "type": "ValuePredicate" - }, - { - "tag": "AtIndex", - "discriminant": 2, - "type": "AtIndex" - }, - { - "tag": "ValueOfKey", - "discriminant": 3, - "type": "ValueOfKey" - }, - { - "tag": "HasKey", - "discriminant": 4, - "type": "Name" + "type": "Burn" } ] }, - "Contains": { + "CanBurnAssetWithDefinition": { "Struct": [ { - "name": "collection", - "type": "EvaluatesTo>" - }, - { - "name": "element", - "type": "EvaluatesTo" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "ContainsAll": { + "CanBurnUserAsset": { "Struct": [ { - "name": "collection", - "type": "EvaluatesTo>" - }, - { - "name": "elements", - "type": "EvaluatesTo>" + "name": "asset", + "type": "AssetId" } ] }, - "ContainsAny": { + "CanBurnUserTrigger": { "Struct": [ { - "name": "collection", - "type": "EvaluatesTo>" - }, - { - "name": "elements", - "type": "EvaluatesTo>" + "name": "trigger", + "type": "TriggerId" } ] }, - "ContextValue": { + "CanExecuteUserTrigger": { "Struct": [ { - "name": "value_name", - "type": "Name" + "name": "trigger", + "type": "TriggerId" } ] }, - "DataEntityFilter": { - "Enum": [ - { - "tag": "ByPeer", - "discriminant": 0, - "type": "FilterOpt" - }, - { - "tag": "ByDomain", - "discriminant": 1, - "type": "FilterOpt" - }, - { - "tag": "ByAccount", - "discriminant": 2, - "type": "FilterOpt" - }, - { - "tag": "ByAssetDefinition", - "discriminant": 3, - "type": "FilterOpt" - }, - { - "tag": "ByAsset", - "discriminant": 4, - "type": "FilterOpt" - }, - { - "tag": "ByTrigger", - "discriminant": 5, - "type": "FilterOpt" - }, + "CanMintAssetWithDefinition": { + "Struct": [ { - "tag": "ByRole", - "discriminant": 6, - "type": "FilterOpt" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "DataEvent": { - "Enum": [ - { - "tag": "Peer", - "discriminant": 0, - "type": "PeerEvent" - }, - { - "tag": "Domain", - "discriminant": 1, - "type": "DomainEvent" - }, - { - "tag": "Account", - "discriminant": 2, - "type": "AccountEvent" - }, - { - "tag": "AssetDefinition", - "discriminant": 3, - "type": "AssetDefinitionEvent" - }, - { - "tag": "Asset", - "discriminant": 4, - "type": "AssetEvent" - }, - { - "tag": "Trigger", - "discriminant": 5, - "type": "TriggerEvent" - }, - { - "tag": "Role", - "discriminant": 6, - "type": "RoleEvent" - }, - { - "tag": "PermissionToken", - "discriminant": 7, - "type": "PermissionTokenSchemaUpdateEvent" - }, - { - "tag": "Configuration", - "discriminant": 8, - "type": "ConfigurationEvent" - }, + "CanMintUserAsset": { + "Struct": [ { - "tag": "Executor", - "discriminant": 9, - "type": "ExecutorEvent" + "name": "asset", + "type": "AssetId" } ] }, - "Divide": { + "CanMintUserTrigger": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" + "name": "trigger", + "type": "TriggerId" } ] }, - "Domain": { + "CanRegisterAccountInDomain": { "Struct": [ { - "name": "id", + "name": "domain", "type": "DomainId" - }, - { - "name": "accounts", - "type": "SortedMap" - }, - { - "name": "asset_definitions", - "type": "SortedMap" - }, - { - "name": "asset_total_quantities", - "type": "SortedMap" - }, - { - "name": "logo", - "type": "Option" - }, - { - "name": "metadata", - "type": "Metadata" - }, - { - "name": "owned_by", - "type": "AccountId" } ] }, - "DomainEvent": { - "Enum": [ - { - "tag": "Account", - "discriminant": 0, - "type": "AccountEvent" - }, - { - "tag": "AssetDefinition", - "discriminant": 1, - "type": "AssetDefinitionEvent" - }, - { - "tag": "Created", - "discriminant": 2, - "type": "Domain" - }, + "CanRegisterAssetDefinitionInDomain": { + "Struct": [ { - "tag": "Deleted", - "discriminant": 3, + "name": "domain", "type": "DomainId" - }, - { - "tag": "MetadataInserted", - "discriminant": 4, - "type": "MetadataChanged" - }, - { - "tag": "MetadataRemoved", - "discriminant": 5, - "type": "MetadataChanged" - }, - { - "tag": "OwnerChanged", - "discriminant": 6, - "type": "DomainOwnerChanged" } ] }, - "DomainEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 - }, - { - "tag": "ByDeleted", - "discriminant": 1 - }, - { - "tag": "ByMetadataInserted", - "discriminant": 2 - }, - { - "tag": "ByMetadataRemoved", - "discriminant": 3 - }, - { - "tag": "ByOwnerChanged", - "discriminant": 4 - }, - { - "tag": "ByAccount", - "discriminant": 5, - "type": "FilterOpt" - }, + "CanRegisterAssetWithDefinition": { + "Struct": [ { - "tag": "ByAssetDefinition", - "discriminant": 6, - "type": "FilterOpt" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "DomainFilter": { + "CanRegisterUserTrigger": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" - }, - { - "name": "event_filter", - "type": "FilterOpt" + "name": "account", + "type": "AccountId" } ] }, - "DomainId": { + "CanRemoveKeyValueInAccount": { "Struct": [ { - "name": "name", - "type": "Name" + "name": "account", + "type": "AccountId" } ] }, - "DomainOwnerChanged": { + "CanRemoveKeyValueInAssetDefinition": { "Struct": [ { - "name": "domain_id", - "type": "DomainId" - }, - { - "name": "new_owner", - "type": "AccountId" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "Duration": { - "Tuple": [ - "u64", - "u32" - ] - }, - "Equal": { + "CanRemoveKeyValueInDomain": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" + "name": "domain", + "type": "DomainId" } ] }, - "EvaluatesTo": { + "CanRemoveKeyValueInTrigger": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "trigger", + "type": "TriggerId" } ] }, - "EvaluatesTo": { + "CanRemoveKeyValueInUserAsset": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset", + "type": "AssetId" } ] }, - "EvaluatesTo": { + "CanSetKeyValueInAccount": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "account", + "type": "AccountId" } ] }, - "EvaluatesTo": { + "CanSetKeyValueInAssetDefinition": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "EvaluatesTo>": { + "CanSetKeyValueInDomain": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "domain", + "type": "DomainId" } ] }, - "EvaluatesTo>": { + "CanSetKeyValueInTrigger": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "trigger", + "type": "TriggerId" } ] }, - "EvaluatesTo": { + "CanSetKeyValueInUserAsset": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset", + "type": "AssetId" } ] }, - "EvaluatesTo": { + "CanSetParameters": null, + "CanTransferAssetWithDefinition": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "EvaluatesTo": { + "CanTransferUserAsset": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset", + "type": "AssetId" } ] }, - "EvaluatesTo": { + "CanUnregisterAccount": { "Struct": [ { - "name": "expression", - "type": "Expression" - } - ] - }, - "EvaluatesTo": { - "Struct": [ - { - "name": "expression", - "type": "Expression" - } - ] - }, - "EvaluatesTo": { - "Struct": [ - { - "name": "expression", - "type": "Expression" - } - ] - }, - "EvaluatesTo": { - "Struct": [ - { - "name": "expression", - "type": "Expression" + "name": "account", + "type": "AccountId" } ] }, - "EvaluatesTo": { + "CanUnregisterAnyPeer": null, + "CanUnregisterAnyRole": null, + "CanUnregisterAssetDefinition": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "EvaluatesTo": { + "CanUnregisterAssetWithDefinition": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, - "EvaluatesTo": { + "CanUnregisterDomain": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "domain", + "type": "DomainId" } ] }, - "EvaluatesTo": { + "CanUnregisterUserAsset": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "asset", + "type": "AssetId" } ] }, - "EvaluatesTo>": { + "CanUnregisterUserTrigger": { "Struct": [ { - "name": "expression", - "type": "Expression" + "name": "account", + "type": "AccountId" } ] }, - "EvaluatesTo": { + "CanUpgradeExecutor": null, + "ChainId": "String", + "ClientQueryPayload": { "Struct": [ { - "name": "expression", - "type": "Expression" - } - ] - }, - "EvaluationError": { - "Enum": [ - { - "tag": "Math", - "discriminant": 0, - "type": "MathError" - }, - { - "tag": "Validation", - "discriminant": 1, - "type": "ValidationFail" - }, - { - "tag": "Find", - "discriminant": 2, - "type": "String" - }, - { - "tag": "Conversion", - "discriminant": 3, - "type": "String" - } - ] - }, - "Event": { - "Enum": [ - { - "tag": "Pipeline", - "discriminant": 0, - "type": "PipelineEvent" + "name": "authority", + "type": "AccountId" }, { - "tag": "Data", - "discriminant": 1, - "type": "DataEvent" + "name": "query", + "type": "QueryBox" }, { - "tag": "Time", - "discriminant": 2, - "type": "TimeEvent" + "name": "filter", + "type": "GenericPredicateBox" }, { - "tag": "ExecuteTrigger", - "discriminant": 3, - "type": "ExecuteTriggerEvent" + "name": "sorting", + "type": "Sorting" }, { - "tag": "Notification", - "discriminant": 4, - "type": "NotificationEvent" - } - ] - }, - "EventMessage": "Event", - "EventSubscriptionRequest": "FilterBox", - "Executable": { - "Enum": [ - { - "tag": "Instructions", - "discriminant": 0, - "type": "Vec" + "name": "pagination", + "type": "Pagination" }, { - "tag": "Wasm", - "discriminant": 1, - "type": "WasmSmartContract" + "name": "fetch_size", + "type": "FetchSize" } ] }, - "ExecuteTriggerEvent": { + "CommittedTransaction": { "Struct": [ { - "name": "trigger_id", - "type": "TriggerId" + "name": "value", + "type": "SignedTransaction" }, { - "name": "authority", - "type": "AccountId" + "name": "error", + "type": "Option" } ] }, - "ExecuteTriggerEventFilter": { - "Struct": [ - { - "name": "trigger_id", - "type": "TriggerId" - }, + "Compact": { + "Int": "Compact" + }, + "Compact": { + "Int": "Compact" + }, + "ConfigurationEvent": { + "Enum": [ { - "name": "authority", - "type": "AccountId" + "tag": "Changed", + "discriminant": 0, + "type": "ParameterChanged" } ] }, - "ExecuteTriggerExpr": { + "ConfigurationEventFilter": { "Struct": [ { - "name": "trigger_id", - "type": "EvaluatesTo" + "name": "event_set", + "type": "ConfigurationEventSet" } ] }, - "ExecutionTime": { + "ConfigurationEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Changed", + "mask": 1 + } + ] + } + }, + "Container": { "Enum": [ { - "tag": "PreCommit", - "discriminant": 0 + "tag": "Any", + "discriminant": 0, + "type": "QueryOutputPredicate" }, { - "tag": "Schedule", + "tag": "All", "discriminant": 1, - "type": "Schedule" + "type": "QueryOutputPredicate" + }, + { + "tag": "AtIndex", + "discriminant": 2, + "type": "AtIndex" } ] }, - "Executor": { + "CustomInstruction": { "Struct": [ { - "name": "wasm", - "type": "WasmSmartContract" + "name": "payload", + "type": "JsonString" } ] }, - "ExecutorEvent": { - "Enum": [ + "CustomParameter": { + "Struct": [ { - "tag": "Upgraded", - "discriminant": 0 + "name": "id", + "type": "CustomParameterId" + }, + { + "name": "payload", + "type": "JsonString" } ] }, - "ExecutorMode": { + "CustomParameterId": "Name", + "DataEvent": { "Enum": [ { - "tag": "Path", + "tag": "Peer", "discriminant": 0, - "type": "String" + "type": "PeerEvent" }, { - "tag": "Inline", + "tag": "Domain", "discriminant": 1, - "type": "Executor" + "type": "DomainEvent" + }, + { + "tag": "Trigger", + "discriminant": 2, + "type": "TriggerEvent" + }, + { + "tag": "Role", + "discriminant": 3, + "type": "RoleEvent" + }, + { + "tag": "Configuration", + "discriminant": 4, + "type": "ConfigurationEvent" + }, + { + "tag": "Executor", + "discriminant": 5, + "type": "ExecutorEvent" } ] }, - "Expression": { + "DataEventFilter": { "Enum": [ { - "tag": "Add", - "discriminant": 0, - "type": "Add" + "tag": "Any", + "discriminant": 0 }, { - "tag": "Subtract", + "tag": "Peer", "discriminant": 1, - "type": "Subtract" + "type": "PeerEventFilter" }, { - "tag": "Multiply", + "tag": "Domain", "discriminant": 2, - "type": "Multiply" + "type": "DomainEventFilter" }, { - "tag": "Divide", + "tag": "Account", "discriminant": 3, - "type": "Divide" + "type": "AccountEventFilter" }, { - "tag": "Mod", + "tag": "Asset", "discriminant": 4, - "type": "Mod" + "type": "AssetEventFilter" }, { - "tag": "RaiseTo", + "tag": "AssetDefinition", "discriminant": 5, - "type": "RaiseTo" + "type": "AssetDefinitionEventFilter" }, { - "tag": "Greater", + "tag": "Trigger", "discriminant": 6, - "type": "Greater" + "type": "TriggerEventFilter" }, { - "tag": "Less", + "tag": "Role", "discriminant": 7, - "type": "Less" + "type": "RoleEventFilter" }, { - "tag": "Equal", + "tag": "Configuration", "discriminant": 8, - "type": "Equal" + "type": "ConfigurationEventFilter" }, { - "tag": "Not", + "tag": "Executor", "discriminant": 9, - "type": "Not" + "type": "ExecutorEventFilter" + } + ] + }, + "Domain": { + "Struct": [ + { + "name": "id", + "type": "DomainId" }, { - "tag": "And", - "discriminant": 10, - "type": "And" + "name": "logo", + "type": "Option" }, { - "tag": "Or", - "discriminant": 11, - "type": "Or" + "name": "metadata", + "type": "Metadata" }, { - "tag": "If", - "discriminant": 12, - "type": "If" + "name": "owned_by", + "type": "AccountId" + } + ] + }, + "DomainEvent": { + "Enum": [ + { + "tag": "Created", + "discriminant": 0, + "type": "Domain" }, { - "tag": "Raw", - "discriminant": 13, - "type": "Value" + "tag": "Deleted", + "discriminant": 1, + "type": "DomainId" }, { - "tag": "Query", - "discriminant": 14, - "type": "QueryBox" + "tag": "AssetDefinition", + "discriminant": 2, + "type": "AssetDefinitionEvent" }, { - "tag": "Contains", - "discriminant": 15, - "type": "Contains" + "tag": "Account", + "discriminant": 3, + "type": "AccountEvent" }, { - "tag": "ContainsAll", - "discriminant": 16, - "type": "ContainsAll" + "tag": "MetadataInserted", + "discriminant": 4, + "type": "MetadataChanged" }, { - "tag": "ContainsAny", - "discriminant": 17, - "type": "ContainsAny" + "tag": "MetadataRemoved", + "discriminant": 5, + "type": "MetadataChanged" }, { - "tag": "Where", - "discriminant": 18, - "type": "Where" + "tag": "OwnerChanged", + "discriminant": 6, + "type": "DomainOwnerChanged" + } + ] + }, + "DomainEventFilter": { + "Struct": [ + { + "name": "id_matcher", + "type": "Option" }, { - "tag": "ContextValue", - "discriminant": 19, - "type": "ContextValue" + "name": "event_set", + "type": "DomainEventSet" + } + ] + }, + "DomainEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "AnyAssetDefinition", + "mask": 4 + }, + { + "name": "AnyAccount", + "mask": 8 + }, + { + "name": "MetadataInserted", + "mask": 16 + }, + { + "name": "MetadataRemoved", + "mask": 32 + }, + { + "name": "OwnerChanged", + "mask": 64 + } + ] + } + }, + "DomainId": { + "Struct": [ + { + "name": "name", + "type": "Name" } ] }, - "Fail": { + "DomainOwnerChanged": { "Struct": [ { - "name": "message", - "type": "String" + "name": "domain", + "type": "DomainId" + }, + { + "name": "new_owner", + "type": "AccountId" } ] }, - "FilterBox": { + "EventBox": { "Enum": [ { "tag": "Pipeline", "discriminant": 0, - "type": "PipelineEventFilter" + "type": "PipelineEventBox" }, { "tag": "Data", "discriminant": 1, - "type": "FilterOpt" + "type": "DataEvent" }, { "tag": "Time", "discriminant": 2, - "type": "TimeEventFilter" + "type": "TimeEvent" }, { "tag": "ExecuteTrigger", "discriminant": 3, - "type": "ExecuteTriggerEventFilter" + "type": "ExecuteTriggerEvent" }, { - "tag": "Notification", + "tag": "TriggerCompleted", "discriminant": 4, - "type": "NotificationEventFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, - { - "tag": "BySome", - "discriminant": 1, - "type": "AccountEventFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, - { - "tag": "BySome", - "discriminant": 1, - "type": "AccountFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, - { - "tag": "BySome", - "discriminant": 1, - "type": "AssetDefinitionEventFilter" + "type": "TriggerCompletedEvent" } ] }, - "FilterOpt": { + "EventFilterBox": { "Enum": [ { - "tag": "AcceptAll", - "discriminant": 0 + "tag": "Pipeline", + "discriminant": 0, + "type": "PipelineEventFilterBox" }, { - "tag": "BySome", + "tag": "Data", "discriminant": 1, - "type": "AssetDefinitionFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "type": "DataEventFilter" }, { - "tag": "BySome", - "discriminant": 1, - "type": "AssetEventFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "tag": "Time", + "discriminant": 2, + "type": "TimeEventFilter" }, { - "tag": "BySome", - "discriminant": 1, - "type": "AssetFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "tag": "ExecuteTrigger", + "discriminant": 3, + "type": "ExecuteTriggerEventFilter" }, { - "tag": "BySome", - "discriminant": 1, - "type": "DataEntityFilter" + "tag": "TriggerCompleted", + "discriminant": 4, + "type": "TriggerCompletedEventFilter" } ] }, - "FilterOpt": { + "EventMessage": "EventBox", + "EventSubscriptionRequest": "Vec", + "Executable": { "Enum": [ { - "tag": "AcceptAll", - "discriminant": 0 + "tag": "Instructions", + "discriminant": 0, + "type": "Vec" }, { - "tag": "BySome", + "tag": "Wasm", "discriminant": 1, - "type": "DomainEventFilter" + "type": "WasmSmartContract" } ] }, - "FilterOpt": { - "Enum": [ + "ExecuteTrigger": { + "Struct": [ { - "tag": "AcceptAll", - "discriminant": 0 + "name": "trigger", + "type": "TriggerId" }, { - "tag": "BySome", - "discriminant": 1, - "type": "DomainFilter" + "name": "args", + "type": "Option" } ] }, - "FilterOpt>": { - "Enum": [ + "ExecuteTriggerEvent": { + "Struct": [ { - "tag": "AcceptAll", - "discriminant": 0 + "name": "trigger_id", + "type": "TriggerId" }, { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" - } - ] - }, - "FilterOpt>": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "name": "authority", + "type": "AccountId" }, { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" + "name": "args", + "type": "Option" } ] }, - "FilterOpt>": { - "Enum": [ + "ExecuteTriggerEventFilter": { + "Struct": [ { - "tag": "AcceptAll", - "discriminant": 0 + "name": "trigger_id", + "type": "Option" }, { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" + "name": "authority", + "type": "Option" } ] }, - "FilterOpt>": { + "ExecutionTime": { "Enum": [ { - "tag": "AcceptAll", + "tag": "PreCommit", "discriminant": 0 }, { - "tag": "BySome", + "tag": "Schedule", "discriminant": 1, - "type": "OriginFilter" + "type": "Schedule" } ] }, - "FilterOpt>": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, + "Executor": { + "Struct": [ { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" + "name": "wasm", + "type": "WasmSmartContract" } ] }, - "FilterOpt>": { - "Enum": [ + "ExecutorDataModel": { + "Struct": [ { - "tag": "AcceptAll", - "discriminant": 0 + "name": "parameters", + "type": "SortedMap" }, { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" - } - ] - }, - "FilterOpt>": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "name": "instructions", + "type": "SortedVec" }, { - "tag": "BySome", - "discriminant": 1, - "type": "OriginFilter" - } - ] - }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "name": "permissions", + "type": "SortedVec" }, { - "tag": "BySome", - "discriminant": 1, - "type": "PeerEventFilter" + "name": "schema", + "type": "JsonString" } ] }, - "FilterOpt": { + "ExecutorEvent": { "Enum": [ { - "tag": "AcceptAll", - "discriminant": 0 - }, - { - "tag": "BySome", - "discriminant": 1, - "type": "PeerFilter" + "tag": "Upgraded", + "discriminant": 0, + "type": "ExecutorUpgrade" } ] }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, + "ExecutorEventFilter": { + "Struct": [ { - "tag": "BySome", - "discriminant": 1, - "type": "RoleEventFilter" + "name": "event_set", + "type": "ExecutorEventSet" } ] }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, - { - "tag": "BySome", - "discriminant": 1, - "type": "RoleFilter" - } - ] + "ExecutorEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Upgraded", + "mask": 1 + } + ] + } }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, + "ExecutorUpgrade": { + "Struct": [ { - "tag": "BySome", - "discriminant": 1, - "type": "TriggerEventFilter" + "name": "new_data_model", + "type": "ExecutorDataModel" } ] }, - "FilterOpt": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 - }, + "FetchSize": { + "Struct": [ { - "tag": "BySome", - "discriminant": 1, - "type": "TriggerFilter" + "name": "fetch_size", + "type": "Option>" } ] }, @@ -1809,7 +1477,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AccountId" } ] }, @@ -1817,35 +1485,27 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AccountId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" } ] }, "FindAccountsByDomainId": { "Struct": [ { - "name": "domain_id", - "type": "EvaluatesTo" - } - ] - }, - "FindAccountsByName": { - "Struct": [ - { - "name": "name", - "type": "EvaluatesTo" + "name": "domain", + "type": "DomainId" } ] }, "FindAccountsWithAsset": { "Struct": [ { - "name": "asset_definition_id", - "type": "EvaluatesTo" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, @@ -1865,7 +1525,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetId" } ] }, @@ -1873,7 +1533,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetDefinitionId" } ] }, @@ -1881,11 +1541,11 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetDefinitionId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" } ] }, @@ -1893,11 +1553,11 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" } ] }, @@ -1905,43 +1565,43 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetId" } ] }, "FindAssetsByAccountId": { "Struct": [ { - "name": "account_id", - "type": "EvaluatesTo" + "name": "account", + "type": "AccountId" } ] }, "FindAssetsByAssetDefinitionId": { "Struct": [ { - "name": "asset_definition_id", - "type": "EvaluatesTo" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, "FindAssetsByDomainId": { "Struct": [ { - "name": "domain_id", - "type": "EvaluatesTo" + "name": "domain", + "type": "DomainId" } ] }, "FindAssetsByDomainIdAndAssetDefinitionId": { "Struct": [ { - "name": "domain_id", - "type": "EvaluatesTo" + "name": "domain", + "type": "DomainId" }, { - "name": "asset_definition_id", - "type": "EvaluatesTo" + "name": "asset_definition", + "type": "AssetDefinitionId" } ] }, @@ -1949,7 +1609,7 @@ "Struct": [ { "name": "name", - "type": "EvaluatesTo" + "type": "Name" } ] }, @@ -1957,7 +1617,7 @@ "Struct": [ { "name": "hash", - "type": "EvaluatesTo>" + "type": "HashOf" } ] }, @@ -1965,7 +1625,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "DomainId" } ] }, @@ -1973,11 +1633,11 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "DomainId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" } ] }, @@ -2011,7 +1671,7 @@ { "tag": "Block", "discriminant": 5, - "type": "HashOf" + "type": "HashOf" }, { "tag": "Transaction", @@ -2034,28 +1694,23 @@ "type": "RoleId" }, { - "tag": "PermissionToken", + "tag": "Permission", "discriminant": 10, - "type": "Name" - }, - { - "tag": "Parameter", - "discriminant": 11, - "type": "ParameterId" + "type": "Permission" }, { "tag": "PublicKey", - "discriminant": 12, + "discriminant": 11, "type": "PublicKey" } ] }, - "FindPermissionTokenSchema": null, - "FindPermissionTokensByAccountId": { + "FindExecutorDataModel": null, + "FindPermissionsByAccountId": { "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AccountId" } ] }, @@ -2063,7 +1718,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "RoleId" } ] }, @@ -2071,7 +1726,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AccountId" } ] }, @@ -2079,7 +1734,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "AssetDefinitionId" } ] }, @@ -2087,15 +1742,15 @@ "Struct": [ { "name": "hash", - "type": "EvaluatesTo>" + "type": "HashOf" } ] }, "FindTransactionsByAccountId": { "Struct": [ { - "name": "account_id", - "type": "EvaluatesTo" + "name": "account", + "type": "AccountId" } ] }, @@ -2103,7 +1758,7 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "TriggerId" } ] }, @@ -2111,33 +1766,34 @@ "Struct": [ { "name": "id", - "type": "EvaluatesTo" + "type": "TriggerId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" } ] }, - "FindTriggersByDomainId": { + "FindTriggersByAuthorityDomainId": { "Struct": [ { - "name": "domain_id", - "type": "EvaluatesTo" + "name": "domain", + "type": "DomainId" } ] }, - "Fixed": "FixedPoint", - "FixedPoint": { - "FixedPoint": { - "base": "i64", - "decimal_places": 9 - } + "FindTriggersByAuthorityId": { + "Struct": [ + { + "name": "account", + "type": "AccountId" + } + ] }, "ForwardCursor": { "Struct": [ { - "name": "query_id", + "name": "query", "type": "Option" }, { @@ -2146,72 +1802,89 @@ } ] }, - "GenericPredicateBox": { + "GenericPredicateBox": { "Enum": [ { "tag": "And", "discriminant": 0, - "type": "NonTrivial>" + "type": "NonTrivial>" }, { "tag": "Or", "discriminant": 1, - "type": "NonTrivial>" + "type": "NonTrivial>" }, { "tag": "Not", "discriminant": 2, - "type": "GenericPredicateBox" + "type": "GenericPredicateBox" }, { "tag": "Raw", "discriminant": 3, - "type": "ValuePredicate" + "type": "QueryOutputPredicate" } ] }, - "GrantExpr": { + "Grant": { "Struct": [ { "name": "object", - "type": "EvaluatesTo" + "type": "Permission" }, { - "name": "destination_id", - "type": "EvaluatesTo" + "name": "destination", + "type": "AccountId" } ] }, - "Greater": { + "Grant": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" + "name": "object", + "type": "Permission" }, { - "name": "right", - "type": "EvaluatesTo" + "name": "destination", + "type": "RoleId" } ] }, - "Hash": "Array", - "HashOf>": "Hash", - "HashOf": "Hash", - "HashOf": "Hash", - "HashValue": { + "Grant": { + "Struct": [ + { + "name": "object", + "type": "RoleId" + }, + { + "name": "destination", + "type": "AccountId" + } + ] + }, + "GrantBox": { "Enum": [ { - "tag": "Transaction", + "tag": "Permission", "discriminant": 0, - "type": "HashOf" + "type": "Grant" }, { - "tag": "Block", + "tag": "Role", "discriminant": 1, - "type": "HashOf" + "type": "Grant" + }, + { + "tag": "RolePermission", + "discriminant": 2, + "type": "Grant" } ] }, + "Hash": "Array", + "HashOf": "Hash", + "HashOf>": "Hash", + "HashOf": "Hash", "IdBox": { "Enum": [ { @@ -2250,14 +1923,14 @@ "type": "RoleId" }, { - "tag": "PermissionTokenId", + "tag": "Permission", "discriminant": 7, - "type": "Name" + "type": "Permission" }, { - "tag": "ParameterId", + "tag": "CustomParameterId", "discriminant": 8, - "type": "ParameterId" + "type": "CustomParameterId" } ] }, @@ -2281,7 +1954,7 @@ { "tag": "NewRole", "discriminant": 3, - "type": "NewRole" + "type": "Role" }, { "tag": "Peer", @@ -2311,7 +1984,7 @@ { "tag": "Trigger", "discriminant": 9, - "type": "Trigger" + "type": "Trigger" }, { "tag": "Role", @@ -2319,48 +1992,101 @@ "type": "Role" }, { - "tag": "Parameter", + "tag": "CustomParameter", "discriminant": 11, - "type": "Parameter" + "type": "CustomParameter" } ] }, - "If": { - "Struct": [ + "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": "SetKeyValue", + "discriminant": 5, + "type": "SetKeyValueBox" + }, + { + "tag": "RemoveKeyValue", + "discriminant": 6, + "type": "RemoveKeyValueBox" + }, + { + "tag": "Grant", + "discriminant": 7, + "type": "GrantBox" + }, + { + "tag": "Revoke", + "discriminant": 8, + "type": "RevokeBox" + }, + { + "tag": "ExecuteTrigger", + "discriminant": 9, + "type": "ExecuteTrigger" + }, + { + "tag": "SetParameter", + "discriminant": 10, + "type": "SetParameter" + }, { - "name": "condition", - "type": "EvaluatesTo" + "tag": "Upgrade", + "discriminant": 11, + "type": "Upgrade" }, { - "name": "then", - "type": "EvaluatesTo" + "tag": "Log", + "discriminant": 12, + "type": "Log" }, { - "name": "otherwise", - "type": "EvaluatesTo" + "tag": "Custom", + "discriminant": 13, + "type": "CustomInstruction" } ] }, "InstructionEvaluationError": { "Enum": [ - { - "tag": "Expression", - "discriminant": 0, - "type": "EvaluationError" - }, { "tag": "Unsupported", - "discriminant": 1, + "discriminant": 0, "type": "InstructionType" }, { "tag": "PermissionParameter", - "discriminant": 2, + "discriminant": 1, "type": "String" }, { "tag": "Type", - "discriminant": 3, + "discriminant": 2, "type": "TypeError" } ] @@ -2402,24 +2128,14 @@ "discriminant": 6, "type": "MathError" }, - { - "tag": "Metadata", - "discriminant": 7, - "type": "MetadataError" - }, - { - "tag": "Fail", - "discriminant": 8, - "type": "String" - }, { "tag": "InvalidParameter", - "discriminant": 9, + "discriminant": 7, "type": "InvalidParameterError" }, { "tag": "InvariantViolation", - "discriminant": 10, + "discriminant": 8, "type": "String" } ] @@ -2428,7 +2144,7 @@ "Struct": [ { "name": "instruction", - "type": "InstructionExpr" + "type": "InstructionBox" }, { "name": "reason", @@ -2436,100 +2152,6 @@ } ] }, - "InstructionExpr": { - "Enum": [ - { - "tag": "Register", - "discriminant": 0, - "type": "RegisterExpr" - }, - { - "tag": "Unregister", - "discriminant": 1, - "type": "UnregisterExpr" - }, - { - "tag": "Mint", - "discriminant": 2, - "type": "MintExpr" - }, - { - "tag": "Burn", - "discriminant": 3, - "type": "BurnExpr" - }, - { - "tag": "Transfer", - "discriminant": 4, - "type": "TransferExpr" - }, - { - "tag": "If", - "discriminant": 5, - "type": "ConditionalExpr" - }, - { - "tag": "Pair", - "discriminant": 6, - "type": "PairExpr" - }, - { - "tag": "Sequence", - "discriminant": 7, - "type": "SequenceExpr" - }, - { - "tag": "SetKeyValue", - "discriminant": 8, - "type": "SetKeyValueExpr" - }, - { - "tag": "RemoveKeyValue", - "discriminant": 9, - "type": "RemoveKeyValueExpr" - }, - { - "tag": "Grant", - "discriminant": 10, - "type": "GrantExpr" - }, - { - "tag": "Revoke", - "discriminant": 11, - "type": "RevokeExpr" - }, - { - "tag": "ExecuteTrigger", - "discriminant": 12, - "type": "ExecuteTriggerExpr" - }, - { - "tag": "SetParameter", - "discriminant": 13, - "type": "SetParameterExpr" - }, - { - "tag": "NewParameter", - "discriminant": 14, - "type": "NewParameterExpr" - }, - { - "tag": "Upgrade", - "discriminant": 15, - "type": "UpgradeExpr" - }, - { - "tag": "Log", - "discriminant": 16, - "type": "LogExpr" - }, - { - "tag": "Fail", - "discriminant": 17, - "type": "Fail" - } - ] - }, "InstructionType": { "Enum": [ { @@ -2553,80 +2175,40 @@ "discriminant": 4 }, { - "tag": "If", + "tag": "SetKeyValue", "discriminant": 5 }, { - "tag": "Pair", + "tag": "RemoveKeyValue", "discriminant": 6 }, { - "tag": "Sequence", + "tag": "Grant", "discriminant": 7 }, { - "tag": "SetKeyValue", + "tag": "Revoke", "discriminant": 8 }, { - "tag": "RemoveKeyValue", + "tag": "ExecuteTrigger", "discriminant": 9 }, { - "tag": "Grant", + "tag": "SetParameter", "discriminant": 10 }, { - "tag": "Revoke", + "tag": "Upgrade", "discriminant": 11 }, { - "tag": "ExecuteTrigger", + "tag": "Log", "discriminant": 12 }, { - "tag": "SetParameter", + "tag": "Custom", "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" - }, - { - "name": "limit", - "type": "u8" } ] }, @@ -2638,40 +2220,15 @@ "type": "String" }, { - "tag": "NameLength", + "tag": "TimeTriggerInThePast", "discriminant": 1 } ] }, "IpfsPath": "String", "Ipv4Addr": "Array", - "Ipv4Predicate": "Array, 4>", "Ipv6Addr": "Array", - "Ipv6Predicate": "Array, 8>", - "LengthLimits": { - "Struct": [ - { - "name": "min", - "type": "u32" - }, - { - "name": "max", - "type": "u32" - } - ] - }, - "Less": { - "Struct": [ - { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" - } - ] - }, + "JsonString": "String", "Level": { "Enum": [ { @@ -2696,27 +2253,15 @@ } ] }, - "Limits": { - "Struct": [ - { - "name": "max_len", - "type": "u32" - }, - { - "name": "max_entry_byte_size", - "type": "u32" - } - ] - }, - "LogExpr": { + "Log": { "Struct": [ { "name": "level", - "type": "EvaluatesTo" + "type": "Level" }, { "name": "msg", - "type": "EvaluatesTo" + "type": "String" } ] }, @@ -2746,14 +2291,9 @@ "tag": "Unknown", "discriminant": 5 }, - { - "tag": "BinaryOpIncompatibleNumericValueTypes", - "discriminant": 6, - "type": "BinaryOpIncompatibleNumericValueTypesError" - }, { "tag": "FixedPointConversion", - "discriminant": 7, + "discriminant": 6, "type": "String" } ] @@ -2761,18 +2301,11 @@ "MerkleTree": { "Vec": "HashOf" }, - "Metadata": { - "Struct": [ - { - "name": "map", - "type": "SortedMap" - } - ] - }, + "Metadata": "SortedMap", "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AccountId" }, { @@ -2781,14 +2314,14 @@ }, { "name": "value", - "type": "Value" + "type": "JsonString" } ] }, "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AssetDefinitionId" }, { @@ -2797,14 +2330,14 @@ }, { "name": "value", - "type": "Value" + "type": "JsonString" } ] }, "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "AssetId" }, { @@ -2813,14 +2346,14 @@ }, { "name": "value", - "type": "Value" + "type": "JsonString" } ] }, "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "DomainId" }, { @@ -2829,14 +2362,14 @@ }, { "name": "value", - "type": "Value" + "type": "JsonString" } ] }, "MetadataChanged": { "Struct": [ { - "name": "target_id", + "name": "target", "type": "TriggerId" }, { @@ -2845,47 +2378,45 @@ }, { "name": "value", - "type": "Value" + "type": "JsonString" } ] }, - "MetadataError": { - "Enum": [ - { - "tag": "EntryTooBig", - "discriminant": 0, - "type": "SizeError" - }, + "Mint": { + "Struct": [ { - "tag": "OverallSize", - "discriminant": 1, - "type": "SizeError" + "name": "object", + "type": "Numeric" }, { - "tag": "EmptyPath", - "discriminant": 2 - }, + "name": "destination", + "type": "AssetId" + } + ] + }, + "Mint": { + "Struct": [ { - "tag": "MissingSegment", - "discriminant": 3, - "type": "Name" + "name": "object", + "type": "u32" }, { - "tag": "InvalidSegment", - "discriminant": 4, - "type": "Name" + "name": "destination", + "type": "TriggerId" } ] }, - "MintExpr": { - "Struct": [ + "MintBox": { + "Enum": [ { - "name": "object", - "type": "EvaluatesTo" + "tag": "Asset", + "discriminant": 0, + "type": "Mint" }, { - "name": "destination_id", - "type": "EvaluatesTo" + "tag": "TriggerRepetitions", + "discriminant": 1, + "type": "Mint" } ] }, @@ -2917,77 +2448,25 @@ } ] }, - "Mismatch": { + "Mismatch": { "Struct": [ { "name": "expected", - "type": "AssetDefinitionId" + "type": "AssetType" }, { "name": "actual", - "type": "AssetDefinitionId" + "type": "AssetType" } ] }, - "Mismatch": { - "Struct": [ - { - "name": "expected", - "type": "AssetValueType" - }, - { - "name": "actual", - "type": "AssetValueType" - } - ] - }, - "Mismatch": { - "Struct": [ - { - "name": "expected", - "type": "Value" - }, - { - "name": "actual", - "type": "Value" - } - ] - }, - "Mod": { - "Struct": [ - { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" - } - ] - }, - "Multiply": { - "Struct": [ - { - "name": "left", - "type": "EvaluatesTo" - }, - { - "name": "right", - "type": "EvaluatesTo" - } - ] - }, - "Name": "String", - "NewAccount": { + "Name": "String", + "NewAccount": { "Struct": [ { "name": "id", "type": "AccountId" }, - { - "name": "signatories", - "type": "SortedVec" - }, { "name": "metadata", "type": "Metadata" @@ -3001,8 +2480,8 @@ "type": "AssetDefinitionId" }, { - "name": "value_type", - "type": "AssetValueType" + "name": "type", + "type": "AssetType" }, { "name": "mintable", @@ -3034,111 +2513,73 @@ } ] }, - "NewParameterExpr": { - "Struct": [ - { - "name": "parameter", - "type": "EvaluatesTo" - } - ] - }, - "NewRole": { - "Struct": [ - { - "name": "inner", - "type": "Role" - } - ] - }, - "NonTrivial>": "Vec>", + "NonTrivial>": "Vec>", "NonZero": "u32", "NonZero": "u64", - "Not": { + "Numeric": { "Struct": [ { - "name": "expression", - "type": "EvaluatesTo" - } - ] - }, - "NotificationEvent": { - "Enum": [ - { - "tag": "TriggerCompleted", - "discriminant": 0, - "type": "TriggerCompletedEvent" - } - ] - }, - "NotificationEventFilter": { - "Enum": [ - { - "tag": "AcceptAll", - "discriminant": 0 + "name": "mantissa", + "type": "Compact" }, { - "tag": "TriggerCompleted", - "discriminant": 1, - "type": "TriggerCompletedEventFilter" + "name": "scale", + "type": "Compact" } ] }, - "NumericValue": { - "Enum": [ - { - "tag": "U32", - "discriminant": 0, - "type": "u32" - }, - { - "tag": "U64", - "discriminant": 1, - "type": "u64" - }, - { - "tag": "U128", - "discriminant": 2, - "type": "u128" - }, + "NumericSpec": { + "Struct": [ { - "tag": "Fixed", - "discriminant": 3, - "type": "Fixed" + "name": "scale", + "type": "Option" } ] }, - "Option": { - "Option": "DomainId" + "Option": { + "Option": "AccountId" }, - "Option": { - "Option": "Duration" + "Option": { + "Option": "AssetDefinitionId" }, - "Option": { - "Option": "Hash" + "Option": { + "Option": "AssetId" }, - "Option>>": { - "Option": "HashOf>" + "Option": { + "Option": "BlockStatus" }, - "Option>": { - "Option": "HashOf" + "Option": { + "Option": "DomainId" }, - "Option": { - "Option": "InstructionExpr" + "Option>": { + "Option": "HashOf" + }, + "Option>": { + "Option": "HashOf" }, "Option": { "Option": "IpfsPath" }, + "Option": { + "Option": "JsonString" + }, + "Option": { + "Option": "Name" + }, "Option>": { "Option": "NonZero" }, "Option>": { "Option": "NonZero" }, - "Option": { - "Option": "PipelineEntityKind" + "Option>>": { + "Option": "Option>" + }, + "Option": { + "Option": "PeerId" }, - "Option": { - "Option": "PipelineStatusKind" + "Option": { + "Option": "RoleId" }, "Option": { "Option": "String" @@ -3149,60 +2590,104 @@ "Option": { "Option": "TransactionRejectionReason" }, + "Option": { + "Option": "TransactionStatus" + }, "Option": { "Option": "TriggerCompletedOutcomeType" }, "Option": { "Option": "TriggerId" }, - "Or": { + "Option": { + "Option": "u32" + }, + "Option": { + "Option": "u64" + }, + "Pagination": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" + "name": "limit", + "type": "Option>" }, { - "name": "right", - "type": "EvaluatesTo" + "name": "start", + "type": "Option>" } ] }, - "OriginFilter": "AccountId", - "OriginFilter": "AssetDefinitionId", - "OriginFilter": "AssetId", - "OriginFilter": "DomainId", - "OriginFilter": "PeerId", - "OriginFilter": "RoleId", - "OriginFilter": "TriggerId", - "PairExpr": { - "Struct": [ + "Parameter": { + "Enum": [ { - "name": "left_instruction", - "type": "InstructionExpr" + "tag": "Sumeragi", + "discriminant": 0, + "type": "SumeragiParameter" + }, + { + "tag": "Block", + "discriminant": 1, + "type": "BlockParameter" + }, + { + "tag": "Transaction", + "discriminant": 2, + "type": "TransactionParameter" + }, + { + "tag": "SmartContract", + "discriminant": 3, + "type": "SmartContractParameter" + }, + { + "tag": "Executor", + "discriminant": 4, + "type": "SmartContractParameter" }, { - "name": "right_instruction", - "type": "InstructionExpr" + "tag": "Custom", + "discriminant": 5, + "type": "CustomParameter" } ] }, - "Parameter": { + "ParameterChanged": { "Struct": [ { - "name": "id", - "type": "ParameterId" + "name": "old_value", + "type": "Parameter" }, { - "name": "val", - "type": "Value" + "name": "new_value", + "type": "Parameter" } ] }, - "ParameterId": { + "Parameters": { "Struct": [ { - "name": "name", - "type": "Name" + "name": "sumeragi", + "type": "SumeragiParameters" + }, + { + "name": "block", + "type": "BlockParameters" + }, + { + "name": "transaction", + "type": "TransactionParameters" + }, + { + "name": "executor", + "type": "SmartContractParameters" + }, + { + "name": "smart_contract", + "type": "SmartContractParameters" + }, + { + "name": "custom", + "type": "SortedMap" } ] }, @@ -3229,29 +2714,32 @@ ] }, "PeerEventFilter": { - "Enum": [ - { - "tag": "ByAdded", - "discriminant": 0 - }, - { - "tag": "ByRemoved", - "discriminant": 1 - } - ] - }, - "PeerFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" + "name": "id_matcher", + "type": "Option" }, { - "name": "event_filter", - "type": "FilterOpt" + "name": "event_set", + "type": "PeerEventSet" } ] }, + "PeerEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Added", + "mask": 1 + }, + { + "name": "Removed", + "mask": 2 + } + ] + } + }, "PeerId": { "Struct": [ { @@ -3264,149 +2752,50 @@ } ] }, - "PermissionRemoved": { - "Struct": [ - { - "name": "role_id", - "type": "RoleId" - }, - { - "name": "permission_token_id", - "type": "Name" - } - ] - }, - "PermissionToken": { - "Struct": [ - { - "name": "definition_id", - "type": "Name" - }, - { - "name": "payload", - "type": "StringWithJson" - } - ] - }, - "PermissionTokenSchema": { + "Permission": { "Struct": [ { - "name": "token_ids", - "type": "Vec" - }, - { - "name": "schema", + "name": "name", "type": "String" - } - ] - }, - "PermissionTokenSchemaUpdateEvent": { - "Struct": [ - { - "name": "old_schema", - "type": "PermissionTokenSchema" }, { - "name": "new_schema", - "type": "PermissionTokenSchema" + "name": "payload", + "type": "JsonString" } ] }, - "PipelineEntityKind": { + "PipelineEventBox": { "Enum": [ - { - "tag": "Block", - "discriminant": 0 - }, { "tag": "Transaction", - "discriminant": 1 - } - ] - }, - "PipelineEvent": { - "Struct": [ - { - "name": "entity_kind", - "type": "PipelineEntityKind" - }, - { - "name": "status", - "type": "PipelineStatus" - }, - { - "name": "hash", - "type": "Hash" - } - ] - }, - "PipelineEventFilter": { - "Struct": [ - { - "name": "entity_kind", - "type": "Option" - }, - { - "name": "status_kind", - "type": "Option" - }, - { - "name": "hash", - "type": "Option" - } - ] - }, - "PipelineRejectionReason": { - "Enum": [ - { - "tag": "Block", "discriminant": 0, - "type": "BlockRejectionReason" + "type": "TransactionEvent" }, { - "tag": "Transaction", + "tag": "Block", "discriminant": 1, - "type": "TransactionRejectionReason" + "type": "BlockEvent" } ] }, - "PipelineStatus": { + "PipelineEventFilterBox": { "Enum": [ { - "tag": "Validating", - "discriminant": 0 + "tag": "Transaction", + "discriminant": 0, + "type": "TransactionEventFilter" }, { - "tag": "Rejected", + "tag": "Block", "discriminant": 1, - "type": "PipelineRejectionReason" - }, - { - "tag": "Committed", - "discriminant": 2 - } - ] - }, - "PipelineStatusKind": { - "Enum": [ - { - "tag": "Validating", - "discriminant": 0 - }, - { - "tag": "Rejected", - "discriminant": 1 - }, - { - "tag": "Committed", - "discriminant": 2 + "type": "BlockEventFilter" } ] }, "PublicKey": { "Struct": [ { - "name": "digest_function", + "name": "algorithm", "type": "Algorithm" }, { @@ -3432,165 +2821,165 @@ "discriminant": 2, "type": "FindAccountKeyValueByIdAndKey" }, - { - "tag": "FindAccountsByName", - "discriminant": 3, - "type": "FindAccountsByName" - }, { "tag": "FindAccountsByDomainId", - "discriminant": 4, + "discriminant": 3, "type": "FindAccountsByDomainId" }, { "tag": "FindAccountsWithAsset", - "discriminant": 5, + "discriminant": 4, "type": "FindAccountsWithAsset" }, { "tag": "FindAllAssets", - "discriminant": 6, + "discriminant": 5, "type": "FindAllAssets" }, { "tag": "FindAllAssetsDefinitions", - "discriminant": 7, + "discriminant": 6, "type": "FindAllAssetsDefinitions" }, { "tag": "FindAssetById", - "discriminant": 8, + "discriminant": 7, "type": "FindAssetById" }, { "tag": "FindAssetDefinitionById", - "discriminant": 9, + "discriminant": 8, "type": "FindAssetDefinitionById" }, { "tag": "FindAssetsByName", - "discriminant": 10, + "discriminant": 9, "type": "FindAssetsByName" }, { "tag": "FindAssetsByAccountId", - "discriminant": 11, + "discriminant": 10, "type": "FindAssetsByAccountId" }, { "tag": "FindAssetsByAssetDefinitionId", - "discriminant": 12, + "discriminant": 11, "type": "FindAssetsByAssetDefinitionId" }, { "tag": "FindAssetsByDomainId", - "discriminant": 13, + "discriminant": 12, "type": "FindAssetsByDomainId" }, { "tag": "FindAssetsByDomainIdAndAssetDefinitionId", - "discriminant": 14, + "discriminant": 13, "type": "FindAssetsByDomainIdAndAssetDefinitionId" }, { "tag": "FindAssetQuantityById", - "discriminant": 15, + "discriminant": 14, "type": "FindAssetQuantityById" }, { "tag": "FindTotalAssetQuantityByAssetDefinitionId", - "discriminant": 16, + "discriminant": 15, "type": "FindTotalAssetQuantityByAssetDefinitionId" }, { "tag": "FindAssetKeyValueByIdAndKey", - "discriminant": 17, + "discriminant": 16, "type": "FindAssetKeyValueByIdAndKey" }, { "tag": "FindAssetDefinitionKeyValueByIdAndKey", - "discriminant": 18, + "discriminant": 17, "type": "FindAssetDefinitionKeyValueByIdAndKey" }, { "tag": "FindAllDomains", - "discriminant": 19, + "discriminant": 18, "type": "FindAllDomains" }, { "tag": "FindDomainById", - "discriminant": 20, + "discriminant": 19, "type": "FindDomainById" }, { "tag": "FindDomainKeyValueByIdAndKey", - "discriminant": 21, + "discriminant": 20, "type": "FindDomainKeyValueByIdAndKey" }, { "tag": "FindAllPeers", - "discriminant": 22, + "discriminant": 21, "type": "FindAllPeers" }, { "tag": "FindAllBlocks", - "discriminant": 23, + "discriminant": 22, "type": "FindAllBlocks" }, { "tag": "FindAllBlockHeaders", - "discriminant": 24, + "discriminant": 23, "type": "FindAllBlockHeaders" }, { "tag": "FindBlockHeaderByHash", - "discriminant": 25, + "discriminant": 24, "type": "FindBlockHeaderByHash" }, { "tag": "FindAllTransactions", - "discriminant": 26, + "discriminant": 25, "type": "FindAllTransactions" }, { "tag": "FindTransactionsByAccountId", - "discriminant": 27, + "discriminant": 26, "type": "FindTransactionsByAccountId" }, { "tag": "FindTransactionByHash", - "discriminant": 28, + "discriminant": 27, "type": "FindTransactionByHash" }, { - "tag": "FindPermissionTokensByAccountId", - "discriminant": 29, - "type": "FindPermissionTokensByAccountId" + "tag": "FindPermissionsByAccountId", + "discriminant": 28, + "type": "FindPermissionsByAccountId" }, { - "tag": "FindPermissionTokenSchema", - "discriminant": 30, - "type": "FindPermissionTokenSchema" + "tag": "FindExecutorDataModel", + "discriminant": 29, + "type": "FindExecutorDataModel" }, { "tag": "FindAllActiveTriggerIds", - "discriminant": 31, + "discriminant": 30, "type": "FindAllActiveTriggerIds" }, { "tag": "FindTriggerById", - "discriminant": 32, + "discriminant": 31, "type": "FindTriggerById" }, { "tag": "FindTriggerKeyValueByIdAndKey", - "discriminant": 33, + "discriminant": 32, "type": "FindTriggerKeyValueByIdAndKey" }, { - "tag": "FindTriggersByDomainId", + "tag": "FindTriggersByAuthorityId", + "discriminant": 33, + "type": "FindTriggersByAuthorityId" + }, + { + "tag": "FindTriggersByAuthorityDomainId", "discriminant": 34, - "type": "FindTriggersByDomainId" + "type": "FindTriggersByAuthorityDomainId" }, { "tag": "FindAllRoles", @@ -3622,123 +3011,331 @@ "QueryExecutionFail": { "Enum": [ { - "tag": "Signature", + "tag": "Find", "discriminant": 0, - "type": "String" + "type": "FindError" }, { - "tag": "Evaluate", + "tag": "Conversion", "discriminant": 1, "type": "String" }, { - "tag": "Find", + "tag": "UnknownCursor", + "discriminant": 2 + }, + { + "tag": "FetchSizeTooBig", + "discriminant": 3 + }, + { + "tag": "InvalidSingularParameters", + "discriminant": 4 + }, + { + "tag": "CapacityLimit", + "discriminant": 5 + } + ] + }, + "QueryOutputBox": { + "Enum": [ + { + "tag": "Id", + "discriminant": 0, + "type": "IdBox" + }, + { + "tag": "Identifiable", + "discriminant": 1, + "type": "IdentifiableBox" + }, + { + "tag": "Transaction", "discriminant": 2, - "type": "FindError" + "type": "TransactionQueryOutput" }, { - "tag": "Conversion", + "tag": "Permission", "discriminant": 3, - "type": "String" + "type": "Permission" + }, + { + "tag": "Parameters", + "discriminant": 4, + "type": "Parameters" + }, + { + "tag": "Metadata", + "discriminant": 5, + "type": "JsonString" + }, + { + "tag": "Numeric", + "discriminant": 6, + "type": "Numeric" + }, + { + "tag": "BlockHeader", + "discriminant": 7, + "type": "BlockHeader" + }, + { + "tag": "Block", + "discriminant": 8, + "type": "SignedBlock" + }, + { + "tag": "ExecutorDataModel", + "discriminant": 9, + "type": "ExecutorDataModel" + }, + { + "tag": "Vec", + "discriminant": 10, + "type": "Vec" } ] }, - "QueryPayload": { - "Struct": [ + "QueryOutputPredicate": { + "Enum": [ { - "name": "authority", - "type": "AccountId" + "tag": "Identifiable", + "discriminant": 0, + "type": "StringPredicate" }, { - "name": "query", - "type": "QueryBox" + "tag": "Container", + "discriminant": 1, + "type": "Container" }, { - "name": "filter", - "type": "GenericPredicateBox" + "tag": "Display", + "discriminant": 2, + "type": "StringPredicate" + }, + { + "tag": "Numerical", + "discriminant": 3, + "type": "SemiRange" + }, + { + "tag": "TimeStamp", + "discriminant": 4, + "type": "SemiInterval" + }, + { + "tag": "Pass", + "discriminant": 5 } ] }, - "RaiseTo": { + "QuerySignature": "SignatureOf", + "RawGenesisTransaction": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" + "name": "chain", + "type": "ChainId" + }, + { + "name": "executor", + "type": "String" + }, + { + "name": "parameters", + "type": "Vec" + }, + { + "name": "instructions", + "type": "Vec" }, { - "name": "right", - "type": "EvaluatesTo" + "name": "topology", + "type": "Vec" } ] }, - "RawGenesisBlock": { + "Register": { "Struct": [ { - "name": "transactions", - "type": "Vec>" - }, + "name": "object", + "type": "NewAccount" + } + ] + }, + "Register": { + "Struct": [ { - "name": "executor", - "type": "ExecutorMode" + "name": "object", + "type": "Asset" } ] }, - "RegisterExpr": { + "Register": { "Struct": [ { "name": "object", - "type": "EvaluatesTo" + "type": "NewAssetDefinition" } ] }, - "RegistrableBox": { + "Register": { + "Struct": [ + { + "name": "object", + "type": "NewDomain" + } + ] + }, + "Register": { + "Struct": [ + { + "name": "object", + "type": "Peer" + } + ] + }, + "Register": { + "Struct": [ + { + "name": "object", + "type": "Role" + } + ] + }, + "Register": { + "Struct": [ + { + "name": "object", + "type": "Trigger" + } + ] + }, + "RegisterBox": { "Enum": [ { "tag": "Peer", "discriminant": 0, - "type": "Peer" + "type": "Register" }, { "tag": "Domain", "discriminant": 1, - "type": "NewDomain" + "type": "Register" }, { "tag": "Account", "discriminant": 2, - "type": "NewAccount" + "type": "Register" }, { "tag": "AssetDefinition", "discriminant": 3, - "type": "NewAssetDefinition" + "type": "Register" }, { "tag": "Asset", "discriminant": 4, - "type": "Asset" + "type": "Register" }, { - "tag": "Trigger", + "tag": "Role", "discriminant": 5, - "type": "Trigger" + "type": "Register" }, { - "tag": "Role", + "tag": "Trigger", "discriminant": 6, - "type": "NewRole" + "type": "Register" + } + ] + }, + "RemoveKeyValue": { + "Struct": [ + { + "name": "object", + "type": "AccountId" + }, + { + "name": "key", + "type": "Name" } ] }, - "RemoveKeyValueExpr": { + "RemoveKeyValue": { "Struct": [ { - "name": "object_id", - "type": "EvaluatesTo" + "name": "object", + "type": "AssetId" + }, + { + "name": "key", + "type": "Name" + } + ] + }, + "RemoveKeyValue": { + "Struct": [ + { + "name": "object", + "type": "AssetDefinitionId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" + } + ] + }, + "RemoveKeyValue": { + "Struct": [ + { + "name": "object", + "type": "DomainId" + }, + { + "name": "key", + "type": "Name" + } + ] + }, + "RemoveKeyValue": { + "Struct": [ + { + "name": "object", + "type": "TriggerId" + }, + { + "name": "key", + "type": "Name" + } + ] + }, + "RemoveKeyValueBox": { + "Enum": [ + { + "tag": "Domain", + "discriminant": 0, + "type": "RemoveKeyValue" + }, + { + "tag": "Account", + "discriminant": 1, + "type": "RemoveKeyValue" + }, + { + "tag": "AssetDefinition", + "discriminant": 2, + "type": "RemoveKeyValue" + }, + { + "tag": "Asset", + "discriminant": 3, + "type": "RemoveKeyValue" + }, + { + "tag": "Trigger", + "discriminant": 4, + "type": "RemoveKeyValue" } ] }, @@ -3758,7 +3355,7 @@ "RepetitionError": { "Struct": [ { - "name": "instruction_type", + "name": "instruction", "type": "InstructionType" }, { @@ -3767,15 +3364,58 @@ } ] }, - "RevokeExpr": { + "Revoke": { + "Struct": [ + { + "name": "object", + "type": "Permission" + }, + { + "name": "destination", + "type": "AccountId" + } + ] + }, + "Revoke": { + "Struct": [ + { + "name": "object", + "type": "Permission" + }, + { + "name": "destination", + "type": "RoleId" + } + ] + }, + "Revoke": { "Struct": [ { "name": "object", - "type": "EvaluatesTo" + "type": "RoleId" + }, + { + "name": "destination", + "type": "AccountId" + } + ] + }, + "RevokeBox": { + "Enum": [ + { + "tag": "Permission", + "discriminant": 0, + "type": "Revoke" + }, + { + "tag": "Role", + "discriminant": 1, + "type": "Revoke" }, { - "name": "destination_id", - "type": "EvaluatesTo" + "tag": "RolePermission", + "discriminant": 2, + "type": "Revoke" } ] }, @@ -3787,7 +3427,7 @@ }, { "name": "permissions", - "type": "SortedVec" + "type": "SortedVec" } ] }, @@ -3804,39 +3444,51 @@ "type": "RoleId" }, { - "tag": "PermissionRemoved", + "tag": "PermissionAdded", "discriminant": 2, - "type": "PermissionRemoved" - } - ] - }, - "RoleEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 + "type": "RolePermissionChanged" }, { - "tag": "ByDeleted", - "discriminant": 1 - }, - { - "tag": "ByPermissionRemoved", - "discriminant": 2 + "tag": "PermissionRemoved", + "discriminant": 3, + "type": "RolePermissionChanged" } ] }, - "RoleFilter": { + "RoleEventFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" - }, - { - "name": "event_filter", - "type": "FilterOpt" - } - ] + "name": "id_matcher", + "type": "Option" + }, + { + "name": "event_set", + "type": "RoleEventSet" + } + ] + }, + "RoleEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "PermissionAdded", + "mask": 4 + }, + { + "name": "PermissionRemoved", + "mask": 8 + } + ] + } }, "RoleId": { "Struct": [ @@ -3846,150 +3498,184 @@ } ] }, - "Schedule": { + "RolePermissionChanged": { "Struct": [ { - "name": "start", - "type": "Duration" + "name": "role", + "type": "RoleId" }, { - "name": "period", - "type": "Option" + "name": "permission", + "type": "Permission" } ] }, - "SemiInterval": { + "Schedule": { "Struct": [ { - "name": "start", - "type": "Fixed" + "name": "start_ms", + "type": "u64" }, { - "name": "limit", - "type": "Fixed" + "name": "period_ms", + "type": "Option" } ] }, - "SemiInterval": { + "SemiInterval": { "Struct": [ { "name": "start", - "type": "u128" + "type": "Numeric" }, { "name": "limit", - "type": "u128" + "type": "Numeric" } ] }, - "SemiInterval": { + "SemiInterval": { "Struct": [ { "name": "start", - "type": "u32" + "type": "u128" }, { "name": "limit", - "type": "u32" + "type": "u128" } ] }, "SemiRange": { "Enum": [ { - "tag": "U32", + "tag": "Numeric", "discriminant": 0, - "type": "SemiInterval" + "type": "SemiInterval" + } + ] + }, + "SetKeyValue": { + "Struct": [ + { + "name": "object", + "type": "AccountId" }, { - "tag": "U128", - "discriminant": 1, - "type": "SemiInterval" + "name": "key", + "type": "Name" }, { - "tag": "Fixed", - "discriminant": 2, - "type": "SemiInterval" + "name": "value", + "type": "JsonString" } ] }, - "SequenceExpr": { + "SetKeyValue": { "Struct": [ { - "name": "instructions", - "type": "Vec" + "name": "object", + "type": "AssetId" + }, + { + "name": "key", + "type": "Name" + }, + { + "name": "value", + "type": "JsonString" } ] }, - "SetKeyValueExpr": { + "SetKeyValue": { "Struct": [ { - "name": "object_id", - "type": "EvaluatesTo" + "name": "object", + "type": "AssetDefinitionId" }, { "name": "key", - "type": "EvaluatesTo" + "type": "Name" }, { "name": "value", - "type": "EvaluatesTo" + "type": "JsonString" } ] }, - "SetParameterExpr": { + "SetKeyValue": { "Struct": [ { - "name": "parameter", - "type": "EvaluatesTo" + "name": "object", + "type": "DomainId" + }, + { + "name": "key", + "type": "Name" + }, + { + "name": "value", + "type": "JsonString" } ] }, - "Signature": { + "SetKeyValue": { "Struct": [ { - "name": "public_key", - "type": "PublicKey" + "name": "object", + "type": "TriggerId" }, { - "name": "payload", - "type": "Vec" + "name": "key", + "type": "Name" + }, + { + "name": "value", + "type": "JsonString" } ] }, - "SignatureCheckCondition": { + "SetKeyValueBox": { "Enum": [ { - "tag": "AnyAccountSignatureOr", + "tag": "Domain", "discriminant": 0, - "type": "Vec" + "type": "SetKeyValue" }, { - "tag": "AllAccountSignaturesAnd", + "tag": "Account", "discriminant": 1, - "type": "Vec" - } - ] - }, - "SignatureOf": "Signature", - "SignatureOf": "Signature", - "SignatureOf": "Signature", - "SignaturesOf": { - "Struct": [ + "type": "SetKeyValue" + }, { - "name": "signatures", - "type": "SortedVec>" + "tag": "AssetDefinition", + "discriminant": 2, + "type": "SetKeyValue" + }, + { + "tag": "Asset", + "discriminant": 3, + "type": "SetKeyValue" + }, + { + "tag": "Trigger", + "discriminant": 4, + "type": "SetKeyValue" } ] }, - "SignaturesOf": { + "SetParameter": "Parameter", + "Signature": { "Struct": [ { - "name": "signatures", - "type": "SortedVec>" + "name": "payload", + "type": "Vec" } ] }, + "SignatureOf": "Signature", + "SignatureOf": "Signature", + "SignatureOf": "Signature", "SignedBlock": { "Enum": [ { @@ -4003,7 +3689,7 @@ "Struct": [ { "name": "signatures", - "type": "SignaturesOf" + "type": "Vec" }, { "name": "payload", @@ -4024,11 +3710,11 @@ "Struct": [ { "name": "signature", - "type": "SignatureOf" + "type": "QuerySignature" }, { "name": "payload", - "type": "QueryPayload" + "type": "ClientQueryPayload" } ] }, @@ -4044,8 +3730,8 @@ "SignedTransactionV1": { "Struct": [ { - "name": "signatures", - "type": "SignaturesOf" + "name": "signature", + "type": "TransactionSignature" }, { "name": "payload", @@ -4053,15 +3739,29 @@ } ] }, - "SizeError": { + "SmartContractParameter": { + "Enum": [ + { + "tag": "Fuel", + "discriminant": 0, + "type": "NonZero" + }, + { + "tag": "Memory", + "discriminant": 1, + "type": "NonZero" + } + ] + }, + "SmartContractParameters": { "Struct": [ { - "name": "limits", - "type": "Limits" + "name": "fuel", + "type": "NonZero" }, { - "name": "actual", - "type": "u64" + "name": "memory", + "type": "NonZero" } ] }, @@ -4120,53 +3820,31 @@ } ] }, - "SortedMap": { - "Map": { - "key": "AccountId", - "value": "Account" - } - }, - "SortedMap": { - "Map": { - "key": "AssetDefinitionId", - "value": "AssetDefinition" - } - }, - "SortedMap": { - "Map": { - "key": "AssetDefinitionId", - "value": "NumericValue" - } - }, - "SortedMap": { - "Map": { - "key": "AssetId", - "value": "Asset" - } - }, - "SortedMap>": { + "SortedMap": { "Map": { - "key": "Name", - "value": "EvaluatesTo" + "key": "CustomParameterId", + "value": "CustomParameter" } }, - "SortedMap": { + "SortedMap": { "Map": { "key": "Name", - "value": "Value" + "value": "JsonString" } }, - "SortedVec": { - "Vec": "PermissionToken" - }, - "SortedVec": { - "Vec": "PublicKey" + "SortedVec": { + "Vec": "Permission" }, - "SortedVec>": { - "Vec": "SignatureOf" + "SortedVec": { + "Vec": "String" }, - "SortedVec>": { - "Vec": "SignatureOf" + "Sorting": { + "Struct": [ + { + "name": "sort_by_metadata_key", + "type": "Option" + } + ] }, "String": "String", "StringPredicate": { @@ -4193,16 +3871,38 @@ } ] }, - "StringWithJson": "String", - "Subtract": { + "SumeragiParameter": { + "Enum": [ + { + "tag": "BlockTimeMs", + "discriminant": 0, + "type": "u64" + }, + { + "tag": "CommitTimeMs", + "discriminant": 1, + "type": "u64" + }, + { + "tag": "MaxClockDriftMs", + "discriminant": 2, + "type": "u64" + } + ] + }, + "SumeragiParameters": { "Struct": [ { - "name": "left", - "type": "EvaluatesTo" + "name": "block_time_ms", + "type": "u64" + }, + { + "name": "commit_time_ms", + "type": "u64" }, { - "name": "right", - "type": "EvaluatesTo" + "name": "max_clock_drift_ms", + "type": "u64" } ] }, @@ -4222,12 +3922,44 @@ "TimeInterval": { "Struct": [ { - "name": "since", - "type": "Duration" + "name": "since_ms", + "type": "u64" + }, + { + "name": "length_ms", + "type": "u64" + } + ] + }, + "TransactionEvent": { + "Struct": [ + { + "name": "hash", + "type": "HashOf" + }, + { + "name": "block_height", + "type": "Option>" + }, + { + "name": "status", + "type": "TransactionStatus" + } + ] + }, + "TransactionEventFilter": { + "Struct": [ + { + "name": "hash", + "type": "Option>" + }, + { + "name": "block_height", + "type": "Option>>" }, { - "name": "length", - "type": "Duration" + "name": "status", + "type": "Option" } ] }, @@ -4239,28 +3971,46 @@ } ] }, - "TransactionLimits": { + "TransactionParameter": { + "Enum": [ + { + "tag": "MaxInstructions", + "discriminant": 0, + "type": "NonZero" + }, + { + "tag": "SmartContractSize", + "discriminant": 1, + "type": "NonZero" + } + ] + }, + "TransactionParameters": { "Struct": [ { - "name": "max_instruction_number", - "type": "u64" + "name": "max_instructions", + "type": "NonZero" }, { - "name": "max_wasm_size_bytes", - "type": "u64" + "name": "smart_contract_size", + "type": "NonZero" } ] }, "TransactionPayload": { "Struct": [ { - "name": "creation_time_ms", - "type": "u64" + "name": "chain", + "type": "ChainId" }, { "name": "authority", "type": "AccountId" }, + { + "name": "creation_time_ms", + "type": "u64" + }, { "name": "instructions", "type": "Executable" @@ -4275,7 +4025,7 @@ }, { "name": "metadata", - "type": "SortedMap" + "type": "Metadata" } ] }, @@ -4283,11 +4033,11 @@ "Struct": [ { "name": "block_hash", - "type": "HashOf" + "type": "HashOf" }, { "name": "transaction", - "type": "TransactionValue" + "type": "CommittedTransaction" } ] }, @@ -4317,42 +4067,115 @@ "tag": "WasmExecution", "discriminant": 4, "type": "WasmExecutionFail" + } + ] + }, + "TransactionSignature": "SignatureOf", + "TransactionStatus": { + "Enum": [ + { + "tag": "Queued", + "discriminant": 0 + }, + { + "tag": "Expired", + "discriminant": 1 + }, + { + "tag": "Approved", + "discriminant": 2 + }, + { + "tag": "Rejected", + "discriminant": 3, + "type": "TransactionRejectionReason" + } + ] + }, + "Transfer": { + "Struct": [ + { + "name": "source", + "type": "AccountId" + }, + { + "name": "object", + "type": "AssetDefinitionId" + }, + { + "name": "destination", + "type": "AccountId" + } + ] + }, + "Transfer": { + "Struct": [ + { + "name": "source", + "type": "AccountId" + }, + { + "name": "object", + "type": "DomainId" + }, + { + "name": "destination", + "type": "AccountId" + } + ] + }, + "Transfer": { + "Struct": [ + { + "name": "source", + "type": "AssetId" }, { - "tag": "Expired", - "discriminant": 5 + "name": "object", + "type": "Metadata" + }, + { + "name": "destination", + "type": "AccountId" } ] }, - "TransactionValue": { + "Transfer": { "Struct": [ { - "name": "value", - "type": "SignedTransaction" + "name": "source", + "type": "AssetId" }, { - "name": "error", - "type": "Option" + "name": "object", + "type": "Numeric" + }, + { + "name": "destination", + "type": "AccountId" } ] }, - "TransferExpr": { - "Struct": [ + "TransferBox": { + "Enum": [ { - "name": "source_id", - "type": "EvaluatesTo" + "tag": "Domain", + "discriminant": 0, + "type": "Transfer" }, { - "name": "object", - "type": "EvaluatesTo" + "tag": "AssetDefinition", + "discriminant": 1, + "type": "Transfer" }, { - "name": "destination_id", - "type": "EvaluatesTo" + "tag": "Asset", + "discriminant": 2, + "type": "AssetTransferBox" } ] }, - "Trigger": { + "Trigger": { "Struct": [ { "name": "id", @@ -4360,7 +4183,7 @@ }, { "name": "action", - "type": "Action" + "type": "Action" } ] }, @@ -4448,51 +4271,50 @@ ] }, "TriggerEventFilter": { - "Enum": [ - { - "tag": "ByCreated", - "discriminant": 0 - }, - { - "tag": "ByDeleted", - "discriminant": 1 - }, - { - "tag": "ByExtended", - "discriminant": 2 - }, - { - "tag": "ByShortened", - "discriminant": 3 - }, - { - "tag": "ByMetadataInserted", - "discriminant": 4 - }, - { - "tag": "ByMetadataRemoved", - "discriminant": 5 - } - ] - }, - "TriggerFilter": { "Struct": [ { - "name": "origin_filter", - "type": "FilterOpt>" + "name": "id_matcher", + "type": "Option" }, { - "name": "event_filter", - "type": "FilterOpt" - } - ] + "name": "event_set", + "type": "TriggerEventSet" + } + ] + }, + "TriggerEventSet": { + "Bitmap": { + "repr": "u32", + "masks": [ + { + "name": "Created", + "mask": 1 + }, + { + "name": "Deleted", + "mask": 2 + }, + { + "name": "Extended", + "mask": 4 + }, + { + "name": "Shortened", + "mask": 8 + }, + { + "name": "MetadataInserted", + "mask": 16 + }, + { + "name": "MetadataRemoved", + "mask": 32 + } + ] + } }, "TriggerId": { "Struct": [ - { - "name": "domain_id", - "type": "Option" - }, { "name": "name", "type": "Name" @@ -4502,7 +4324,7 @@ "TriggerNumberOfExecutionsChanged": { "Struct": [ { - "name": "trigger_id", + "name": "trigger", "type": "TriggerId" }, { @@ -4511,305 +4333,176 @@ } ] }, - "TriggeringFilterBox": { + "TypeError": { "Enum": [ { - "tag": "Pipeline", + "tag": "AssetType", "discriminant": 0, - "type": "PipelineEventFilter" + "type": "Mismatch" }, { - "tag": "Data", + "tag": "NumericAssetTypeExpected", "discriminant": 1, - "type": "FilterOpt" - }, - { - "tag": "Time", - "discriminant": 2, - "type": "TimeEventFilter" - }, - { - "tag": "ExecuteTrigger", - "discriminant": 3, - "type": "ExecuteTriggerEventFilter" + "type": "AssetType" } ] }, - "TypeError": { - "Enum": [ - { - "tag": "AssetValueType", - "discriminant": 0, - "type": "Mismatch" - }, - { - "tag": "ParameterValueType", - "discriminant": 1, - "type": "Mismatch" - }, + "Unregister": { + "Struct": [ { - "tag": "AssetDefinitionId", - "discriminant": 2, - "type": "Mismatch" + "name": "object", + "type": "AccountId" } ] }, - "UniqueVec": "Vec", - "UnregisterExpr": { + "Unregister": { "Struct": [ { - "name": "object_id", - "type": "EvaluatesTo" + "name": "object", + "type": "AssetId" } ] }, - "UpgradableBox": { - "Enum": [ + "Unregister": { + "Struct": [ { - "tag": "Executor", - "discriminant": 0, - "type": "Executor" + "name": "object", + "type": "AssetDefinitionId" } ] }, - "UpgradeExpr": { + "Unregister": { "Struct": [ { "name": "object", - "type": "EvaluatesTo" + "type": "DomainId" } ] }, - "ValidationFail": { - "Enum": [ - { - "tag": "NotPermitted", - "discriminant": 0, - "type": "String" - }, - { - "tag": "InstructionFailed", - "discriminant": 1, - "type": "InstructionExecutionError" - }, + "Unregister": { + "Struct": [ { - "tag": "QueryFailed", - "discriminant": 2, - "type": "QueryExecutionFail" - }, + "name": "object", + "type": "PeerId" + } + ] + }, + "Unregister": { + "Struct": [ { - "tag": "TooComplex", - "discriminant": 3 - }, + "name": "object", + "type": "RoleId" + } + ] + }, + "Unregister": { + "Struct": [ { - "tag": "InternalError", - "discriminant": 4 + "name": "object", + "type": "TriggerId" } ] }, - "Value": { + "UnregisterBox": { "Enum": [ { - "tag": "Bool", + "tag": "Peer", "discriminant": 0, - "type": "bool" + "type": "Unregister" }, { - "tag": "String", + "tag": "Domain", "discriminant": 1, - "type": "String" + "type": "Unregister" }, { - "tag": "Name", + "tag": "Account", "discriminant": 2, - "type": "Name" + "type": "Unregister" }, { - "tag": "Vec", + "tag": "AssetDefinition", "discriminant": 3, - "type": "Vec" + "type": "Unregister" }, { - "tag": "LimitedMetadata", + "tag": "Asset", "discriminant": 4, - "type": "Metadata" + "type": "Unregister" }, { - "tag": "MetadataLimits", + "tag": "Role", "discriminant": 5, - "type": "Limits" + "type": "Unregister" }, { - "tag": "TransactionLimits", + "tag": "Trigger", "discriminant": 6, - "type": "TransactionLimits" - }, - { - "tag": "LengthLimits", - "discriminant": 7, - "type": "LengthLimits" - }, - { - "tag": "Id", - "discriminant": 8, - "type": "IdBox" - }, - { - "tag": "Identifiable", - "discriminant": 9, - "type": "IdentifiableBox" - }, - { - "tag": "PublicKey", - "discriminant": 10, - "type": "PublicKey" - }, - { - "tag": "SignatureCheckCondition", - "discriminant": 11, - "type": "SignatureCheckCondition" - }, - { - "tag": "TransactionQueryOutput", - "discriminant": 12, - "type": "TransactionQueryOutput" - }, - { - "tag": "PermissionToken", - "discriminant": 13, - "type": "PermissionToken" - }, - { - "tag": "PermissionTokenSchema", - "discriminant": 14, - "type": "PermissionTokenSchema" - }, - { - "tag": "Hash", - "discriminant": 15, - "type": "HashValue" - }, - { - "tag": "Block", - "discriminant": 16, - "type": "SignedBlock" - }, - { - "tag": "BlockHeader", - "discriminant": 17, - "type": "BlockHeader" - }, - { - "tag": "Ipv4Addr", - "discriminant": 18, - "type": "Ipv4Addr" - }, - { - "tag": "Ipv6Addr", - "discriminant": 19, - "type": "Ipv6Addr" - }, - { - "tag": "Numeric", - "discriminant": 20, - "type": "NumericValue" - }, - { - "tag": "Executor", - "discriminant": 21, - "type": "Executor" - }, - { - "tag": "LogLevel", - "discriminant": 22, - "type": "Level" + "type": "Unregister" } ] }, - "ValueOfKey": { + "Upgrade": { "Struct": [ { - "name": "key", - "type": "Name" - }, - { - "name": "predicate", - "type": "ValuePredicate" + "name": "executor", + "type": "Executor" } ] }, - "ValuePredicate": { + "ValidationFail": { "Enum": [ { - "tag": "Identifiable", + "tag": "NotPermitted", "discriminant": 0, - "type": "StringPredicate" + "type": "String" }, { - "tag": "Container", + "tag": "InstructionFailed", "discriminant": 1, - "type": "Container" + "type": "InstructionExecutionError" }, { - "tag": "Display", + "tag": "QueryFailed", "discriminant": 2, - "type": "StringPredicate" - }, - { - "tag": "Numerical", - "discriminant": 3, - "type": "SemiRange" - }, - { - "tag": "TimeStamp", - "discriminant": 4, - "type": "SemiInterval" - }, - { - "tag": "Ipv4Addr", - "discriminant": 5, - "type": "Ipv4Predicate" + "type": "QueryExecutionFail" }, { - "tag": "Ipv6Addr", - "discriminant": 6, - "type": "Ipv6Predicate" + "tag": "TooComplex", + "discriminant": 3 }, { - "tag": "Pass", - "discriminant": 7 + "tag": "InternalError", + "discriminant": 4 } ] }, - "Vec": { - "Vec": "Event" + "Vec": { + "Vec": "BlockSignature" }, - "Vec>": { - "Vec": "GenericPredicateBox" + "Vec": { + "Vec": "CommittedTransaction" }, - "Vec": { - "Vec": "InstructionExpr" + "Vec": { + "Vec": "EventBox" }, - "Vec": { - "Vec": "Name" - }, - "Vec": { - "Vec": "PeerId" + "Vec": { + "Vec": "EventFilterBox" }, - "Vec": { - "Vec": "PublicKey" + "Vec>": { + "Vec": "GenericPredicateBox" }, - "Vec": { - "Vec": "SignedTransaction" + "Vec": { + "Vec": "InstructionBox" }, - "Vec": { - "Vec": "TransactionValue" + "Vec": { + "Vec": "Parameter" }, - "Vec": { - "Vec": "Value" + "Vec": { + "Vec": "PeerId" }, - "Vec>": { - "Vec": "Vec" + "Vec": { + "Vec": "QueryOutputBox" }, "Vec": { "Vec": "u8" @@ -4823,22 +4516,6 @@ ] }, "WasmSmartContract": "Vec", - "Where": { - "Struct": [ - { - "name": "expression", - "type": "EvaluatesTo" - }, - { - "name": "values", - "type": "SortedMap>" - } - ] - }, - "bool": "bool", - "i64": { - "Int": "FixedWidth" - }, "u128": { "Int": "FixedWidth" }, @@ -4854,4 +4531,4 @@ "u8": { "Int": "FixedWidth" } -} +} \ No newline at end of file diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/Comparators.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/Comparators.kt index b0e131676..ca4855f18 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/Comparators.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/Comparators.kt @@ -3,8 +3,9 @@ package jp.co.soramitsu.iroha2 import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.generated.CustomParameterId import jp.co.soramitsu.iroha2.generated.Name -import jp.co.soramitsu.iroha2.generated.PermissionToken +import jp.co.soramitsu.iroha2.generated.Permission import jp.co.soramitsu.iroha2.generated.PublicKey import jp.co.soramitsu.iroha2.generated.RoleId import jp.co.soramitsu.iroha2.generated.SignatureOf @@ -26,15 +27,16 @@ fun Name.Companion.comparator() = compareBy { it.string } * Compare account IDs */ @JvmName("AccountIdComparator") -fun AccountId.Companion.comparator() = compareBy { it.name.string } - .thenBy { it.domainId.name.string } +fun AccountId.Companion.comparator() = compareBy { it.domain.name.string }.thenComparator { o1, o2 -> + PublicKey.comparator().compare(o1.signatory, o2.signatory) +} /** * Compare asset definition IDs */ @JvmName("AssetDefinitionIdComparator") fun AssetDefinitionId.Companion.comparator() = compareBy { it.name.string } - .thenBy { it.domainId.name.string } + .thenBy { it.domain.name.string } /** * Compare asset IDs @@ -42,11 +44,11 @@ fun AssetDefinitionId.Companion.comparator() = compareBy { it @JvmName("AssetIdComparator") fun AssetId.Companion.comparator() = Comparator { o1, o2 -> AssetDefinitionId.comparator().compare( - o1.definitionId, - o2.definitionId, + o1.definition, + o2.definition, ) }.thenComparator { o1, o2 -> - AccountId.comparator().compare(o1.accountId, o2.accountId) + AccountId.comparator().compare(o1.account, o2.account) } /** @@ -68,11 +70,6 @@ fun PublicKey.Companion.comparator() = Comparator { o1, o2 -> */ @JvmName("SignatureOfComparator") fun SignatureOf.Companion.comparator() = Comparator> { o1, o2 -> - PublicKey.comparator().compare( - o1.signature.publicKey, - o2.signature.publicKey, - ) -}.thenComparator { o1, o2 -> ByteArray::class.comparator().compare( o1.signature.payload, o2.signature.payload, @@ -80,13 +77,21 @@ fun SignatureOf.Companion.comparator() = Comparator> { o1, o2 -> } /** - * Compare permission tokens + * Compare permissions */ -@JvmName("PermissionTokenComparator") -fun PermissionToken.Companion.comparator() = compareBy { - it.definitionId.string +@JvmName("PermissionComparator") +fun Permission.Companion.comparator() = compareBy { + it.name }.thenComparator { o1, o2 -> - o1.payload.string.compareTo(o2.payload.string) + o1.payload?.compareTo(o2.payload ?: "") ?: 0 +} + +/** + * Compare custom parameter ID + */ +@JvmName("CustomParameterIdComparator") +fun CustomParameterId.Companion.comparator() = compareBy { + it.name.string } private fun KClass.comparator() = Comparator { o1, o2 -> diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecReader.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecReader.kt index 4388640dc..8f5ef34df 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecReader.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecReader.kt @@ -71,7 +71,8 @@ class ScaleCodecReader(private val source: ByteArray) { if (scaleReader is BoolReader || scaleReader is BoolNullableReader) { return BOOL_NULLABLE.read(this) as T? } - return when (readBoolean()) { + val nullable = readBoolean() + return when (nullable) { true -> read(scaleReader) else -> null } @@ -79,6 +80,10 @@ class ScaleCodecReader(private val source: ByteArray) { inline fun readNullable(): T? { return when (T::class) { + BigInteger::class -> when (readBoolean()) { + true -> readUint64() + else -> null + } as T? Long::class -> when (readBoolean()) { true -> readUint32() else -> null diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecWriter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecWriter.kt index 6f64a82c8..c0d00be31 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecWriter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/codec/ScaleCodecWriter.kt @@ -76,6 +76,7 @@ class ScaleCodecWriter(private val out: OutputStream) : Closeable { inline fun writeNullable(value: T?) { when (value) { + is BigInteger -> BOOL.write(this, true).also { writeUint64(value) } is Long -> BOOL.write(this, true).also { writeUint32(value) } is Int -> BOOL.write(this, true).also { writeUint16(value) } is String -> BOOL.write(this, true).also { writeAsList(value.toByteArray(Charsets.UTF_8)) } 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 2d6a33ea0..ed68718cc 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 @@ -7,11 +7,8 @@ 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.comparator import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit -import kotlin.collections.List -import kotlin.collections.Map /** * Account @@ -20,18 +17,12 @@ import kotlin.collections.Map */ public data class Account( public val id: AccountId, - public val assets: Map, - public val signatories: List, - public val signatureCheckCondition: SignatureCheckCondition, public val metadata: Metadata, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Account = try { Account( AccountId.read(reader), - reader.readMap(reader.readCompactInt(), { AssetId.read(reader) }, { Asset.read(reader) }), - reader.readVec(reader.readCompactInt()) { PublicKey.read(reader) }, - SignatureCheckCondition.read(reader), Metadata.read(reader), ) } catch (ex: Exception) { @@ -40,20 +31,6 @@ public data class Account( override fun write(writer: ScaleCodecWriter, instance: Account): Unit = try { AccountId.write(writer, instance.id) - writer.writeCompact(instance.assets.size) - instance.assets.toSortedMap( - AssetId.comparator(), - ).forEach { (key, value) -> - AssetId.write(writer, key) - Asset.write(writer, value) - } - writer.writeCompact(instance.signatories.size) - instance.signatories.sortedWith( - PublicKey.comparator(), - ).forEach { value -> - PublicKey.write(writer, value) - } - SignatureCheckCondition.write(writer, instance.signatureCheckCondition) Metadata.write(writer, instance.metadata) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEvent.kt index c905981c7..cc6e3b0e0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEvent.kt @@ -23,38 +23,6 @@ public sealed class AccountEvent : ModelEnum { */ public abstract fun discriminant(): Int - /** - * 'Asset' variant - */ - public data class Asset( - public val assetEvent: AssetEvent, - ) : AccountEvent() { - 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.AccountEvent.Asset = try { - Asset( - AssetEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEvent.Asset, - ): Unit = try { - AssetEvent.write(writer, instance.assetEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Created' variant */ @@ -66,7 +34,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 1 + public const val DISCRIMINANT: Int = 0 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.Created = try { Created( @@ -98,7 +66,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 2 + public const val DISCRIMINANT: Int = 1 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.Deleted = try { Deleted( @@ -120,53 +88,21 @@ public sealed class AccountEvent : ModelEnum { } /** - * 'AuthenticationAdded' variant - */ - public data class AuthenticationAdded( - public val accountId: AccountId, - ) : AccountEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.AuthenticationAdded = try { - AuthenticationAdded( - AccountId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEvent.AuthenticationAdded, - ): Unit = try { - AccountId.write(writer, instance.accountId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'AuthenticationRemoved' variant + * 'Asset' variant */ - public data class AuthenticationRemoved( - public val accountId: AccountId, + public data class Asset( + public val assetEvent: AssetEvent, ) : AccountEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 4 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.AuthenticationRemoved = try { - AuthenticationRemoved( - AccountId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.Asset = try { + Asset( + AssetEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -174,9 +110,9 @@ public sealed class AccountEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEvent.AuthenticationRemoved, + instance: jp.co.soramitsu.iroha2.generated.AccountEvent.Asset, ): Unit = try { - AccountId.write(writer, instance.accountId) + AssetEvent.write(writer, instance.assetEvent) } catch (ex: Exception) { throw wrapException(ex) } @@ -194,7 +130,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 5 + public const val DISCRIMINANT: Int = 3 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.PermissionAdded = try { PermissionAdded( @@ -226,7 +162,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 6 + public const val DISCRIMINANT: Int = 4 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.PermissionRemoved = try { PermissionRemoved( @@ -248,20 +184,20 @@ public sealed class AccountEvent : ModelEnum { } /** - * 'RoleRevoked' variant + * 'RoleGranted' variant */ - public data class RoleRevoked( + public data class RoleGranted( public val accountRoleChanged: AccountRoleChanged, ) : AccountEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 5 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.RoleRevoked = try { - RoleRevoked( + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.RoleGranted = try { + RoleGranted( AccountRoleChanged.read(reader), ) } catch (ex: Exception) { @@ -270,7 +206,7 @@ public sealed class AccountEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEvent.RoleRevoked, + instance: jp.co.soramitsu.iroha2.generated.AccountEvent.RoleGranted, ): Unit = try { AccountRoleChanged.write(writer, instance.accountRoleChanged) } catch (ex: Exception) { @@ -280,20 +216,20 @@ public sealed class AccountEvent : ModelEnum { } /** - * 'RoleGranted' variant + * 'RoleRevoked' variant */ - public data class RoleGranted( + public data class RoleRevoked( public val accountRoleChanged: AccountRoleChanged, ) : AccountEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.RoleGranted = try { - RoleGranted( + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.RoleRevoked = try { + RoleRevoked( AccountRoleChanged.read(reader), ) } catch (ex: Exception) { @@ -302,7 +238,7 @@ public sealed class AccountEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEvent.RoleGranted, + instance: jp.co.soramitsu.iroha2.generated.AccountEvent.RoleRevoked, ): Unit = try { AccountRoleChanged.write(writer, instance.accountRoleChanged) } catch (ex: Exception) { @@ -322,7 +258,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 9 + public const val DISCRIMINANT: Int = 7 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.MetadataInserted = try { MetadataInserted( @@ -354,7 +290,7 @@ public sealed class AccountEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 10 + public const val DISCRIMINANT: Int = 8 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEvent.MetadataRemoved = try { MetadataRemoved( @@ -380,33 +316,29 @@ public sealed class AccountEvent : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Asset.read(reader) - 1 -> Created.read(reader) - 2 -> Deleted.read(reader) - 3 -> AuthenticationAdded.read(reader) - 4 -> AuthenticationRemoved.read(reader) - 5 -> PermissionAdded.read(reader) - 6 -> PermissionRemoved.read(reader) - 7 -> RoleRevoked.read(reader) - 8 -> RoleGranted.read(reader) - 9 -> MetadataInserted.read(reader) - 10 -> MetadataRemoved.read(reader) + 0 -> Created.read(reader) + 1 -> Deleted.read(reader) + 2 -> Asset.read(reader) + 3 -> PermissionAdded.read(reader) + 4 -> PermissionRemoved.read(reader) + 5 -> RoleGranted.read(reader) + 6 -> RoleRevoked.read(reader) + 7 -> MetadataInserted.read(reader) + 8 -> MetadataRemoved.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: AccountEvent) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Asset.write(writer, instance as Asset) - 1 -> Created.write(writer, instance as Created) - 2 -> Deleted.write(writer, instance as Deleted) - 3 -> AuthenticationAdded.write(writer, instance as AuthenticationAdded) - 4 -> AuthenticationRemoved.write(writer, instance as AuthenticationRemoved) - 5 -> PermissionAdded.write(writer, instance as PermissionAdded) - 6 -> PermissionRemoved.write(writer, instance as PermissionRemoved) - 7 -> RoleRevoked.write(writer, instance as RoleRevoked) - 8 -> RoleGranted.write(writer, instance as RoleGranted) - 9 -> MetadataInserted.write(writer, instance as MetadataInserted) - 10 -> MetadataRemoved.write(writer, instance as MetadataRemoved) + 0 -> Created.write(writer, instance as Created) + 1 -> Deleted.write(writer, instance as Deleted) + 2 -> Asset.write(writer, instance as Asset) + 3 -> PermissionAdded.write(writer, instance as PermissionAdded) + 4 -> PermissionRemoved.write(writer, instance as PermissionRemoved) + 5 -> RoleGranted.write(writer, instance as RoleGranted) + 6 -> RoleRevoked.write(writer, instance as RoleRevoked) + 7 -> MetadataInserted.write(writer, instance as MetadataInserted) + 8 -> MetadataRemoved.write(writer, instance as MetadataRemoved) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEventFilter.kt index a35263181..a5355bfe3 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountEventFilter.kt @@ -3,493 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * AccountEventFilter * - * Generated from 'AccountEventFilter' enum + * Generated from 'AccountEventFilter' regular structure */ -public sealed class AccountEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByAuthenticationAdded -> ByAuthenticationAdded.equals(this, other) - is ByAuthenticationRemoved -> ByAuthenticationRemoved.equals(this, other) - is ByPermissionAdded -> ByPermissionAdded.equals(this, other) - is ByPermissionRemoved -> ByPermissionRemoved.equals(this, other) - is ByRoleRevoked -> ByRoleRevoked.equals(this, other) - is ByRoleGranted -> ByRoleGranted.equals(this, other) - is ByMetadataInserted -> ByMetadataInserted.equals(this, other) - is ByMetadataRemoved -> ByMetadataRemoved.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByAuthenticationAdded -> ByAuthenticationAdded.hashCode() - is ByAuthenticationRemoved -> ByAuthenticationRemoved.hashCode() - is ByPermissionAdded -> ByPermissionAdded.hashCode() - is ByPermissionRemoved -> ByPermissionRemoved.hashCode() - is ByRoleRevoked -> ByRoleRevoked.hashCode() - is ByRoleGranted -> ByRoleGranted.hashCode() - is ByMetadataInserted -> ByMetadataInserted.hashCode() - is ByMetadataRemoved -> ByMetadataRemoved.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : AccountEventFilter() { - 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.AccountEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByCreated, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByCreated, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : AccountEventFilter() { - 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.AccountEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByDeleted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByDeleted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByAuthenticationAdded' variant - */ - public class ByAuthenticationAdded : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationAdded = try { - ByAuthenticationAdded() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationAdded, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationAdded, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByAuthenticationAdded".hashCode() - } - } - - /** - * 'ByAuthenticationRemoved' variant - */ - public class ByAuthenticationRemoved : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationRemoved = try { - ByAuthenticationRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationRemoved, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAuthenticationRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByAuthenticationRemoved".hashCode() - } - } - - /** - * 'ByPermissionAdded' variant - */ - public class ByPermissionAdded : AccountEventFilter() { - 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.AccountEventFilter.ByPermissionAdded = try { - ByPermissionAdded() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByPermissionAdded, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByPermissionAdded, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByPermissionAdded".hashCode() - } - } - - /** - * 'ByPermissionRemoved' variant - */ - public class ByPermissionRemoved : AccountEventFilter() { - 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.AccountEventFilter.ByPermissionRemoved = try { - ByPermissionRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByPermissionRemoved, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByPermissionRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByPermissionRemoved".hashCode() - } - } - - /** - * 'ByRoleRevoked' variant - */ - public class ByRoleRevoked : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleRevoked = try { - ByRoleRevoked() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleRevoked, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleRevoked, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByRoleRevoked".hashCode() - } - } - - /** - * 'ByRoleGranted' variant - */ - public class ByRoleGranted : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleGranted = try { - ByRoleGranted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleGranted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByRoleGranted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByRoleGranted".hashCode() - } - } - - /** - * 'ByMetadataInserted' variant - */ - public class ByMetadataInserted : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataInserted = try { - ByMetadataInserted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataInserted, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataInserted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByMetadataInserted".hashCode() - } - } - - /** - * 'ByMetadataRemoved' variant - */ - public class ByMetadataRemoved : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 9 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataRemoved = try { - ByMetadataRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataRemoved, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByMetadataRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AccountEventFilter.ByMetadataRemoved".hashCode() - } - } - - /** - * 'ByAsset' variant - */ - public data class ByAsset( - public val filterOptOfAssetFilter: FilterOptOfAssetFilter, - ) : AccountEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 10 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAsset = try { - ByAsset( - FilterOptOfAssetFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AccountEventFilter.ByAsset, - ): Unit = try { - FilterOptOfAssetFilter.write(writer, instance.filterOptOfAssetFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - +public data class AccountEventFilter( + public val idMatcher: AccountId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AccountEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByDeleted.read(reader) - 2 -> ByAuthenticationAdded.read(reader) - 3 -> ByAuthenticationRemoved.read(reader) - 4 -> ByPermissionAdded.read(reader) - 5 -> ByPermissionRemoved.read(reader) - 6 -> ByRoleRevoked.read(reader) - 7 -> ByRoleGranted.read(reader) - 8 -> ByMetadataInserted.read(reader) - 9 -> ByMetadataRemoved.read(reader) - 10 -> ByAsset.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: AccountEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByDeleted.write(writer, instance as ByDeleted) - 2 -> ByAuthenticationAdded.write(writer, instance as ByAuthenticationAdded) - 3 -> ByAuthenticationRemoved.write(writer, instance as ByAuthenticationRemoved) - 4 -> ByPermissionAdded.write(writer, instance as ByPermissionAdded) - 5 -> ByPermissionRemoved.write(writer, instance as ByPermissionRemoved) - 6 -> ByRoleRevoked.write(writer, instance as ByRoleRevoked) - 7 -> ByRoleGranted.write(writer, instance as ByRoleGranted) - 8 -> ByMetadataInserted.write(writer, instance as ByMetadataInserted) - 9 -> ByMetadataRemoved.write(writer, instance as ByMetadataRemoved) - 10 -> ByAsset.write(writer, instance as ByAsset) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): AccountEventFilter = try { + AccountEventFilter( + reader.readNullable(AccountId) as AccountId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: AccountEventFilter): Unit = try { + writer.writeNullable(AccountId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountFilter.kt deleted file mode 100644 index 7f7b19ab0..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountFilter.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 - -/** - * AccountFilter - * - * Generated from 'AccountFilter' regular structure - */ -public data class AccountFilter( - public val originFilter: FilterOptOfOriginFilterOfAccountEvent, - public val eventFilter: FilterOptOfAccountEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AccountFilter = try { - AccountFilter( - FilterOptOfOriginFilterOfAccountEvent.read(reader), - FilterOptOfAccountEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: AccountFilter): Unit = try { - FilterOptOfOriginFilterOfAccountEvent.write(writer, instance.originFilter) - FilterOptOfAccountEventFilter.write(writer, instance.eventFilter) - } 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 a827615f2..3dbdc2f0d 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 domainId: DomainId, - public val name: Name, + public val domain: DomainId, + public val signatory: PublicKey, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AccountId = try { AccountId( DomainId.read(reader), - Name.read(reader), + PublicKey.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AccountId): Unit = try { - DomainId.write(writer, instance.domainId) - Name.write(writer, instance.name) + DomainId.write(writer, instance.domain) + PublicKey.write(writer, instance.signatory) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountIdPredicateBox.kt new file mode 100644 index 000000000..8c67a2eb7 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountIdPredicateBox.kt @@ -0,0 +1,141 @@ +// +// 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 + +/** + * AccountIdPredicateBox + * + * Generated from 'AccountIdPredicateBox' enum + */ +public sealed class AccountIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val accountId: AccountId, + ) : AccountIdPredicateBox() { + 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.AccountIdPredicateBox.Equals = try { + Equals( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AccountIdPredicateBox.Equals, + ): Unit = try { + AccountId.write(writer, instance.accountId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'DomainId' variant + */ + public data class DomainId( + public val domainIdPredicateBox: DomainIdPredicateBox, + ) : AccountIdPredicateBox() { + 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.AccountIdPredicateBox.DomainId = try { + DomainId( + DomainIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AccountIdPredicateBox.DomainId, + ): Unit = try { + DomainIdPredicateBox.write(writer, instance.domainIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Signatory' variant + */ + public data class Signatory( + public val publicKeyPredicateBox: PublicKeyPredicateBox, + ) : AccountIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AccountIdPredicateBox.Signatory = try { + Signatory( + PublicKeyPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AccountIdPredicateBox.Signatory, + ): Unit = try { + PublicKeyPredicateBox.write(writer, instance.publicKeyPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AccountIdPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + 1 -> DomainId.read(reader) + 2 -> Signatory.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AccountIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + 1 -> DomainId.write(writer, instance as DomainId) + 2 -> Signatory.write(writer, instance as Signatory) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPermissionChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPermissionChanged.kt index abb2ce587..9957dc0d9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPermissionChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPermissionChanged.kt @@ -16,8 +16,8 @@ import kotlin.Unit * Generated from 'AccountPermissionChanged' regular structure */ public data class AccountPermissionChanged( - public val accountId: AccountId, - public val permissionId: Name, + public val account: AccountId, + public val permission: Permission, ) { public companion object : ScaleReader, @@ -25,15 +25,15 @@ public data class AccountPermissionChanged( override fun read(reader: ScaleCodecReader): AccountPermissionChanged = try { AccountPermissionChanged( AccountId.read(reader), - Name.read(reader), + Permission.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AccountPermissionChanged): Unit = try { - AccountId.write(writer, instance.accountId) - Name.write(writer, instance.permissionId) + AccountId.write(writer, instance.account) + Permission.write(writer, instance.permission) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPredicateBox.kt new file mode 100644 index 000000000..1636d2ec0 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountPredicateBox.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * AccountPredicateBox + * + * Generated from 'AccountPredicateBox' enum + */ +public sealed class AccountPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val accountIdPredicateBox: AccountIdPredicateBox, + ) : AccountPredicateBox() { + 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.AccountPredicateBox.Id = try { + Id( + AccountIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AccountPredicateBox.Id, + ): Unit = try { + AccountIdPredicateBox.write(writer, instance.accountIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Metadata' variant + */ + public data class Metadata( + public val metadataPredicateBox: MetadataPredicateBox, + ) : AccountPredicateBox() { + 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.AccountPredicateBox.Metadata = try { + Metadata( + MetadataPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AccountPredicateBox.Metadata, + ): Unit = try { + MetadataPredicateBox.write(writer, instance.metadataPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AccountPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + 1 -> Metadata.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AccountPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + 1 -> Metadata.write(writer, instance as Metadata) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountRoleChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountRoleChanged.kt index 56c0e604f..f3d9abe99 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountRoleChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AccountRoleChanged.kt @@ -16,8 +16,8 @@ import kotlin.Unit * Generated from 'AccountRoleChanged' regular structure */ public data class AccountRoleChanged( - public val accountId: AccountId, - public val roleId: RoleId, + public val account: AccountId, + public val role: RoleId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AccountRoleChanged = try { @@ -30,8 +30,8 @@ public data class AccountRoleChanged( } override fun write(writer: ScaleCodecWriter, instance: AccountRoleChanged): Unit = try { - AccountId.write(writer, instance.accountId) - RoleId.write(writer, instance.roleId) + AccountId.write(writer, instance.account) + RoleId.write(writer, instance.role) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Action.kt similarity index 65% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Action.kt index 17f5c0da4..e6422e1ee 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ActionOfTriggeringFilterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Action.kt @@ -11,37 +11,35 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ActionOfTriggeringFilterBox + * Action * - * Generated from 'ActionOfTriggeringFilterBox' regular structure + * Generated from 'Action' regular structure */ -public data class ActionOfTriggeringFilterBox( +public data class Action( public val executable: Executable, public val repeats: Repeats, public val authority: AccountId, - public val filter: TriggeringFilterBox, + public val filter: EventFilterBox, public val metadata: Metadata, ) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): ActionOfTriggeringFilterBox = try { - ActionOfTriggeringFilterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Action = try { + Action( Executable.read(reader), Repeats.read(reader), AccountId.read(reader), - TriggeringFilterBox.read(reader), + EventFilterBox.read(reader), Metadata.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ActionOfTriggeringFilterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: Action): Unit = try { Executable.write(writer, instance.executable) Repeats.write(writer, instance.repeats) AccountId.write(writer, instance.authority) - TriggeringFilterBox.write(writer, instance.filter) + EventFilterBox.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/Add.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Add.kt deleted file mode 100644 index a020f42b1..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Add.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 - -/** - * Add - * - * Generated from 'Add' regular structure - */ -public data class Add( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Add = try { - Add( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Add): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/And.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/And.kt deleted file mode 100644 index 01e38aee1..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/And.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.Boolean -import kotlin.Unit - -/** - * And - * - * Generated from 'And' regular structure - */ -public data class And( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): And = try { - And( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: And): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetChanged.kt index 4f7511825..0c74cd6e7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetChanged.kt @@ -16,7 +16,7 @@ import kotlin.Unit * Generated from 'AssetChanged' regular structure */ public data class AssetChanged( - public val assetId: AssetId, + public val asset: AssetId, public val amount: AssetValue, ) { public companion object : ScaleReader, ScaleWriter { @@ -30,7 +30,7 @@ public data class AssetChanged( } override fun write(writer: ScaleCodecWriter, instance: AssetChanged): Unit = try { - AssetId.write(writer, instance.assetId) + AssetId.write(writer, instance.asset) AssetValue.write(writer, instance.amount) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinition.kt index c575f9de7..87f4be6e8 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinition.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinition.kt @@ -17,7 +17,7 @@ import kotlin.Unit */ public data class AssetDefinition( public val id: AssetDefinitionId, - public val valueType: AssetValueType, + public val type: AssetType, public val mintable: Mintable, public val logo: IpfsPath? = null, public val metadata: Metadata, @@ -27,7 +27,7 @@ public data class AssetDefinition( override fun read(reader: ScaleCodecReader): AssetDefinition = try { AssetDefinition( AssetDefinitionId.read(reader), - AssetValueType.read(reader), + AssetType.read(reader), Mintable.read(reader), reader.readNullable(IpfsPath) as IpfsPath?, Metadata.read(reader), @@ -39,7 +39,7 @@ public data class AssetDefinition( override fun write(writer: ScaleCodecWriter, instance: AssetDefinition): Unit = try { AssetDefinitionId.write(writer, instance.id) - AssetValueType.write(writer, instance.valueType) + AssetType.write(writer, instance.type) Mintable.write(writer, instance.mintable) writer.writeNullable(IpfsPath, instance.logo) Metadata.write(writer, instance.metadata) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEvent.kt index b5c460c32..bb6ca7be5 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEvent.kt @@ -55,70 +55,6 @@ public sealed class AssetDefinitionEvent : ModelEnum { } } - /** - * 'MintabilityChanged' variant - */ - public data class MintabilityChanged( - public val assetDefinitionId: AssetDefinitionId, - ) : AssetDefinitionEvent() { - 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.AssetDefinitionEvent.MintabilityChanged = try { - MintabilityChanged( - AssetDefinitionId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.MintabilityChanged, - ): Unit = try { - AssetDefinitionId.write(writer, instance.assetDefinitionId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'OwnerChanged' variant - */ - public data class OwnerChanged( - public val assetDefinitionOwnerChanged: AssetDefinitionOwnerChanged, - ) : AssetDefinitionEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.OwnerChanged = try { - OwnerChanged( - AssetDefinitionOwnerChanged.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.OwnerChanged, - ): Unit = try { - AssetDefinitionOwnerChanged.write(writer, instance.assetDefinitionOwnerChanged) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Deleted' variant */ @@ -130,7 +66,7 @@ public sealed class AssetDefinitionEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 3 + public const val DISCRIMINANT: Int = 1 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.Deleted = try { Deleted( @@ -162,7 +98,7 @@ public sealed class AssetDefinitionEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 4 + public const val DISCRIMINANT: Int = 2 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.MetadataInserted = try { MetadataInserted( @@ -198,7 +134,7 @@ public sealed class AssetDefinitionEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 5 + public const val DISCRIMINANT: Int = 3 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.MetadataRemoved = try { MetadataRemoved( @@ -223,6 +159,38 @@ public sealed class AssetDefinitionEvent : ModelEnum { } } + /** + * 'MintabilityChanged' variant + */ + public data class MintabilityChanged( + public val assetDefinitionId: AssetDefinitionId, + ) : AssetDefinitionEvent() { + 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.AssetDefinitionEvent.MintabilityChanged = try { + MintabilityChanged( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.MintabilityChanged, + ): Unit = try { + AssetDefinitionId.write(writer, instance.assetDefinitionId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + /** * 'TotalQuantityChanged' variant */ @@ -234,7 +202,7 @@ public sealed class AssetDefinitionEvent : 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.AssetDefinitionEvent.TotalQuantityChanged = try { TotalQuantityChanged( @@ -258,30 +226,62 @@ public sealed class AssetDefinitionEvent : ModelEnum { } } + /** + * 'OwnerChanged' variant + */ + public data class OwnerChanged( + public val assetDefinitionOwnerChanged: AssetDefinitionOwnerChanged, + ) : AssetDefinitionEvent() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.OwnerChanged = try { + OwnerChanged( + AssetDefinitionOwnerChanged.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEvent.OwnerChanged, + ): Unit = try { + AssetDefinitionOwnerChanged.write(writer, instance.assetDefinitionOwnerChanged) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AssetDefinitionEvent = when ( val discriminant = reader.readUByte() ) { 0 -> Created.read(reader) - 1 -> MintabilityChanged.read(reader) - 2 -> OwnerChanged.read(reader) - 3 -> Deleted.read(reader) - 4 -> MetadataInserted.read(reader) - 5 -> MetadataRemoved.read(reader) - 6 -> TotalQuantityChanged.read(reader) + 1 -> Deleted.read(reader) + 2 -> MetadataInserted.read(reader) + 3 -> MetadataRemoved.read(reader) + 4 -> MintabilityChanged.read(reader) + 5 -> TotalQuantityChanged.read(reader) + 6 -> OwnerChanged.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionEvent) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Created.write(writer, instance as Created) - 1 -> MintabilityChanged.write(writer, instance as MintabilityChanged) - 2 -> OwnerChanged.write(writer, instance as OwnerChanged) - 3 -> Deleted.write(writer, instance as Deleted) - 4 -> MetadataInserted.write(writer, instance as MetadataInserted) - 5 -> MetadataRemoved.write(writer, instance as MetadataRemoved) - 6 -> TotalQuantityChanged.write(writer, instance as TotalQuantityChanged) + 1 -> Deleted.write(writer, instance as Deleted) + 2 -> MetadataInserted.write(writer, instance as MetadataInserted) + 3 -> MetadataRemoved.write(writer, instance as MetadataRemoved) + 4 -> MintabilityChanged.write(writer, instance as MintabilityChanged) + 5 -> TotalQuantityChanged.write(writer, instance as TotalQuantityChanged) + 6 -> OwnerChanged.write(writer, instance as OwnerChanged) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEventFilter.kt index ea6a3b700..c92a5b292 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionEventFilter.kt @@ -3,336 +3,40 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * AssetDefinitionEventFilter * - * Generated from 'AssetDefinitionEventFilter' enum + * Generated from 'AssetDefinitionEventFilter' regular structure */ -public sealed class AssetDefinitionEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByMintabilityChanged -> ByMintabilityChanged.equals(this, other) - is ByOwnerChanged -> ByOwnerChanged.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByMetadataInserted -> ByMetadataInserted.equals(this, other) - is ByMetadataRemoved -> ByMetadataRemoved.equals(this, other) - is ByTotalQuantityChanged -> ByTotalQuantityChanged.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByMintabilityChanged -> ByMintabilityChanged.hashCode() - is ByOwnerChanged -> ByOwnerChanged.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByMetadataInserted -> ByMetadataInserted.hashCode() - is ByMetadataRemoved -> ByMetadataRemoved.hashCode() - is ByTotalQuantityChanged -> ByTotalQuantityChanged.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : AssetDefinitionEventFilter() { - 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.AssetDefinitionEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByCreated, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByCreated, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByMintabilityChanged' variant - */ - public class ByMintabilityChanged : AssetDefinitionEventFilter() { - 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.AssetDefinitionEventFilter.ByMintabilityChanged = try { - ByMintabilityChanged() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMintabilityChanged, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMintabilityChanged, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByMintabilityChanged".hashCode() - } - } - - /** - * 'ByOwnerChanged' variant - */ - public class ByOwnerChanged : AssetDefinitionEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByOwnerChanged = try { - ByOwnerChanged() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByOwnerChanged, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByOwnerChanged, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByOwnerChanged".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : AssetDefinitionEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByDeleted, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByDeleted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByMetadataInserted' variant - */ - public class ByMetadataInserted : AssetDefinitionEventFilter() { - 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.AssetDefinitionEventFilter.ByMetadataInserted = try { - ByMetadataInserted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMetadataInserted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMetadataInserted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByMetadataInserted".hashCode() - } - } - - /** - * 'ByMetadataRemoved' variant - */ - public class ByMetadataRemoved : AssetDefinitionEventFilter() { - 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.AssetDefinitionEventFilter.ByMetadataRemoved = try { - ByMetadataRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMetadataRemoved, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByMetadataRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByMetadataRemoved".hashCode() - } - } - - /** - * 'ByTotalQuantityChanged' variant - */ - public class ByTotalQuantityChanged : AssetDefinitionEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByTotalQuantityChanged = try { - ByTotalQuantityChanged() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByTotalQuantityChanged, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetDefinitionEventFilter.ByTotalQuantityChanged, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetDefinitionEventFilter.ByTotalQuantityChanged".hashCode() - } - } - +public data class AssetDefinitionEventFilter( + public val idMatcher: AssetDefinitionId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AssetDefinitionEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByMintabilityChanged.read(reader) - 2 -> ByOwnerChanged.read(reader) - 3 -> ByDeleted.read(reader) - 4 -> ByMetadataInserted.read(reader) - 5 -> ByMetadataRemoved.read(reader) - 6 -> ByTotalQuantityChanged.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByMintabilityChanged.write(writer, instance as ByMintabilityChanged) - 2 -> ByOwnerChanged.write(writer, instance as ByOwnerChanged) - 3 -> ByDeleted.write(writer, instance as ByDeleted) - 4 -> ByMetadataInserted.write(writer, instance as ByMetadataInserted) - 5 -> ByMetadataRemoved.write(writer, instance as ByMetadataRemoved) - 6 -> ByTotalQuantityChanged.write(writer, instance as ByTotalQuantityChanged) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): AssetDefinitionEventFilter = try { + AssetDefinitionEventFilter( + reader.readNullable(AssetDefinitionId) as AssetDefinitionId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionEventFilter): Unit = try { + writer.writeNullable(AssetDefinitionId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionFilter.kt deleted file mode 100644 index df18c0949..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionFilter.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 - -/** - * AssetDefinitionFilter - * - * Generated from 'AssetDefinitionFilter' regular structure - */ -public data class AssetDefinitionFilter( - public val originFilter: FilterOptOfOriginFilterOfAssetDefinitionEvent, - public val eventFilter: FilterOptOfAssetDefinitionEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AssetDefinitionFilter = try { - AssetDefinitionFilter( - FilterOptOfOriginFilterOfAssetDefinitionEvent.read(reader), - FilterOptOfAssetDefinitionEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionFilter): Unit = try { - FilterOptOfOriginFilterOfAssetDefinitionEvent.write(writer, instance.originFilter) - FilterOptOfAssetDefinitionEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionId.kt index 4447f0703..137949bc7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionId.kt @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'AssetDefinitionId' regular structure */ public data class AssetDefinitionId( + public val domain: DomainId, public val name: Name, - public val domainId: DomainId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AssetDefinitionId = try { AssetDefinitionId( - Name.read(reader), DomainId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionId): Unit = try { + DomainId.write(writer, instance.domain) Name.write(writer, instance.name) - DomainId.write(writer, instance.domainId) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionIdPredicateBox.kt new file mode 100644 index 000000000..b0bccd122 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionIdPredicateBox.kt @@ -0,0 +1,145 @@ +// +// 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 + +/** + * AssetDefinitionIdPredicateBox + * + * Generated from 'AssetDefinitionIdPredicateBox' enum + */ +public sealed class AssetDefinitionIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val assetDefinitionId: AssetDefinitionId, + ) : AssetDefinitionIdPredicateBox() { + 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.AssetDefinitionIdPredicateBox.Equals = try { + Equals( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionIdPredicateBox.Equals, + ): Unit = + try { + AssetDefinitionId.write(writer, instance.assetDefinitionId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'DomainId' variant + */ + public data class DomainId( + public val domainIdPredicateBox: DomainIdPredicateBox, + ) : AssetDefinitionIdPredicateBox() { + 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.AssetDefinitionIdPredicateBox.DomainId = try { + DomainId( + DomainIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionIdPredicateBox.DomainId, + ): Unit = + try { + DomainIdPredicateBox.write(writer, instance.domainIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Name' variant + */ + public data class Name( + public val stringPredicateBox: StringPredicateBox, + ) : AssetDefinitionIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionIdPredicateBox.Name = try { + Name( + StringPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionIdPredicateBox.Name, + ): Unit = try { + StringPredicateBox.write(writer, instance.stringPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetDefinitionIdPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Equals.read(reader) + 1 -> DomainId.read(reader) + 2 -> Name.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + 1 -> DomainId.write(writer, instance as DomainId) + 2 -> Name.write(writer, instance as Name) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionOwnerChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionOwnerChanged.kt index 82d44eb14..31a7926c6 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionOwnerChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionOwnerChanged.kt @@ -16,7 +16,7 @@ import kotlin.Unit * Generated from 'AssetDefinitionOwnerChanged' regular structure */ public data class AssetDefinitionOwnerChanged( - public val assetDefinitionId: AssetDefinitionId, + public val assetDefinition: AssetDefinitionId, public val newOwner: AccountId, ) { public companion object : @@ -32,7 +32,7 @@ public data class AssetDefinitionOwnerChanged( } override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionOwnerChanged): Unit = try { - AssetDefinitionId.write(writer, instance.assetDefinitionId) + AssetDefinitionId.write(writer, instance.assetDefinition) AccountId.write(writer, instance.newOwner) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionPredicateBox.kt new file mode 100644 index 000000000..b020e0d45 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionPredicateBox.kt @@ -0,0 +1,145 @@ +// +// 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 + +/** + * AssetDefinitionPredicateBox + * + * Generated from 'AssetDefinitionPredicateBox' enum + */ +public sealed class AssetDefinitionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val assetDefinitionIdPredicateBox: AssetDefinitionIdPredicateBox, + ) : AssetDefinitionPredicateBox() { + 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.AssetDefinitionPredicateBox.Id = try { + Id( + AssetDefinitionIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionPredicateBox.Id, + ): Unit = try { + AssetDefinitionIdPredicateBox.write(writer, instance.assetDefinitionIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Metadata' variant + */ + public data class Metadata( + public val metadataPredicateBox: MetadataPredicateBox, + ) : AssetDefinitionPredicateBox() { + 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.AssetDefinitionPredicateBox.Metadata = try { + Metadata( + MetadataPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionPredicateBox.Metadata, + ): Unit = + try { + MetadataPredicateBox.write(writer, instance.metadataPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'OwnedBy' variant + */ + public data class OwnedBy( + public val accountIdPredicateBox: AccountIdPredicateBox, + ) : AssetDefinitionPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetDefinitionPredicateBox.OwnedBy = try { + OwnedBy( + AccountIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetDefinitionPredicateBox.OwnedBy, + ): Unit = + try { + AccountIdPredicateBox.write(writer, instance.accountIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetDefinitionPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + 1 -> Metadata.read(reader) + 2 -> OwnedBy.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + 1 -> Metadata.write(writer, instance as Metadata) + 2 -> OwnedBy.write(writer, instance as OwnedBy) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionTotalQuantityChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionTotalQuantityChanged.kt index 2a764ca37..cff71594e 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionTotalQuantityChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetDefinitionTotalQuantityChanged.kt @@ -16,8 +16,8 @@ import kotlin.Unit * Generated from 'AssetDefinitionTotalQuantityChanged' regular structure */ public data class AssetDefinitionTotalQuantityChanged( - public val assetDefinitionId: AssetDefinitionId, - public val totalAmount: NumericValue, + public val assetDefinition: AssetDefinitionId, + public val totalAmount: Numeric, ) { public companion object : ScaleReader, @@ -25,15 +25,15 @@ public data class AssetDefinitionTotalQuantityChanged( override fun read(reader: ScaleCodecReader): AssetDefinitionTotalQuantityChanged = try { AssetDefinitionTotalQuantityChanged( AssetDefinitionId.read(reader), - NumericValue.read(reader), + Numeric.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AssetDefinitionTotalQuantityChanged): Unit = try { - AssetDefinitionId.write(writer, instance.assetDefinitionId) - NumericValue.write(writer, instance.totalAmount) + AssetDefinitionId.write(writer, instance.assetDefinition) + Numeric.write(writer, instance.totalAmount) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetEventFilter.kt index b0dd17b1d..19d220c19 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetEventFilter.kt @@ -3,280 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * AssetEventFilter * - * Generated from 'AssetEventFilter' enum + * Generated from 'AssetEventFilter' regular structure */ -public sealed class AssetEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByAdded -> ByAdded.equals(this, other) - is ByRemoved -> ByRemoved.equals(this, other) - is ByMetadataInserted -> ByMetadataInserted.equals(this, other) - is ByMetadataRemoved -> ByMetadataRemoved.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByAdded -> ByAdded.hashCode() - is ByRemoved -> ByRemoved.hashCode() - is ByMetadataInserted -> ByMetadataInserted.hashCode() - is ByMetadataRemoved -> ByMetadataRemoved.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : AssetEventFilter() { - 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.AssetEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByCreated, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByCreated, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : AssetEventFilter() { - 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.AssetEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByDeleted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByDeleted, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByAdded' variant - */ - public class ByAdded : AssetEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByAdded = try { - ByAdded() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByAdded, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByAdded, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByAdded".hashCode() - } - } - - /** - * 'ByRemoved' variant - */ - public class ByRemoved : AssetEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByRemoved = try { - ByRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByRemoved, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByRemoved, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByRemoved".hashCode() - } - } - - /** - * 'ByMetadataInserted' variant - */ - public class ByMetadataInserted : AssetEventFilter() { - 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.AssetEventFilter.ByMetadataInserted = try { - ByMetadataInserted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByMetadataInserted, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByMetadataInserted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByMetadataInserted".hashCode() - } - } - - /** - * 'ByMetadataRemoved' variant - */ - public class ByMetadataRemoved : AssetEventFilter() { - 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.AssetEventFilter.ByMetadataRemoved = try { - ByMetadataRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByMetadataRemoved, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.AssetEventFilter.ByMetadataRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetEventFilter.ByMetadataRemoved".hashCode() - } - } - +public data class AssetEventFilter( + public val idMatcher: AssetId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AssetEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByDeleted.read(reader) - 2 -> ByAdded.read(reader) - 3 -> ByRemoved.read(reader) - 4 -> ByMetadataInserted.read(reader) - 5 -> ByMetadataRemoved.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): AssetEventFilter = try { + AssetEventFilter( + reader.readNullable(AssetId) as AssetId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } - override fun write(writer: ScaleCodecWriter, instance: AssetEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByDeleted.write(writer, instance as ByDeleted) - 2 -> ByAdded.write(writer, instance as ByAdded) - 3 -> ByRemoved.write(writer, instance as ByRemoved) - 4 -> ByMetadataInserted.write(writer, instance as ByMetadataInserted) - 5 -> ByMetadataRemoved.write(writer, instance as ByMetadataRemoved) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun write(writer: ScaleCodecWriter, instance: AssetEventFilter): Unit = try { + writer.writeNullable(AssetId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetFilter.kt deleted file mode 100644 index 06a0672c9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetFilter.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 - -/** - * AssetFilter - * - * Generated from 'AssetFilter' regular structure - */ -public data class AssetFilter( - public val originFilter: FilterOptOfOriginFilterOfAssetEvent, - public val eventFilter: FilterOptOfAssetEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AssetFilter = try { - AssetFilter( - FilterOptOfOriginFilterOfAssetEvent.read(reader), - FilterOptOfAssetEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: AssetFilter): Unit = try { - FilterOptOfOriginFilterOfAssetEvent.write(writer, instance.originFilter) - FilterOptOfAssetEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetId.kt index 001c12ce0..1c7b14900 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetId.kt @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'AssetId' regular structure */ public data class AssetId( - public val definitionId: AssetDefinitionId, - public val accountId: AccountId, + public val account: AccountId, + public val definition: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AssetId = try { AssetId( - AssetDefinitionId.read(reader), AccountId.read(reader), + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: AssetId): Unit = try { - AssetDefinitionId.write(writer, instance.definitionId) - AccountId.write(writer, instance.accountId) + AccountId.write(writer, instance.account) + AssetDefinitionId.write(writer, instance.definition) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetIdPredicateBox.kt new file mode 100644 index 000000000..0150bef74 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetIdPredicateBox.kt @@ -0,0 +1,141 @@ +// +// 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 + +/** + * AssetIdPredicateBox + * + * Generated from 'AssetIdPredicateBox' enum + */ +public sealed class AssetIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val assetId: AssetId, + ) : AssetIdPredicateBox() { + 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.AssetIdPredicateBox.Equals = try { + Equals( + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetIdPredicateBox.Equals, + ): Unit = try { + AssetId.write(writer, instance.assetId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'DefinitionId' variant + */ + public data class DefinitionId( + public val assetDefinitionIdPredicateBox: AssetDefinitionIdPredicateBox, + ) : AssetIdPredicateBox() { + 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.AssetIdPredicateBox.DefinitionId = try { + DefinitionId( + AssetDefinitionIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetIdPredicateBox.DefinitionId, + ): Unit = try { + AssetDefinitionIdPredicateBox.write(writer, instance.assetDefinitionIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AccountId' variant + */ + public data class AccountId( + public val accountIdPredicateBox: AccountIdPredicateBox, + ) : AssetIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetIdPredicateBox.AccountId = try { + AccountId( + AccountIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetIdPredicateBox.AccountId, + ): Unit = try { + AccountIdPredicateBox.write(writer, instance.accountIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetIdPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + 1 -> DefinitionId.read(reader) + 2 -> AccountId.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + 1 -> DefinitionId.write(writer, instance as DefinitionId) + 2 -> AccountId.write(writer, instance as AccountId) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetPredicateBox.kt new file mode 100644 index 000000000..470905e05 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetPredicateBox.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * AssetPredicateBox + * + * Generated from 'AssetPredicateBox' enum + */ +public sealed class AssetPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val assetIdPredicateBox: AssetIdPredicateBox, + ) : AssetPredicateBox() { + 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.AssetPredicateBox.Id = try { + Id( + AssetIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetPredicateBox.Id, + ): Unit = try { + AssetIdPredicateBox.write(writer, instance.assetIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Value' variant + */ + public data class Value( + public val assetValuePredicateBox: AssetValuePredicateBox, + ) : AssetPredicateBox() { + 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.AssetPredicateBox.Value = try { + Value( + AssetValuePredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetPredicateBox.Value, + ): Unit = try { + AssetValuePredicateBox.write(writer, instance.assetValuePredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + 1 -> Value.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + 1 -> Value.write(writer, instance as Value) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetTransferBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetTransferBox.kt new file mode 100644 index 000000000..b3c7c1fba --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetTransferBox.kt @@ -0,0 +1,113 @@ +// +// 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 + +/** + * AssetTransferBox + * + * Generated from 'AssetTransferBox' enum + */ +public sealed class AssetTransferBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Numeric' variant + */ + public data class Numeric( + public val transferOfAssetAndNumericAndAccount: TransferOfAssetAndNumericAndAccount, + ) : AssetTransferBox() { + 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.AssetTransferBox.Numeric = try { + Numeric( + TransferOfAssetAndNumericAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetTransferBox.Numeric, + ): Unit = try { + TransferOfAssetAndNumericAndAccount.write( + writer, + instance.transferOfAssetAndNumericAndAccount, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Store' variant + */ + public data class Store( + public val transferOfAssetAndMetadataAndAccount: TransferOfAssetAndMetadataAndAccount, + ) : AssetTransferBox() { + 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.AssetTransferBox.Store = try { + Store( + TransferOfAssetAndMetadataAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.AssetTransferBox.Store, + ): Unit = try { + TransferOfAssetAndMetadataAndAccount.write( + writer, + instance.transferOfAssetAndMetadataAndAccount, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetTransferBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Numeric.read(reader) + 1 -> Store.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetTransferBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Numeric.write(writer, instance as Numeric) + 1 -> Store.write(writer, instance as Store) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetType.kt similarity index 51% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleFilter.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetType.kt index 610a28474..e44697b25 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetType.kt @@ -15,107 +15,105 @@ import kotlin.Int import kotlin.Unit /** - * FilterOptOfRoleFilter + * AssetType * - * Generated from 'FilterOptOfRoleFilter' enum + * Generated from 'AssetType' enum */ -public sealed class FilterOptOfRoleFilter : ModelEnum { +public sealed class AssetType : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) + is Store -> Store.equals(this, other) else -> super.equals(other) } override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() + is Store -> Store.hashCode() else -> super.hashCode() } /** - * 'AcceptAll' variant + * 'Numeric' variant */ - public class AcceptAll : FilterOptOfRoleFilter() { + public data class Numeric( + public val numericSpec: NumericSpec, + ) : AssetType() { 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.FilterOptOfRoleFilter.AcceptAll = try { - AcceptAll() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetType.Numeric = try { + Numeric( + NumericSpec.read(reader), + ) } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleFilter.AcceptAll, + instance: jp.co.soramitsu.iroha2.generated.AssetType.Numeric, ): Unit = try { + NumericSpec.write(writer, instance.numericSpec) } catch (ex: Exception) { throw wrapException(ex) } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfRoleFilter.AcceptAll".hashCode() } } /** - * 'BySome' variant + * 'Store' variant */ - public data class BySome( - public val roleFilter: RoleFilter, - ) : FilterOptOfRoleFilter() { + public class Store : AssetType() { 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.FilterOptOfRoleFilter.BySome = try { - BySome( - RoleFilter.read(reader), - ) + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetType.Store = try { + Store() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleFilter.BySome, + instance: jp.co.soramitsu.iroha2.generated.AssetType.Store, ): Unit = try { - RoleFilter.write(writer, instance.roleFilter) } catch (ex: Exception) { throw wrapException(ex) } + + public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetType.Store, o2: Any?): Boolean = + when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".AssetType.Store".hashCode() } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfRoleFilter = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetType = when ( val discriminant = reader.readUByte() ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) + 0 -> Numeric.read(reader) + 1 -> Store.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfRoleFilter) { + override fun write(writer: ScaleCodecWriter, instance: AssetType) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) + 0 -> Numeric.write(writer, instance as Numeric) + 1 -> Store.write(writer, instance as Store) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValue.kt index 12eee0b71..c0a991359 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValue.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValue.kt @@ -9,9 +9,7 @@ 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 java.math.BigInteger import kotlin.Int -import kotlin.Long import kotlin.Unit /** @@ -26,21 +24,21 @@ public sealed class AssetValue : ModelEnum { public abstract fun discriminant(): Int /** - * 'Quantity' variant + * 'Numeric' variant */ - public data class Quantity( - public val u32: Long, + public data class Numeric( + public val numeric: jp.co.soramitsu.iroha2.generated.Numeric, ) : AssetValue() { 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.AssetValue.Quantity = try { - Quantity( - reader.readUint32(), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetValue.Numeric = try { + Numeric( + jp.co.soramitsu.iroha2.generated.Numeric.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -48,73 +46,9 @@ public sealed class AssetValue : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValue.Quantity, + instance: jp.co.soramitsu.iroha2.generated.AssetValue.Numeric, ): Unit = try { - writer.writeUint32(instance.u32) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'BigQuantity' variant - */ - public data class BigQuantity( - public val u128: BigInteger, - ) : AssetValue() { - 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.AssetValue.BigQuantity = try { - BigQuantity( - reader.readUint128(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValue.BigQuantity, - ): Unit = try { - writer.writeUint128(instance.u128) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Fixed' variant - */ - public data class Fixed( - public val fixed: jp.co.soramitsu.iroha2.generated.Fixed, - ) : AssetValue() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetValue.Fixed = try { - Fixed( - jp.co.soramitsu.iroha2.generated.Fixed.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValue.Fixed, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Fixed.write(writer, instance.fixed) + jp.co.soramitsu.iroha2.generated.Numeric.write(writer, instance.numeric) } catch (ex: Exception) { throw wrapException(ex) } @@ -132,7 +66,7 @@ public sealed class AssetValue : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 3 + public const val DISCRIMINANT: Int = 1 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.AssetValue.Store = try { Store( @@ -158,19 +92,15 @@ public sealed class AssetValue : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Quantity.read(reader) - 1 -> BigQuantity.read(reader) - 2 -> Fixed.read(reader) - 3 -> Store.read(reader) + 0 -> Numeric.read(reader) + 1 -> Store.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: AssetValue) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Quantity.write(writer, instance as Quantity) - 1 -> BigQuantity.write(writer, instance as BigQuantity) - 2 -> Fixed.write(writer, instance as Fixed) - 3 -> Store.write(writer, instance as Store) + 0 -> Numeric.write(writer, instance as Numeric) + 1 -> Store.write(writer, instance as Store) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValuePredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValuePredicateBox.kt new file mode 100644 index 000000000..b6746406a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValuePredicateBox.kt @@ -0,0 +1,37 @@ +// +// 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 kotlin.Int + +/** + * AssetValuePredicateBox + * + * Generated from 'AssetValuePredicateBox' enum + */ +public sealed class AssetValuePredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): AssetValuePredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: AssetValuePredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AtIndex.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AtIndex.kt index c0d0a0704..3a375d74b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AtIndex.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AtIndex.kt @@ -18,13 +18,13 @@ import kotlin.Unit */ public data class AtIndex( public val index: Long, - public val predicate: ValuePredicate, + public val predicate: QueryOutputPredicate, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): AtIndex = try { AtIndex( reader.readUint32(), - ValuePredicate.read(reader), + QueryOutputPredicate.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -32,7 +32,7 @@ public data class AtIndex( override fun write(writer: ScaleCodecWriter, instance: AtIndex): Unit = try { writer.writeUint32(instance.index) - ValuePredicate.write(writer, instance.predicate) + QueryOutputPredicate.write(writer, instance.predicate) } 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 c70c71c67..31d4a8873 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 @@ -12,12 +12,11 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Any import kotlin.Int import kotlin.Unit -import kotlin.collections.List /** * BatchedResponse * - * Generated from 'BatchedResponse>' enum + * Generated from 'BatchedResponse' enum */ public sealed class BatchedResponse : ModelEnum { /** @@ -29,8 +28,8 @@ public sealed class BatchedResponse : ModelEnum { * 'V1' variant */ public data class V1( - public val batchedResponseV1: BatchedResponseV1>, - ) : BatchedResponse>() { + public val batchedResponseV1: BatchedResponseV1, + ) : BatchedResponse() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -40,7 +39,7 @@ public sealed class BatchedResponse : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BatchedResponse.V1 = try { V1( - BatchedResponseV1.read(reader) as BatchedResponseV1>, + BatchedResponseV1.read(reader) as BatchedResponseV1, ) } catch (ex: Exception) { throw wrapException(ex) 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 index dd3b6c1d8..d613c9b68 100644 --- 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 @@ -10,15 +10,14 @@ 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 + * Generated from 'BatchedResponseV1' regular structure */ public data class BatchedResponseV1( - public val batch: List, + public val batch: QueryOutputBox, public val cursor: ForwardCursor, ) { public companion object : @@ -26,7 +25,7 @@ public data class BatchedResponseV1( ScaleWriter> { override fun read(reader: ScaleCodecReader): BatchedResponseV1 = try { BatchedResponseV1( - reader.readVec(reader.readCompactInt()) { SignedTransaction.read(reader) }, + QueryOutputBox.read(reader), ForwardCursor.read(reader), ) } catch (ex: Exception) { @@ -34,10 +33,7 @@ public data class BatchedResponseV1( } override fun write(writer: ScaleCodecWriter, instance: BatchedResponseV1): Unit = try { - writer.writeCompact(instance.batch.size) - instance.batch.forEach { value -> - SignedTransaction.write(writer, value) - } + QueryOutputBox.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/BatchedResponseV1OfValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1OfValue.kt deleted file mode 100644 index c751b2940..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseV1OfValue.kt +++ /dev/null @@ -1,41 +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 - -/** - * 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/BinaryOpIncompatibleNumericValueTypesError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BinaryOpIncompatibleNumericValueTypesError.kt deleted file mode 100644 index ce6194398..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BinaryOpIncompatibleNumericValueTypesError.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 - -/** - * BinaryOpIncompatibleNumericValueTypesError - * - * Generated from 'BinaryOpIncompatibleNumericValueTypesError' regular structure - */ -public data class BinaryOpIncompatibleNumericValueTypesError( - public val left: NumericValue, - public val right: NumericValue, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): BinaryOpIncompatibleNumericValueTypesError = try { - BinaryOpIncompatibleNumericValueTypesError( - NumericValue.read(reader), - NumericValue.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: BinaryOpIncompatibleNumericValueTypesError, - ): Unit = try { - NumericValue.write(writer, instance.left) - NumericValue.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEvent.kt new file mode 100644 index 000000000..a8bf43229 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEvent.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 + +/** + * BlockEvent + * + * Generated from 'BlockEvent' regular structure + */ +public data class BlockEvent( + public val `header`: BlockHeader, + public val status: BlockStatus, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockEvent = try { + BlockEvent( + BlockHeader.read(reader), + BlockStatus.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BlockEvent): Unit = try { + BlockHeader.write(writer, instance.`header`) + BlockStatus.write(writer, instance.status) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEventFilter.kt new file mode 100644 index 000000000..c67b86812 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockEventFilter.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 + +/** + * BlockEventFilter + * + * Generated from 'BlockEventFilter' regular structure + */ +public data class BlockEventFilter( + public val height: NonZeroOfu64? = null, + public val status: BlockStatus? = null, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockEventFilter = try { + BlockEventFilter( + reader.readNullable(NonZeroOfu64) as NonZeroOfu64?, + reader.readNullable(BlockStatus) as BlockStatus?, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BlockEventFilter): Unit = try { + writer.writeNullable(NonZeroOfu64, instance.height) + writer.writeNullable(BlockStatus, instance.status) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} 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/BlockHashPredicateBox.kt similarity index 57% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BatchedResponseOfValue.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHashPredicateBox.kt index 541b5300c..a40986bcb 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/BlockHashPredicateBox.kt @@ -13,32 +13,32 @@ import kotlin.Int import kotlin.Unit /** - * BatchedResponseOfValue + * BlockHashPredicateBox * - * Generated from 'BatchedResponseOfValue' enum + * Generated from 'BlockHashPredicateBox' enum */ -public sealed class BatchedResponseOfValue : ModelEnum { +public sealed class BlockHashPredicateBox : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'V1' variant + * 'Equals' variant */ - public data class V1( - public val batchedResponseV1OfValue: BatchedResponseV1OfValue, - ) : BatchedResponseOfValue() { + public data class Equals( + public val hashOf: HashOf, + ) : BlockHashPredicateBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 1 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 0 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue.V1 = try { - V1( - BatchedResponseV1OfValue.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockHashPredicateBox.Equals = try { + Equals( + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,27 +46,27 @@ public sealed class BatchedResponseOfValue : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.BatchedResponseOfValue.V1, + instance: jp.co.soramitsu.iroha2.generated.BlockHashPredicateBox.Equals, ): Unit = try { - BatchedResponseV1OfValue.write(writer, instance.batchedResponseV1OfValue) + HashOf.write(writer, instance.hashOf) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): BatchedResponseOfValue = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockHashPredicateBox = when ( val discriminant = reader.readUByte() ) { - 1 -> V1.read(reader) + 0 -> Equals.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: BatchedResponseOfValue) { + override fun write(writer: ScaleCodecWriter, instance: BlockHashPredicateBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 1 -> V1.write(writer, instance as V1) + 0 -> Equals.write(writer, instance as Equals) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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 bb92154a5..7393cf9c7 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 @@ -9,6 +9,7 @@ import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException import java.math.BigInteger +import kotlin.Long import kotlin.Unit import kotlin.collections.List @@ -18,21 +19,21 @@ import kotlin.collections.List * Generated from 'BlockHeader' regular structure */ public data class BlockHeader( - public val height: BigInteger, - public val timestampMs: BigInteger, - public val previousBlockHash: HashOf? = null, - public val transactionsHash: HashOf>? = null, - public val viewChangeIndex: BigInteger, + public val height: NonZeroOfu64, + public val prevBlockHash: HashOf? = null, + public val transactionsHash: HashOf>, + public val creationTimeMs: BigInteger, + public val viewChangeIndex: Long, public val consensusEstimationMs: BigInteger, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): BlockHeader = try { BlockHeader( + NonZeroOfu64.read(reader), + reader.readNullable(HashOf) as HashOf?, + HashOf.read(reader) as HashOf>, reader.readUint64(), - reader.readUint64(), - reader.readNullable(HashOf) as HashOf?, - reader.readNullable(HashOf) as HashOf>?, - reader.readUint64(), + reader.readUint32(), reader.readUint64(), ) } catch (ex: Exception) { @@ -40,11 +41,11 @@ public data class BlockHeader( } override fun write(writer: ScaleCodecWriter, instance: BlockHeader): Unit = try { - writer.writeUint64(instance.height) - writer.writeUint64(instance.timestampMs) - writer.writeNullable(HashOf, instance.previousBlockHash) - writer.writeNullable(HashOf, instance.transactionsHash) - writer.writeUint64(instance.viewChangeIndex) + NonZeroOfu64.write(writer, instance.height) + writer.writeNullable(HashOf, instance.prevBlockHash) + HashOf.write(writer, instance.transactionsHash) + writer.writeUint64(instance.creationTimeMs) + writer.writeUint32(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/NotificationEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeaderPredicateBox.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NotificationEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeaderPredicateBox.kt index 89f9b86cf..62559f878 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NotificationEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockHeaderPredicateBox.kt @@ -13,32 +13,32 @@ import kotlin.Int import kotlin.Unit /** - * NotificationEvent + * BlockHeaderPredicateBox * - * Generated from 'NotificationEvent' enum + * Generated from 'BlockHeaderPredicateBox' enum */ -public sealed class NotificationEvent : ModelEnum { +public sealed class BlockHeaderPredicateBox : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'TriggerCompleted' variant + * 'Hash' variant */ - public data class TriggerCompleted( - public val triggerCompletedEvent: TriggerCompletedEvent, - ) : NotificationEvent() { + public data class Hash( + public val blockHashPredicateBox: BlockHashPredicateBox, + ) : BlockHeaderPredicateBox() { 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.NotificationEvent.TriggerCompleted = try { - TriggerCompleted( - TriggerCompletedEvent.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockHeaderPredicateBox.Hash = try { + Hash( + BlockHashPredicateBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,27 +46,29 @@ public sealed class NotificationEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NotificationEvent.TriggerCompleted, + instance: jp.co.soramitsu.iroha2.generated.BlockHeaderPredicateBox.Hash, ): Unit = try { - TriggerCompletedEvent.write(writer, instance.triggerCompletedEvent) + BlockHashPredicateBox.write(writer, instance.blockHashPredicateBox) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): NotificationEvent = when ( + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockHeaderPredicateBox = when ( val discriminant = reader.readUByte() ) { - 0 -> TriggerCompleted.read(reader) + 0 -> Hash.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: NotificationEvent) { + override fun write(writer: ScaleCodecWriter, instance: BlockHeaderPredicateBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> TriggerCompleted.write(writer, instance as TriggerCompleted) + 0 -> Hash.write(writer, instance as Hash) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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/BlockParameter.kt similarity index 57% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradableBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockParameter.kt index 6c1c27085..718476f2b 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/BlockParameter.kt @@ -13,32 +13,32 @@ import kotlin.Int import kotlin.Unit /** - * UpgradableBox + * BlockParameter * - * Generated from 'UpgradableBox' enum + * Generated from 'BlockParameter' enum */ -public sealed class UpgradableBox : ModelEnum { +public sealed class BlockParameter : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'Executor' variant + * 'MaxTransactions' variant */ - public data class Executor( - public val executor: jp.co.soramitsu.iroha2.generated.Executor, - ) : UpgradableBox() { + public data class MaxTransactions( + public val nonZeroOfu64: NonZeroOfu64, + ) : BlockParameter() { 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.Executor = try { - Executor( - jp.co.soramitsu.iroha2.generated.Executor.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockParameter.MaxTransactions = try { + MaxTransactions( + NonZeroOfu64.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,27 +46,27 @@ public sealed class UpgradableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.UpgradableBox.Executor, + instance: jp.co.soramitsu.iroha2.generated.BlockParameter.MaxTransactions, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Executor.write(writer, instance.executor) + NonZeroOfu64.write(writer, instance.nonZeroOfu64) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): UpgradableBox = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockParameter = when ( val discriminant = reader.readUByte() ) { - 0 -> Executor.read(reader) + 0 -> MaxTransactions.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: UpgradableBox) { + override fun write(writer: ScaleCodecWriter, instance: BlockParameter) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Executor.write(writer, instance as Executor) + 0 -> MaxTransactions.write(writer, instance as MaxTransactions) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockParameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockParameters.kt new file mode 100644 index 000000000..a6f725dc9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockParameters.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * BlockParameters + * + * Generated from 'BlockParameters' regular structure + */ +public data class BlockParameters( + public val maxTransactions: NonZeroOfu64, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockParameters = try { + BlockParameters( + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BlockParameters): Unit = try { + NonZeroOfu64.write(writer, instance.maxTransactions) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt index fcccd60ee..4c64170cb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockPayload.kt @@ -18,17 +18,15 @@ import kotlin.collections.List */ public data class BlockPayload( public val `header`: BlockHeader, - public val commitTopology: UniqueVec, - public val transactions: List, - public val eventRecommendations: List, + public val transactions: List, + public val eventRecommendations: List, ) { 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) }, + reader.readVec(reader.readCompactInt()) { CommittedTransaction.read(reader) }, + reader.readVec(reader.readCompactInt()) { EventBox.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) @@ -36,14 +34,13 @@ public data class BlockPayload( 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) + CommittedTransaction.write(writer, value) } writer.writeCompact(instance.eventRecommendations.size) instance.eventRecommendations.forEach { value -> - Event.write(writer, value) + EventBox.write(writer, value) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Duration.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockSignature.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Duration.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockSignature.kt index 931dc5863..85ee7d1d2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Duration.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockSignature.kt @@ -9,31 +9,30 @@ import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException import java.math.BigInteger -import kotlin.Long import kotlin.Unit /** - * Duration + * BlockSignature * - * Generated from 'Duration' tuple structure + * Generated from 'BlockSignature' tuple structure */ -public data class Duration( +public data class BlockSignature( public val u64: BigInteger, - public val u32: Long, + public val signatureOf: SignatureOf, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Duration = try { - Duration( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockSignature = try { + BlockSignature( reader.readUint64(), - reader.readUint32(), + SignatureOf.read(reader) as SignatureOf, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Duration): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: BlockSignature): Unit = try { writer.writeUint64(instance.u64) - writer.writeUint32(instance.u32) + SignatureOf.write(writer, instance.signatureOf) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValueType.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockStatus.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValueType.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockStatus.kt index a8a93d21d..df507d132 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/AssetValueType.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BlockStatus.kt @@ -15,184 +15,180 @@ import kotlin.Int import kotlin.Unit /** - * AssetValueType + * BlockStatus * - * Generated from 'AssetValueType' enum + * Generated from 'BlockStatus' enum */ -public sealed class AssetValueType : ModelEnum { +public sealed class BlockStatus : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int override fun equals(other: Any?): Boolean = when (this) { - is Quantity -> Quantity.equals(this, other) - is BigQuantity -> BigQuantity.equals(this, other) - is Fixed -> Fixed.equals(this, other) - is Store -> Store.equals(this, other) + is Approved -> Approved.equals(this, other) + is Committed -> Committed.equals(this, other) + is Applied -> Applied.equals(this, other) else -> super.equals(other) } override fun hashCode(): Int = when (this) { - is Quantity -> Quantity.hashCode() - is BigQuantity -> BigQuantity.hashCode() - is Fixed -> Fixed.hashCode() - is Store -> Store.hashCode() + is Approved -> Approved.hashCode() + is Committed -> Committed.hashCode() + is Applied -> Applied.hashCode() else -> super.hashCode() } /** - * 'Quantity' variant + * 'Approved' variant */ - public class Quantity : AssetValueType() { + public class Approved : BlockStatus() { 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.AssetValueType.Quantity = try { - Quantity() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockStatus.Approved = try { + Approved() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValueType.Quantity, + instance: jp.co.soramitsu.iroha2.generated.BlockStatus.Approved, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetValueType.Quantity, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.BlockStatus.Approved, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".AssetValueType.Quantity".hashCode() + override fun hashCode(): Int = ".BlockStatus.Approved".hashCode() } } /** - * 'BigQuantity' variant + * 'Rejected' variant */ - public class BigQuantity : AssetValueType() { + public data class Rejected( + public val blockRejectionReason: BlockRejectionReason, + ) : BlockStatus() { 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.AssetValueType.BigQuantity = try { - BigQuantity() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockStatus.Rejected = try { + Rejected( + BlockRejectionReason.read(reader), + ) } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValueType.BigQuantity, + instance: jp.co.soramitsu.iroha2.generated.BlockStatus.Rejected, ): Unit = try { + BlockRejectionReason.write(writer, instance.blockRejectionReason) } catch (ex: Exception) { throw wrapException(ex) } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetValueType.BigQuantity, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".AssetValueType.BigQuantity".hashCode() } } /** - * 'Fixed' variant + * 'Committed' variant */ - public class Fixed : AssetValueType() { + public class Committed : BlockStatus() { 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.AssetValueType.Fixed = try { - Fixed() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockStatus.Committed = try { + Committed() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValueType.Fixed, + instance: jp.co.soramitsu.iroha2.generated.BlockStatus.Committed, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetValueType.Fixed, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.BlockStatus.Committed, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".AssetValueType.Fixed".hashCode() + override fun hashCode(): Int = ".BlockStatus.Committed".hashCode() } } /** - * 'Store' variant + * 'Applied' variant */ - public class Store : AssetValueType() { + public class Applied : BlockStatus() { 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.AssetValueType.Store = try { - Store() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.BlockStatus.Applied = try { + Applied() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.AssetValueType.Store, + instance: jp.co.soramitsu.iroha2.generated.BlockStatus.Applied, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.AssetValueType.Store, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.BlockStatus.Applied, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".AssetValueType.Store".hashCode() + override fun hashCode(): Int = ".BlockStatus.Applied".hashCode() } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): AssetValueType = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BlockStatus = when ( val discriminant = reader.readUByte() ) { - 0 -> Quantity.read(reader) - 1 -> BigQuantity.read(reader) - 2 -> Fixed.read(reader) - 3 -> Store.read(reader) + 0 -> Approved.read(reader) + 1 -> Rejected.read(reader) + 2 -> Committed.read(reader) + 3 -> Applied.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: AssetValueType) { + override fun write(writer: ScaleCodecWriter, instance: BlockStatus) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Quantity.write(writer, instance as Quantity) - 1 -> BigQuantity.write(writer, instance as BigQuantity) - 2 -> Fixed.write(writer, instance as Fixed) - 3 -> Store.write(writer, instance as Store) + 0 -> Approved.write(writer, instance as Approved) + 1 -> Rejected.write(writer, instance as Rejected) + 2 -> Committed.write(writer, instance as Committed) + 3 -> Applied.write(writer, instance as Applied) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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/BurnBox.kt new file mode 100644 index 000000000..a7e7b29ec --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnBox.kt @@ -0,0 +1,108 @@ +// +// 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 + +/** + * BurnBox + * + * Generated from 'BurnBox' enum + */ +public sealed class BurnBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Asset' variant + */ + public data class Asset( + public val burnOfNumericAndAsset: BurnOfNumericAndAsset, + ) : BurnBox() { + 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.BurnBox.Asset = + try { + Asset( + BurnOfNumericAndAsset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.BurnBox.Asset, + ): Unit = try { + BurnOfNumericAndAsset.write(writer, instance.burnOfNumericAndAsset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'TriggerRepetitions' variant + */ + public data class TriggerRepetitions( + public val burnOfu32AndTrigger: BurnOfu32AndTrigger, + ) : BurnBox() { + 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.BurnBox.TriggerRepetitions = try { + TriggerRepetitions( + BurnOfu32AndTrigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.BurnBox.TriggerRepetitions, + ): Unit = try { + BurnOfu32AndTrigger.write(writer, instance.burnOfu32AndTrigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BurnBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Asset.read(reader) + 1 -> TriggerRepetitions.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: BurnBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Asset.write(writer, instance as Asset) + 1 -> TriggerRepetitions.write(writer, instance as TriggerRepetitions) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.kt deleted file mode 100644 index 79a1382d3..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnExpr.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 - -/** - * BurnExpr - * - * Generated from 'BurnExpr' regular structure - */ -public data class BurnExpr( - public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): BurnExpr = try { - BurnExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: BurnExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) - EvaluatesTo.write(writer, instance.destinationId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfNumericAndAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfNumericAndAsset.kt new file mode 100644 index 000000000..5e4b85de6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfNumericAndAsset.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 + +/** + * BurnOfNumericAndAsset + * + * Generated from 'BurnOfNumericAndAsset' regular structure + */ +public data class BurnOfNumericAndAsset( + public val `object`: Numeric, + public val destination: AssetId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BurnOfNumericAndAsset = try { + BurnOfNumericAndAsset( + Numeric.read(reader), + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BurnOfNumericAndAsset): Unit = try { + Numeric.write(writer, instance.`object`) + AssetId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfu32AndTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfu32AndTrigger.kt new file mode 100644 index 000000000..f8681d7fe --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/BurnOfu32AndTrigger.kt @@ -0,0 +1,40 @@ +// +// 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.Long +import kotlin.Unit + +/** + * BurnOfu32AndTrigger + * + * Generated from 'BurnOfu32AndTrigger' regular structure + */ +public data class BurnOfu32AndTrigger( + public val `object`: Long, + public val destination: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): BurnOfu32AndTrigger = try { + BurnOfu32AndTrigger( + reader.readUint32(), + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: BurnOfu32AndTrigger): Unit = try { + writer.writeUint32(instance.`object`) + TriggerId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnAssetWithDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnAssetWithDefinition.kt new file mode 100644 index 000000000..265ec6a71 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnAssetWithDefinition.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanBurnAssetWithDefinition + * + * Generated from 'CanBurnAssetWithDefinition' regular structure + */ +public data class CanBurnAssetWithDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanBurnAssetWithDefinition = try { + CanBurnAssetWithDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanBurnAssetWithDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContextValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserAsset.kt similarity index 57% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContextValue.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserAsset.kt index 8cd104ec2..c33542aea 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContextValue.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserAsset.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ContextValue + * CanBurnUserAsset * - * Generated from 'ContextValue' regular structure + * Generated from 'CanBurnUserAsset' regular structure */ -public data class ContextValue( - public val valueName: Name, +public data class CanBurnUserAsset( + public val asset: AssetId, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ContextValue = try { - ContextValue( - Name.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanBurnUserAsset = try { + CanBurnUserAsset( + AssetId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ContextValue): Unit = try { - Name.write(writer, instance.valueName) + override fun write(writer: ScaleCodecWriter, instance: CanBurnUserAsset): Unit = try { + AssetId.write(writer, instance.asset) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserTrigger.kt new file mode 100644 index 000000000..09d8e0339 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanBurnUserTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanBurnUserTrigger + * + * Generated from 'CanBurnUserTrigger' regular structure + */ +public data class CanBurnUserTrigger( + public val trigger: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanBurnUserTrigger = try { + CanBurnUserTrigger( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanBurnUserTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanExecuteUserTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanExecuteUserTrigger.kt new file mode 100644 index 000000000..a5b5900ce --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanExecuteUserTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanExecuteUserTrigger + * + * Generated from 'CanExecuteUserTrigger' regular structure + */ +public data class CanExecuteUserTrigger( + public val trigger: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanExecuteUserTrigger = try { + CanExecuteUserTrigger( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanExecuteUserTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintAssetWithDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintAssetWithDefinition.kt new file mode 100644 index 000000000..1b4ce4ae3 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintAssetWithDefinition.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanMintAssetWithDefinition + * + * Generated from 'CanMintAssetWithDefinition' regular structure + */ +public data class CanMintAssetWithDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanMintAssetWithDefinition = try { + CanMintAssetWithDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanMintAssetWithDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserAsset.kt new file mode 100644 index 000000000..1f237f34c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserAsset.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanMintUserAsset + * + * Generated from 'CanMintUserAsset' regular structure + */ +public data class CanMintUserAsset( + public val asset: AssetId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanMintUserAsset = try { + CanMintUserAsset( + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanMintUserAsset): Unit = try { + AssetId.write(writer, instance.asset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserTrigger.kt new file mode 100644 index 000000000..4f2f09288 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanMintUserTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanMintUserTrigger + * + * Generated from 'CanMintUserTrigger' regular structure + */ +public data class CanMintUserTrigger( + public val trigger: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanMintUserTrigger = try { + CanMintUserTrigger( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanMintUserTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAccountInDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAccountInDomain.kt new file mode 100644 index 000000000..dea60174e --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAccountInDomain.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanRegisterAccountInDomain + * + * Generated from 'CanRegisterAccountInDomain' regular structure + */ +public data class CanRegisterAccountInDomain( + public val domain: DomainId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRegisterAccountInDomain = try { + CanRegisterAccountInDomain( + DomainId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanRegisterAccountInDomain): Unit = try { + DomainId.write(writer, instance.domain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetDefinitionInDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetDefinitionInDomain.kt new file mode 100644 index 000000000..858dc873a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetDefinitionInDomain.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanRegisterAssetDefinitionInDomain + * + * Generated from 'CanRegisterAssetDefinitionInDomain' regular structure + */ +public data class CanRegisterAssetDefinitionInDomain( + public val domain: DomainId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRegisterAssetDefinitionInDomain = try { + CanRegisterAssetDefinitionInDomain( + DomainId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanRegisterAssetDefinitionInDomain): Unit = try { + DomainId.write(writer, instance.domain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetWithDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetWithDefinition.kt new file mode 100644 index 000000000..0ba87046b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterAssetWithDefinition.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 + +/** + * CanRegisterAssetWithDefinition + * + * Generated from 'CanRegisterAssetWithDefinition' regular structure + */ +public data class CanRegisterAssetWithDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRegisterAssetWithDefinition = try { + CanRegisterAssetWithDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanRegisterAssetWithDefinition): Unit = + try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterUserTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterUserTrigger.kt new file mode 100644 index 000000000..415c2f987 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRegisterUserTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanRegisterUserTrigger + * + * Generated from 'CanRegisterUserTrigger' regular structure + */ +public data class CanRegisterUserTrigger( + public val account: AccountId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRegisterUserTrigger = try { + CanRegisterUserTrigger( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanRegisterUserTrigger): Unit = try { + AccountId.write(writer, instance.account) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAccountEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAccount.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAccountEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAccount.kt index a9293943c..b75459474 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAccountEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAccount.kt @@ -11,26 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfAccountEvent + * CanRemoveKeyValueInAccount * - * Generated from 'OriginFilterOfAccountEvent' regular structure + * Generated from 'CanRemoveKeyValueInAccount' regular structure */ -public data class OriginFilterOfAccountEvent( - public val accountId: AccountId, +public data class CanRemoveKeyValueInAccount( + public val account: AccountId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfAccountEvent = try { - OriginFilterOfAccountEvent( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRemoveKeyValueInAccount = try { + CanRemoveKeyValueInAccount( AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfAccountEvent): Unit = try { - AccountId.write(writer, instance.accountId) + override fun write(writer: ScaleCodecWriter, instance: CanRemoveKeyValueInAccount): Unit = try { + AccountId.write(writer, instance.account) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetDefinitionEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAssetDefinition.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetDefinitionEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAssetDefinition.kt index 5b903e86b..da5718ba5 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetDefinitionEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInAssetDefinition.kt @@ -11,26 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfAssetDefinitionEvent + * CanRemoveKeyValueInAssetDefinition * - * Generated from 'OriginFilterOfAssetDefinitionEvent' regular structure + * Generated from 'CanRemoveKeyValueInAssetDefinition' regular structure */ -public data class OriginFilterOfAssetDefinitionEvent( - public val assetDefinitionId: AssetDefinitionId, +public data class CanRemoveKeyValueInAssetDefinition( + public val assetDefinition: AssetDefinitionId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfAssetDefinitionEvent = try { - OriginFilterOfAssetDefinitionEvent( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRemoveKeyValueInAssetDefinition = try { + CanRemoveKeyValueInAssetDefinition( AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfAssetDefinitionEvent): Unit = try { - AssetDefinitionId.write(writer, instance.assetDefinitionId) + override fun write(writer: ScaleCodecWriter, instance: CanRemoveKeyValueInAssetDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.assetDefinition) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfDomainEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInDomain.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfDomainEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInDomain.kt index 5570592c2..ed241bfea 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfDomainEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInDomain.kt @@ -11,26 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfDomainEvent + * CanRemoveKeyValueInDomain * - * Generated from 'OriginFilterOfDomainEvent' regular structure + * Generated from 'CanRemoveKeyValueInDomain' regular structure */ -public data class OriginFilterOfDomainEvent( - public val domainId: DomainId, +public data class CanRemoveKeyValueInDomain( + public val domain: DomainId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfDomainEvent = try { - OriginFilterOfDomainEvent( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRemoveKeyValueInDomain = try { + CanRemoveKeyValueInDomain( DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfDomainEvent): Unit = try { - DomainId.write(writer, instance.domainId) + override fun write(writer: ScaleCodecWriter, instance: CanRemoveKeyValueInDomain): Unit = try { + DomainId.write(writer, instance.domain) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfTriggerEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInTrigger.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfTriggerEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInTrigger.kt index 545d411b0..a03af883c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfTriggerEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInTrigger.kt @@ -11,26 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfTriggerEvent + * CanRemoveKeyValueInTrigger * - * Generated from 'OriginFilterOfTriggerEvent' regular structure + * Generated from 'CanRemoveKeyValueInTrigger' regular structure */ -public data class OriginFilterOfTriggerEvent( - public val triggerId: TriggerId, +public data class CanRemoveKeyValueInTrigger( + public val trigger: TriggerId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfTriggerEvent = try { - OriginFilterOfTriggerEvent( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRemoveKeyValueInTrigger = try { + CanRemoveKeyValueInTrigger( TriggerId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfTriggerEvent): Unit = try { - TriggerId.write(writer, instance.triggerId) + override fun write(writer: ScaleCodecWriter, instance: CanRemoveKeyValueInTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInUserAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInUserAsset.kt new file mode 100644 index 000000000..2a955e704 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanRemoveKeyValueInUserAsset.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanRemoveKeyValueInUserAsset + * + * Generated from 'CanRemoveKeyValueInUserAsset' regular structure + */ +public data class CanRemoveKeyValueInUserAsset( + public val asset: AssetId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanRemoveKeyValueInUserAsset = try { + CanRemoveKeyValueInUserAsset( + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanRemoveKeyValueInUserAsset): Unit = try { + AssetId.write(writer, instance.asset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAccount.kt new file mode 100644 index 000000000..024ef5a7b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAccount.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanSetKeyValueInAccount + * + * Generated from 'CanSetKeyValueInAccount' regular structure + */ +public data class CanSetKeyValueInAccount( + public val account: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanSetKeyValueInAccount = try { + CanSetKeyValueInAccount( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanSetKeyValueInAccount): Unit = try { + AccountId.write(writer, instance.account) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAssetDefinition.kt new file mode 100644 index 000000000..c22ec37e5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInAssetDefinition.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 + +/** + * CanSetKeyValueInAssetDefinition + * + * Generated from 'CanSetKeyValueInAssetDefinition' regular structure + */ +public data class CanSetKeyValueInAssetDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanSetKeyValueInAssetDefinition = try { + CanSetKeyValueInAssetDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanSetKeyValueInAssetDefinition): Unit = + try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInDomain.kt new file mode 100644 index 000000000..f0dd9ed2c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInDomain.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanSetKeyValueInDomain + * + * Generated from 'CanSetKeyValueInDomain' regular structure + */ +public data class CanSetKeyValueInDomain( + public val domain: DomainId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanSetKeyValueInDomain = try { + CanSetKeyValueInDomain( + DomainId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanSetKeyValueInDomain): Unit = try { + DomainId.write(writer, instance.domain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInTrigger.kt new file mode 100644 index 000000000..844a06c7f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInTrigger.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanSetKeyValueInTrigger + * + * Generated from 'CanSetKeyValueInTrigger' regular structure + */ +public data class CanSetKeyValueInTrigger( + public val trigger: TriggerId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanSetKeyValueInTrigger = try { + CanSetKeyValueInTrigger( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanSetKeyValueInTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInUserAsset.kt similarity index 53% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInUserAsset.kt index f29e894b4..6070ca368 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfAssetEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanSetKeyValueInUserAsset.kt @@ -11,26 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfAssetEvent + * CanSetKeyValueInUserAsset * - * Generated from 'OriginFilterOfAssetEvent' regular structure + * Generated from 'CanSetKeyValueInUserAsset' regular structure */ -public data class OriginFilterOfAssetEvent( - public val assetId: AssetId, +public data class CanSetKeyValueInUserAsset( + public val asset: AssetId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfAssetEvent = try { - OriginFilterOfAssetEvent( + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanSetKeyValueInUserAsset = try { + CanSetKeyValueInUserAsset( AssetId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfAssetEvent): Unit = try { - AssetId.write(writer, instance.assetId) + override fun write(writer: ScaleCodecWriter, instance: CanSetKeyValueInUserAsset): Unit = try { + AssetId.write(writer, instance.asset) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferAssetWithDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferAssetWithDefinition.kt new file mode 100644 index 000000000..d8df1d595 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferAssetWithDefinition.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 + +/** + * CanTransferAssetWithDefinition + * + * Generated from 'CanTransferAssetWithDefinition' regular structure + */ +public data class CanTransferAssetWithDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanTransferAssetWithDefinition = try { + CanTransferAssetWithDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanTransferAssetWithDefinition): Unit = + try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferUserAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferUserAsset.kt new file mode 100644 index 000000000..2c4322986 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanTransferUserAsset.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanTransferUserAsset + * + * Generated from 'CanTransferUserAsset' regular structure + */ +public data class CanTransferUserAsset( + public val asset: AssetId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanTransferUserAsset = try { + CanTransferUserAsset( + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanTransferUserAsset): Unit = try { + AssetId.write(writer, instance.asset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAccount.kt new file mode 100644 index 000000000..dae14c76d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAccount.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanUnregisterAccount + * + * Generated from 'CanUnregisterAccount' regular structure + */ +public data class CanUnregisterAccount( + public val account: AccountId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterAccount = try { + CanUnregisterAccount( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterAccount): Unit = try { + AccountId.write(writer, instance.account) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetDefinition.kt new file mode 100644 index 000000000..e9bb10982 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetDefinition.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanUnregisterAssetDefinition + * + * Generated from 'CanUnregisterAssetDefinition' regular structure + */ +public data class CanUnregisterAssetDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterAssetDefinition = try { + CanUnregisterAssetDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterAssetDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetWithDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetWithDefinition.kt new file mode 100644 index 000000000..026066d46 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterAssetWithDefinition.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 + +/** + * CanUnregisterAssetWithDefinition + * + * Generated from 'CanUnregisterAssetWithDefinition' regular structure + */ +public data class CanUnregisterAssetWithDefinition( + public val assetDefinition: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterAssetWithDefinition = try { + CanUnregisterAssetWithDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterAssetWithDefinition): Unit = + try { + AssetDefinitionId.write(writer, instance.assetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterDomain.kt new file mode 100644 index 000000000..5100adc0a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterDomain.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanUnregisterDomain + * + * Generated from 'CanUnregisterDomain' regular structure + */ +public data class CanUnregisterDomain( + public val domain: DomainId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterDomain = try { + CanUnregisterDomain( + DomainId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterDomain): Unit = try { + DomainId.write(writer, instance.domain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserAsset.kt new file mode 100644 index 000000000..c29a1a1c8 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserAsset.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * CanUnregisterUserAsset + * + * Generated from 'CanUnregisterUserAsset' regular structure + */ +public data class CanUnregisterUserAsset( + public val asset: AssetId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterUserAsset = try { + CanUnregisterUserAsset( + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterUserAsset): Unit = try { + AssetId.write(writer, instance.asset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserTrigger.kt new file mode 100644 index 000000000..80340de0b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CanUnregisterUserTrigger.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * CanUnregisterUserTrigger + * + * Generated from 'CanUnregisterUserTrigger' regular structure + */ +public data class CanUnregisterUserTrigger( + public val account: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CanUnregisterUserTrigger = try { + CanUnregisterUserTrigger( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CanUnregisterUserTrigger): Unit = try { + AccountId.write(writer, instance.account) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringWithJson.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ChainId.kt similarity index 64% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringWithJson.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ChainId.kt index cbd600fd9..9e3302da7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringWithJson.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ChainId.kt @@ -12,23 +12,23 @@ import kotlin.String import kotlin.Unit /** - * StringWithJson + * ChainId * - * Generated from 'StringWithJson' regular structure + * Generated from 'ChainId' regular structure */ -public data class StringWithJson( +public data class ChainId( public val string: String, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): StringWithJson = try { - StringWithJson( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ChainId = try { + ChainId( reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: StringWithJson): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: ChainId): Unit = try { writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ClientQueryPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ClientQueryPayload.kt new file mode 100644 index 000000000..ece309fff --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ClientQueryPayload.kt @@ -0,0 +1,51 @@ +// +// 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 + +/** + * ClientQueryPayload + * + * Generated from 'ClientQueryPayload' regular structure + */ +public data class ClientQueryPayload( + public val authority: AccountId, + public val query: QueryBox, + public val filter: GenericPredicateBox, + public val sorting: Sorting, + public val pagination: Pagination, + public val fetchSize: FetchSize, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ClientQueryPayload = try { + ClientQueryPayload( + AccountId.read(reader), + QueryBox.read(reader), + GenericPredicateBox.read(reader) as GenericPredicateBox, + Sorting.read(reader), + Pagination.read(reader), + FetchSize.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: ClientQueryPayload): Unit = try { + AccountId.write(writer, instance.authority) + QueryBox.write(writer, instance.query) + GenericPredicateBox.write(writer, instance.filter) + Sorting.write(writer, instance.sorting) + Pagination.write(writer, instance.pagination) + FetchSize.write(writer, instance.fetchSize) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} 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/CommittedTransaction.kt similarity index 68% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionValue.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedTransaction.kt index 322e720ec..8359fa420 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/CommittedTransaction.kt @@ -11,17 +11,17 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * TransactionValue + * CommittedTransaction * - * Generated from 'TransactionValue' regular structure + * Generated from 'CommittedTransaction' regular structure */ -public data class TransactionValue( +public data class CommittedTransaction( public val `value`: SignedTransaction, public val error: TransactionRejectionReason? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TransactionValue = try { - TransactionValue( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CommittedTransaction = try { + CommittedTransaction( SignedTransaction.read(reader), reader.readNullable(TransactionRejectionReason) as TransactionRejectionReason?, ) @@ -29,7 +29,7 @@ public data class TransactionValue( throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: TransactionValue): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: CommittedTransaction): Unit = try { SignedTransaction.write(writer, instance.`value`) writer.writeNullable(TransactionRejectionReason, instance.error) } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedTransactionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedTransactionPredicateBox.kt new file mode 100644 index 000000000..0f41cf40a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CommittedTransactionPredicateBox.kt @@ -0,0 +1,111 @@ +// +// 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 + +/** + * CommittedTransactionPredicateBox + * + * Generated from 'CommittedTransactionPredicateBox' enum + */ +public sealed class CommittedTransactionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Value' variant + */ + public data class Value( + public val signedTransactionPredicateBox: SignedTransactionPredicateBox, + ) : CommittedTransactionPredicateBox() { + 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.CommittedTransactionPredicateBox.Value = try { + Value( + SignedTransactionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CommittedTransactionPredicateBox.Value, + ): Unit = + try { + SignedTransactionPredicateBox.write(writer, instance.signedTransactionPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Error' variant + */ + public data class Error( + public val transactionErrorPredicateBox: TransactionErrorPredicateBox, + ) : CommittedTransactionPredicateBox() { + 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.CommittedTransactionPredicateBox.Error = try { + Error( + TransactionErrorPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CommittedTransactionPredicateBox.Error, + ): Unit = + try { + TransactionErrorPredicateBox.write(writer, instance.transactionErrorPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CommittedTransactionPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Value.read(reader) + 1 -> Error.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CommittedTransactionPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Value.write(writer, instance as Value) + 1 -> Error.write(writer, instance as Error) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAccountPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAccountPredicateBox.kt new file mode 100644 index 000000000..45b664893 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAccountPredicateBox.kt @@ -0,0 +1,187 @@ +// +// 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 + +/** + * CompoundPredicateOfAccountPredicateBox + * + * Generated from 'CompoundPredicateOfAccountPredicateBox' enum + */ +public sealed class CompoundPredicateOfAccountPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val accountPredicateBox: AccountPredicateBox, + ) : CompoundPredicateOfAccountPredicateBox() { + 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.CompoundPredicateOfAccountPredicateBox.Atom = try { + Atom( + AccountPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.Atom, + ): Unit = try { + AccountPredicateBox.write(writer, instance.accountPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfAccountPredicateBox: CompoundPredicateOfAccountPredicateBox, + ) : CompoundPredicateOfAccountPredicateBox() { + 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.CompoundPredicateOfAccountPredicateBox.Not = try { + Not( + CompoundPredicateOfAccountPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfAccountPredicateBox.write( + writer, + instance.compoundPredicateOfAccountPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfAccountPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAccountPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAccountPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfAccountPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAccountPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAccountPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAccountPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfAccountPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfAccountPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetDefinitionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetDefinitionPredicateBox.kt new file mode 100644 index 000000000..c1e438290 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetDefinitionPredicateBox.kt @@ -0,0 +1,189 @@ +// +// 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 + +/** + * CompoundPredicateOfAssetDefinitionPredicateBox + * + * Generated from 'CompoundPredicateOfAssetDefinitionPredicateBox' enum + */ +public sealed class CompoundPredicateOfAssetDefinitionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val assetDefinitionPredicateBox: AssetDefinitionPredicateBox, + ) : CompoundPredicateOfAssetDefinitionPredicateBox() { + 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.CompoundPredicateOfAssetDefinitionPredicateBox.Atom = try { + Atom( + AssetDefinitionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.Atom, + ): Unit = try { + AssetDefinitionPredicateBox.write(writer, instance.assetDefinitionPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfAssetDefinitionPredicateBox: + CompoundPredicateOfAssetDefinitionPredicateBox, + ) : CompoundPredicateOfAssetDefinitionPredicateBox() { + 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.CompoundPredicateOfAssetDefinitionPredicateBox.Not = try { + Not( + CompoundPredicateOfAssetDefinitionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfAssetDefinitionPredicateBox.write( + writer, + instance.compoundPredicateOfAssetDefinitionPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfAssetDefinitionPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAssetDefinitionPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAssetDefinitionPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfAssetDefinitionPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAssetDefinitionPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetDefinitionPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAssetDefinitionPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfAssetDefinitionPredicateBox = + when (val discriminant = reader.readUByte()) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfAssetDefinitionPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetPredicateBox.kt new file mode 100644 index 000000000..41dcffd98 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfAssetPredicateBox.kt @@ -0,0 +1,187 @@ +// +// 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 + +/** + * CompoundPredicateOfAssetPredicateBox + * + * Generated from 'CompoundPredicateOfAssetPredicateBox' enum + */ +public sealed class CompoundPredicateOfAssetPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val assetPredicateBox: AssetPredicateBox, + ) : CompoundPredicateOfAssetPredicateBox() { + 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.CompoundPredicateOfAssetPredicateBox.Atom = try { + Atom( + AssetPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.Atom, + ): Unit = try { + AssetPredicateBox.write(writer, instance.assetPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfAssetPredicateBox: CompoundPredicateOfAssetPredicateBox, + ) : CompoundPredicateOfAssetPredicateBox() { + 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.CompoundPredicateOfAssetPredicateBox.Not = try { + Not( + CompoundPredicateOfAssetPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfAssetPredicateBox.write( + writer, + instance.compoundPredicateOfAssetPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfAssetPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAssetPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAssetPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfAssetPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfAssetPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfAssetPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfAssetPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfAssetPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfAssetPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfBlockHeaderPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfBlockHeaderPredicateBox.kt new file mode 100644 index 000000000..143aa7d55 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfBlockHeaderPredicateBox.kt @@ -0,0 +1,189 @@ +// +// 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 + +/** + * CompoundPredicateOfBlockHeaderPredicateBox + * + * Generated from 'CompoundPredicateOfBlockHeaderPredicateBox' enum + */ +public sealed class CompoundPredicateOfBlockHeaderPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val blockHeaderPredicateBox: BlockHeaderPredicateBox, + ) : CompoundPredicateOfBlockHeaderPredicateBox() { + 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.CompoundPredicateOfBlockHeaderPredicateBox.Atom = try { + Atom( + BlockHeaderPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.Atom, + ): Unit = try { + BlockHeaderPredicateBox.write(writer, instance.blockHeaderPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfBlockHeaderPredicateBox: + CompoundPredicateOfBlockHeaderPredicateBox, + ) : CompoundPredicateOfBlockHeaderPredicateBox() { + 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.CompoundPredicateOfBlockHeaderPredicateBox.Not = try { + Not( + CompoundPredicateOfBlockHeaderPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfBlockHeaderPredicateBox.write( + writer, + instance.compoundPredicateOfBlockHeaderPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfBlockHeaderPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfBlockHeaderPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfBlockHeaderPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfBlockHeaderPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfBlockHeaderPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfBlockHeaderPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfBlockHeaderPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfBlockHeaderPredicateBox = + when (val discriminant = reader.readUByte()) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfBlockHeaderPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfDomainPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfDomainPredicateBox.kt new file mode 100644 index 000000000..08a709838 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfDomainPredicateBox.kt @@ -0,0 +1,187 @@ +// +// 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 + +/** + * CompoundPredicateOfDomainPredicateBox + * + * Generated from 'CompoundPredicateOfDomainPredicateBox' enum + */ +public sealed class CompoundPredicateOfDomainPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val domainPredicateBox: DomainPredicateBox, + ) : CompoundPredicateOfDomainPredicateBox() { + 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.CompoundPredicateOfDomainPredicateBox.Atom = try { + Atom( + DomainPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.Atom, + ): Unit = try { + DomainPredicateBox.write(writer, instance.domainPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfDomainPredicateBox: CompoundPredicateOfDomainPredicateBox, + ) : CompoundPredicateOfDomainPredicateBox() { + 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.CompoundPredicateOfDomainPredicateBox.Not = try { + Not( + CompoundPredicateOfDomainPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfDomainPredicateBox.write( + writer, + instance.compoundPredicateOfDomainPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfDomainPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfDomainPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfDomainPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfDomainPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfDomainPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfDomainPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfDomainPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfDomainPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfDomainPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPeerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPeerPredicateBox.kt new file mode 100644 index 000000000..c173ec28c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPeerPredicateBox.kt @@ -0,0 +1,188 @@ +// +// 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 + +/** + * CompoundPredicateOfPeerPredicateBox + * + * Generated from 'CompoundPredicateOfPeerPredicateBox' enum + */ +public sealed class CompoundPredicateOfPeerPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val peerPredicateBox: PeerPredicateBox, + ) : CompoundPredicateOfPeerPredicateBox() { + 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.CompoundPredicateOfPeerPredicateBox.Atom = try { + Atom( + PeerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.Atom, + ): Unit = try { + PeerPredicateBox.write(writer, instance.peerPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfPeerPredicateBox: CompoundPredicateOfPeerPredicateBox, + ) : CompoundPredicateOfPeerPredicateBox() { + 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.CompoundPredicateOfPeerPredicateBox.Not = try { + Not( + CompoundPredicateOfPeerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfPeerPredicateBox.write( + writer, + instance.compoundPredicateOfPeerPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfPeerPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfPeerPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfPeerPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfPeerPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfPeerPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPeerPredicateBox.Or, + ): Unit = + try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfPeerPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfPeerPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfPeerPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPermissionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPermissionPredicateBox.kt new file mode 100644 index 000000000..90ad9bb31 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfPermissionPredicateBox.kt @@ -0,0 +1,188 @@ +// +// 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 + +/** + * CompoundPredicateOfPermissionPredicateBox + * + * Generated from 'CompoundPredicateOfPermissionPredicateBox' enum + */ +public sealed class CompoundPredicateOfPermissionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val permissionPredicateBox: PermissionPredicateBox, + ) : CompoundPredicateOfPermissionPredicateBox() { + 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.CompoundPredicateOfPermissionPredicateBox.Atom = try { + Atom( + PermissionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.Atom, + ): Unit = try { + PermissionPredicateBox.write(writer, instance.permissionPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfPermissionPredicateBox: CompoundPredicateOfPermissionPredicateBox, + ) : CompoundPredicateOfPermissionPredicateBox() { + 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.CompoundPredicateOfPermissionPredicateBox.Not = try { + Not( + CompoundPredicateOfPermissionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfPermissionPredicateBox.write( + writer, + instance.compoundPredicateOfPermissionPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfPermissionPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfPermissionPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfPermissionPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfPermissionPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfPermissionPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfPermissionPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfPermissionPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfPermissionPredicateBox = + when (val discriminant = reader.readUByte()) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfPermissionPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRoleIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRoleIdPredicateBox.kt new file mode 100644 index 000000000..4c871c6cd --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRoleIdPredicateBox.kt @@ -0,0 +1,187 @@ +// +// 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 + +/** + * CompoundPredicateOfRoleIdPredicateBox + * + * Generated from 'CompoundPredicateOfRoleIdPredicateBox' enum + */ +public sealed class CompoundPredicateOfRoleIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val roleIdPredicateBox: RoleIdPredicateBox, + ) : CompoundPredicateOfRoleIdPredicateBox() { + 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.CompoundPredicateOfRoleIdPredicateBox.Atom = try { + Atom( + RoleIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.Atom, + ): Unit = try { + RoleIdPredicateBox.write(writer, instance.roleIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfRoleIdPredicateBox: CompoundPredicateOfRoleIdPredicateBox, + ) : CompoundPredicateOfRoleIdPredicateBox() { + 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.CompoundPredicateOfRoleIdPredicateBox.Not = try { + Not( + CompoundPredicateOfRoleIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfRoleIdPredicateBox.write( + writer, + instance.compoundPredicateOfRoleIdPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfRoleIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfRoleIdPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfRoleIdPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfRoleIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfRoleIdPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRoleIdPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfRoleIdPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfRoleIdPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfRoleIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRolePredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRolePredicateBox.kt new file mode 100644 index 000000000..83ddb0d6f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfRolePredicateBox.kt @@ -0,0 +1,188 @@ +// +// 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 + +/** + * CompoundPredicateOfRolePredicateBox + * + * Generated from 'CompoundPredicateOfRolePredicateBox' enum + */ +public sealed class CompoundPredicateOfRolePredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val rolePredicateBox: RolePredicateBox, + ) : CompoundPredicateOfRolePredicateBox() { + 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.CompoundPredicateOfRolePredicateBox.Atom = try { + Atom( + RolePredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.Atom, + ): Unit = try { + RolePredicateBox.write(writer, instance.rolePredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfRolePredicateBox: CompoundPredicateOfRolePredicateBox, + ) : CompoundPredicateOfRolePredicateBox() { + 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.CompoundPredicateOfRolePredicateBox.Not = try { + Not( + CompoundPredicateOfRolePredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.Not, + ): Unit = try { + CompoundPredicateOfRolePredicateBox.write( + writer, + instance.compoundPredicateOfRolePredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfRolePredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfRolePredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfRolePredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfRolePredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfRolePredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfRolePredicateBox.Or, + ): Unit = + try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfRolePredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfRolePredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfRolePredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfSignedBlockPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfSignedBlockPredicateBox.kt new file mode 100644 index 000000000..a598a6962 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfSignedBlockPredicateBox.kt @@ -0,0 +1,189 @@ +// +// 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 + +/** + * CompoundPredicateOfSignedBlockPredicateBox + * + * Generated from 'CompoundPredicateOfSignedBlockPredicateBox' enum + */ +public sealed class CompoundPredicateOfSignedBlockPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val signedBlockPredicateBox: SignedBlockPredicateBox, + ) : CompoundPredicateOfSignedBlockPredicateBox() { + 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.CompoundPredicateOfSignedBlockPredicateBox.Atom = try { + Atom( + SignedBlockPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.Atom, + ): Unit = try { + SignedBlockPredicateBox.write(writer, instance.signedBlockPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfSignedBlockPredicateBox: + CompoundPredicateOfSignedBlockPredicateBox, + ) : CompoundPredicateOfSignedBlockPredicateBox() { + 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.CompoundPredicateOfSignedBlockPredicateBox.Not = try { + Not( + CompoundPredicateOfSignedBlockPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfSignedBlockPredicateBox.write( + writer, + instance.compoundPredicateOfSignedBlockPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfSignedBlockPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfSignedBlockPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfSignedBlockPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfSignedBlockPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfSignedBlockPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfSignedBlockPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfSignedBlockPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfSignedBlockPredicateBox = + when (val discriminant = reader.readUByte()) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfSignedBlockPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTransactionQueryOutputPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTransactionQueryOutputPredicateBox.kt new file mode 100644 index 000000000..63af5b66a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTransactionQueryOutputPredicateBox.kt @@ -0,0 +1,194 @@ +// +// 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 + +/** + * CompoundPredicateOfTransactionQueryOutputPredicateBox + * + * Generated from 'CompoundPredicateOfTransactionQueryOutputPredicateBox' enum + */ +public sealed class CompoundPredicateOfTransactionQueryOutputPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val transactionQueryOutputPredicateBox: TransactionQueryOutputPredicateBox, + ) : CompoundPredicateOfTransactionQueryOutputPredicateBox() { + 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.CompoundPredicateOfTransactionQueryOutputPredicateBox.Atom = try { + Atom( + TransactionQueryOutputPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.Atom, + ): Unit = try { + TransactionQueryOutputPredicateBox.write( + writer, + instance.transactionQueryOutputPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfTransactionQueryOutputPredicateBox: + CompoundPredicateOfTransactionQueryOutputPredicateBox, + ) : CompoundPredicateOfTransactionQueryOutputPredicateBox() { + 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.CompoundPredicateOfTransactionQueryOutputPredicateBox.Not = try { + Not( + CompoundPredicateOfTransactionQueryOutputPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfTransactionQueryOutputPredicateBox.write( + writer, + instance.compoundPredicateOfTransactionQueryOutputPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfTransactionQueryOutputPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTransactionQueryOutputPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTransactionQueryOutputPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfTransactionQueryOutputPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTransactionQueryOutputPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTransactionQueryOutputPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTransactionQueryOutputPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfTransactionQueryOutputPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfTransactionQueryOutputPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerIdPredicateBox.kt new file mode 100644 index 000000000..c57886dd7 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerIdPredicateBox.kt @@ -0,0 +1,190 @@ +// +// 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 + +/** + * CompoundPredicateOfTriggerIdPredicateBox + * + * Generated from 'CompoundPredicateOfTriggerIdPredicateBox' enum + */ +public sealed class CompoundPredicateOfTriggerIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val triggerIdPredicateBox: TriggerIdPredicateBox, + ) : CompoundPredicateOfTriggerIdPredicateBox() { + 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.CompoundPredicateOfTriggerIdPredicateBox.Atom = try { + Atom( + TriggerIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.Atom, + ): Unit = try { + TriggerIdPredicateBox.write(writer, instance.triggerIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfTriggerIdPredicateBox: CompoundPredicateOfTriggerIdPredicateBox, + ) : CompoundPredicateOfTriggerIdPredicateBox() { + 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.CompoundPredicateOfTriggerIdPredicateBox.Not = try { + Not( + CompoundPredicateOfTriggerIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfTriggerIdPredicateBox.write( + writer, + instance.compoundPredicateOfTriggerIdPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfTriggerIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTriggerIdPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTriggerIdPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfTriggerIdPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTriggerIdPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerIdPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTriggerIdPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfTriggerIdPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write( + writer: ScaleCodecWriter, + instance: CompoundPredicateOfTriggerIdPredicateBox, + ) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerPredicateBox.kt new file mode 100644 index 000000000..3daba80e5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CompoundPredicateOfTriggerPredicateBox.kt @@ -0,0 +1,187 @@ +// +// 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 + +/** + * CompoundPredicateOfTriggerPredicateBox + * + * Generated from 'CompoundPredicateOfTriggerPredicateBox' enum + */ +public sealed class CompoundPredicateOfTriggerPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Atom' variant + */ + public data class Atom( + public val triggerPredicateBox: TriggerPredicateBox, + ) : CompoundPredicateOfTriggerPredicateBox() { + 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.CompoundPredicateOfTriggerPredicateBox.Atom = try { + Atom( + TriggerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.Atom, + ): Unit = try { + TriggerPredicateBox.write(writer, instance.triggerPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Not' variant + */ + public data class Not( + public val compoundPredicateOfTriggerPredicateBox: CompoundPredicateOfTriggerPredicateBox, + ) : CompoundPredicateOfTriggerPredicateBox() { + 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.CompoundPredicateOfTriggerPredicateBox.Not = try { + Not( + CompoundPredicateOfTriggerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.Not, + ): Unit = try { + CompoundPredicateOfTriggerPredicateBox.write( + writer, + instance.compoundPredicateOfTriggerPredicateBox, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'And' variant + */ + public data class And( + public val vec: List, + ) : CompoundPredicateOfTriggerPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.And = try { + And( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTriggerPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.And, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTriggerPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Or' variant + */ + public data class Or( + public val vec: List, + ) : CompoundPredicateOfTriggerPredicateBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.Or = try { + Or( + reader.readVec(reader.readCompactInt()) { CompoundPredicateOfTriggerPredicateBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.CompoundPredicateOfTriggerPredicateBox.Or, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + CompoundPredicateOfTriggerPredicateBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): CompoundPredicateOfTriggerPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Atom.read(reader) + 1 -> Not.read(reader) + 2 -> And.read(reader) + 3 -> Or.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: CompoundPredicateOfTriggerPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Atom.write(writer, instance as Atom) + 1 -> Not.write(writer, instance as Not) + 2 -> And.write(writer, instance as And) + 3 -> Or.write(writer, instance as Or) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt deleted file mode 100644 index ca93e6b81..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConditionalExpr.kt +++ /dev/null @@ -1,43 +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.Boolean -import kotlin.Unit - -/** - * ConditionalExpr - * - * Generated from 'ConditionalExpr' regular structure - */ -public data class ConditionalExpr( - public val condition: EvaluatesTo, - public val then: InstructionExpr, - public val otherwise: InstructionExpr? = null, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ConditionalExpr = try { - ConditionalExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - InstructionExpr.read(reader), - reader.readNullable(InstructionExpr) as InstructionExpr?, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: ConditionalExpr): Unit = try { - EvaluatesTo.write(writer, instance.condition) - 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/ConfigurationEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEvent.kt index 42d77c160..1a164848c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEvent.kt @@ -27,7 +27,7 @@ public sealed class ConfigurationEvent : ModelEnum { * 'Changed' variant */ public data class Changed( - public val parameterId: ParameterId, + public val parameterChanged: ParameterChanged, ) : ConfigurationEvent() { override fun discriminant(): Int = DISCRIMINANT @@ -38,7 +38,7 @@ public sealed class ConfigurationEvent : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ConfigurationEvent.Changed = try { Changed( - ParameterId.read(reader), + ParameterChanged.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -48,71 +48,7 @@ public sealed class ConfigurationEvent : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.ConfigurationEvent.Changed, ): Unit = try { - ParameterId.write(writer, instance.parameterId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Created' variant - */ - public data class Created( - public val parameterId: ParameterId, - ) : ConfigurationEvent() { - 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.ConfigurationEvent.Created = try { - Created( - ParameterId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ConfigurationEvent.Created, - ): Unit = try { - ParameterId.write(writer, instance.parameterId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Deleted' variant - */ - public data class Deleted( - public val parameterId: ParameterId, - ) : ConfigurationEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ConfigurationEvent.Deleted = try { - Deleted( - ParameterId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ConfigurationEvent.Deleted, - ): Unit = try { - ParameterId.write(writer, instance.parameterId) + ParameterChanged.write(writer, instance.parameterChanged) } catch (ex: Exception) { throw wrapException(ex) } @@ -125,16 +61,12 @@ public sealed class ConfigurationEvent : ModelEnum { reader.readUByte() ) { 0 -> Changed.read(reader) - 1 -> Created.read(reader) - 2 -> Deleted.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: ConfigurationEvent) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Changed.write(writer, instance as Changed) - 1 -> Created.write(writer, instance as Created) - 2 -> Deleted.write(writer, instance as Deleted) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LengthLimits.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEventFilter.kt similarity index 51% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LengthLimits.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEventFilter.kt index 18a031dbd..fd34ea517 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LengthLimits.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ConfigurationEventFilter.kt @@ -12,27 +12,26 @@ import kotlin.Long import kotlin.Unit /** - * LengthLimits + * ConfigurationEventFilter * - * Generated from 'LengthLimits' regular structure + * Generated from 'ConfigurationEventFilter' regular structure */ -public data class LengthLimits( - public val min: Long, - public val max: Long, +public data class ConfigurationEventFilter( + public val eventSet: Long, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): LengthLimits = try { - LengthLimits( - reader.readUint32(), + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): ConfigurationEventFilter = try { + ConfigurationEventFilter( reader.readUint32(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: LengthLimits): Unit = try { - writer.writeUint32(instance.min) - writer.writeUint32(instance.max) + override fun write(writer: ScaleCodecWriter, instance: ConfigurationEventFilter): Unit = try { + writer.writeUint32(instance.eventSet) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Container.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Container.kt index 8eddeb221..4be10b719 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Container.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Container.kt @@ -27,7 +27,7 @@ public sealed class Container : ModelEnum { * 'Any' variant */ public data class Any( - public val valuePredicate: ValuePredicate, + public val queryOutputPredicate: QueryOutputPredicate, ) : Container() { override fun discriminant(): Int = DISCRIMINANT @@ -39,7 +39,7 @@ public sealed class Container : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Container.Any = try { Any( - ValuePredicate.read(reader), + QueryOutputPredicate.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -49,7 +49,7 @@ public sealed class Container : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.Container.Any, ): Unit = try { - ValuePredicate.write(writer, instance.valuePredicate) + QueryOutputPredicate.write(writer, instance.queryOutputPredicate) } catch (ex: Exception) { throw wrapException(ex) } @@ -60,7 +60,7 @@ public sealed class Container : ModelEnum { * 'All' variant */ public data class All( - public val valuePredicate: ValuePredicate, + public val queryOutputPredicate: QueryOutputPredicate, ) : Container() { override fun discriminant(): Int = DISCRIMINANT @@ -72,7 +72,7 @@ public sealed class Container : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Container.All = try { All( - ValuePredicate.read(reader), + QueryOutputPredicate.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -82,7 +82,7 @@ public sealed class Container : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.Container.All, ): Unit = try { - ValuePredicate.write(writer, instance.valuePredicate) + QueryOutputPredicate.write(writer, instance.queryOutputPredicate) } catch (ex: Exception) { throw wrapException(ex) } @@ -121,70 +121,6 @@ public sealed class Container : ModelEnum { } } - /** - * 'ValueOfKey' variant - */ - public data class ValueOfKey( - public val valueOfKey: jp.co.soramitsu.iroha2.generated.ValueOfKey, - ) : Container() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Container.ValueOfKey = try { - ValueOfKey( - jp.co.soramitsu.iroha2.generated.ValueOfKey.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Container.ValueOfKey, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.ValueOfKey.write(writer, instance.valueOfKey) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'HasKey' variant - */ - public data class HasKey( - public val name: Name, - ) : Container() { - 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.Container.HasKey = try { - HasKey( - Name.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Container.HasKey, - ): Unit = try { - Name.write(writer, instance.name) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Container = when ( val discriminant = @@ -193,8 +129,6 @@ public sealed class Container : ModelEnum { 0 -> Any.read(reader) 1 -> All.read(reader) 2 -> AtIndex.read(reader) - 3 -> ValueOfKey.read(reader) - 4 -> HasKey.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: Container) { @@ -203,8 +137,6 @@ public sealed class Container : ModelEnum { 0 -> Any.write(writer, instance as Any) 1 -> All.write(writer, instance as All) 2 -> AtIndex.write(writer, instance as AtIndex) - 3 -> ValueOfKey.write(writer, instance as ValueOfKey) - 4 -> HasKey.write(writer, instance as HasKey) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Contains.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Contains.kt deleted file mode 100644 index bfa126bc6..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Contains.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.Unit -import kotlin.collections.List - -/** - * Contains - * - * Generated from 'Contains' regular structure - */ -public data class Contains( - public val collection: EvaluatesTo>, - public val element: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Contains = try { - Contains( - EvaluatesTo.read(reader) as EvaluatesTo>, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Contains): Unit = try { - EvaluatesTo.write(writer, instance.collection) - EvaluatesTo.write(writer, instance.element) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAll.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAll.kt deleted file mode 100644 index 522be3a07..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAll.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.Unit -import kotlin.collections.List - -/** - * ContainsAll - * - * Generated from 'ContainsAll' regular structure - */ -public data class ContainsAll( - public val collection: EvaluatesTo>, - public val elements: EvaluatesTo>, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ContainsAll = try { - ContainsAll( - EvaluatesTo.read(reader) as EvaluatesTo>, - EvaluatesTo.read(reader) as EvaluatesTo>, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: ContainsAll): Unit = try { - EvaluatesTo.write(writer, instance.collection) - EvaluatesTo.write(writer, instance.elements) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAny.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAny.kt deleted file mode 100644 index e9d182743..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ContainsAny.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.Unit -import kotlin.collections.List - -/** - * ContainsAny - * - * Generated from 'ContainsAny' regular structure - */ -public data class ContainsAny( - public val collection: EvaluatesTo>, - public val elements: EvaluatesTo>, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ContainsAny = try { - ContainsAny( - EvaluatesTo.read(reader) as EvaluatesTo>, - EvaluatesTo.read(reader) as EvaluatesTo>, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: ContainsAny): Unit = try { - EvaluatesTo.write(writer, instance.collection) - EvaluatesTo.write(writer, instance.elements) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomInstruction.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomInstruction.kt new file mode 100644 index 000000000..c7cd7b2ce --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomInstruction.kt @@ -0,0 +1,37 @@ +// +// 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.String +import kotlin.Unit + +/** + * CustomInstruction + * + * Generated from 'CustomInstruction' regular structure + */ +public data class CustomInstruction( + public val payload: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CustomInstruction = try { + CustomInstruction( + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CustomInstruction): Unit = try { + writer.writeAsList(instance.payload.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameter.kt new file mode 100644 index 000000000..5d1aed51c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameter.kt @@ -0,0 +1,40 @@ +// +// 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.String +import kotlin.Unit + +/** + * CustomParameter + * + * Generated from 'CustomParameter' regular structure + */ +public data class CustomParameter( + public val id: CustomParameterId, + public val payload: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CustomParameter = try { + CustomParameter( + CustomParameterId.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: CustomParameter): Unit = try { + CustomParameterId.write(writer, instance.id) + writer.writeAsList(instance.payload.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameterId.kt similarity index 61% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterId.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameterId.kt index fa68f71fc..04e99cfda 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/CustomParameterId.kt @@ -11,23 +11,23 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ParameterId + * CustomParameterId * - * Generated from 'ParameterId' regular structure + * Generated from 'CustomParameterId' regular structure */ -public data class ParameterId( +public data class CustomParameterId( public val name: Name, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ParameterId = try { - ParameterId( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): CustomParameterId = try { + CustomParameterId( Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ParameterId): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: CustomParameterId): Unit = try { Name.write(writer, instance.name) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEntityFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEntityFilter.kt deleted file mode 100644 index 03959ada3..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEntityFilter.kt +++ /dev/null @@ -1,277 +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 - -/** - * DataEntityFilter - * - * Generated from 'DataEntityFilter' enum - */ -public sealed class DataEntityFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'ByPeer' variant - */ - public data class ByPeer( - public val filterOptOfPeerFilter: FilterOptOfPeerFilter, - ) : DataEntityFilter() { - 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.DataEntityFilter.ByPeer = try { - ByPeer( - FilterOptOfPeerFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByPeer, - ): Unit = try { - FilterOptOfPeerFilter.write(writer, instance.filterOptOfPeerFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByDomain' variant - */ - public data class ByDomain( - public val filterOptOfDomainFilter: FilterOptOfDomainFilter, - ) : DataEntityFilter() { - 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.DataEntityFilter.ByDomain = try { - ByDomain( - FilterOptOfDomainFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByDomain, - ): Unit = try { - FilterOptOfDomainFilter.write(writer, instance.filterOptOfDomainFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByAccount' variant - */ - public data class ByAccount( - public val filterOptOfAccountFilter: FilterOptOfAccountFilter, - ) : DataEntityFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByAccount = try { - ByAccount( - FilterOptOfAccountFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByAccount, - ): Unit = try { - FilterOptOfAccountFilter.write(writer, instance.filterOptOfAccountFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByAssetDefinition' variant - */ - public data class ByAssetDefinition( - public val filterOptOfAssetDefinitionFilter: FilterOptOfAssetDefinitionFilter, - ) : DataEntityFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByAssetDefinition = try { - ByAssetDefinition( - FilterOptOfAssetDefinitionFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByAssetDefinition, - ): Unit = try { - FilterOptOfAssetDefinitionFilter.write(writer, instance.filterOptOfAssetDefinitionFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByAsset' variant - */ - public data class ByAsset( - public val filterOptOfAssetFilter: FilterOptOfAssetFilter, - ) : DataEntityFilter() { - 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.DataEntityFilter.ByAsset = try { - ByAsset( - FilterOptOfAssetFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByAsset, - ): Unit = try { - FilterOptOfAssetFilter.write(writer, instance.filterOptOfAssetFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByTrigger' variant - */ - public data class ByTrigger( - public val filterOptOfTriggerFilter: FilterOptOfTriggerFilter, - ) : DataEntityFilter() { - 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.DataEntityFilter.ByTrigger = try { - ByTrigger( - FilterOptOfTriggerFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByTrigger, - ): Unit = try { - FilterOptOfTriggerFilter.write(writer, instance.filterOptOfTriggerFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByRole' variant - */ - public data class ByRole( - public val filterOptOfRoleFilter: FilterOptOfRoleFilter, - ) : DataEntityFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByRole = try { - ByRole( - FilterOptOfRoleFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEntityFilter.ByRole, - ): Unit = try { - FilterOptOfRoleFilter.write(writer, instance.filterOptOfRoleFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): DataEntityFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByPeer.read(reader) - 1 -> ByDomain.read(reader) - 2 -> ByAccount.read(reader) - 3 -> ByAssetDefinition.read(reader) - 4 -> ByAsset.read(reader) - 5 -> ByTrigger.read(reader) - 6 -> ByRole.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: DataEntityFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByPeer.write(writer, instance as ByPeer) - 1 -> ByDomain.write(writer, instance as ByDomain) - 2 -> ByAccount.write(writer, instance as ByAccount) - 3 -> ByAssetDefinition.write(writer, instance as ByAssetDefinition) - 4 -> ByAsset.write(writer, instance as ByAsset) - 5 -> ByTrigger.write(writer, instance as ByTrigger) - 6 -> ByRole.write(writer, instance as ByRole) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} 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 b2e516d8c..426dfe055 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 @@ -88,102 +88,6 @@ public sealed class DataEvent : ModelEnum { } } - /** - * 'Account' variant - */ - public data class Account( - public val accountEvent: AccountEvent, - ) : DataEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Account = try { - Account( - AccountEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEvent.Account, - ): Unit = try { - AccountEvent.write(writer, instance.accountEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'AssetDefinition' variant - */ - public data class AssetDefinition( - public val assetDefinitionEvent: AssetDefinitionEvent, - ) : DataEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.AssetDefinition = try { - AssetDefinition( - AssetDefinitionEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEvent.AssetDefinition, - ): Unit = try { - AssetDefinitionEvent.write(writer, instance.assetDefinitionEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Asset' variant - */ - public data class Asset( - public val assetEvent: AssetEvent, - ) : DataEvent() { - 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.DataEvent.Asset = try { - Asset( - AssetEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEvent.Asset, - ): Unit = try { - AssetEvent.write(writer, instance.assetEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Trigger' variant */ @@ -195,7 +99,7 @@ public sealed class DataEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 5 + public const val DISCRIMINANT: Int = 2 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Trigger = try { Trigger( @@ -227,7 +131,7 @@ public sealed class DataEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 6 + public const val DISCRIMINANT: Int = 3 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Role = try { @@ -249,38 +153,6 @@ public sealed class DataEvent : ModelEnum { } } - /** - * 'PermissionToken' variant - */ - public data class PermissionToken( - public val permissionTokenSchemaUpdateEvent: PermissionTokenSchemaUpdateEvent, - ) : DataEvent() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.PermissionToken = try { - PermissionToken( - PermissionTokenSchemaUpdateEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DataEvent.PermissionToken, - ): Unit = try { - PermissionTokenSchemaUpdateEvent.write(writer, instance.permissionTokenSchemaUpdateEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Configuration' variant */ @@ -292,7 +164,7 @@ public sealed class DataEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 8 + public const val DISCRIMINANT: Int = 4 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Configuration = try { Configuration( @@ -324,7 +196,7 @@ public sealed class DataEvent : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 9 + public const val DISCRIMINANT: Int = 5 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEvent.Executor = try { Executor( @@ -352,14 +224,10 @@ public sealed class DataEvent : ModelEnum { ) { 0 -> Peer.read(reader) 1 -> Domain.read(reader) - 2 -> Account.read(reader) - 3 -> AssetDefinition.read(reader) - 4 -> Asset.read(reader) - 5 -> Trigger.read(reader) - 6 -> Role.read(reader) - 7 -> PermissionToken.read(reader) - 8 -> Configuration.read(reader) - 9 -> Executor.read(reader) + 2 -> Trigger.read(reader) + 3 -> Role.read(reader) + 4 -> Configuration.read(reader) + 5 -> Executor.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: DataEvent) { @@ -367,14 +235,10 @@ public sealed class DataEvent : ModelEnum { when (val discriminant = instance.discriminant()) { 0 -> Peer.write(writer, instance as Peer) 1 -> Domain.write(writer, instance as Domain) - 2 -> Account.write(writer, instance as Account) - 3 -> AssetDefinition.write(writer, instance as AssetDefinition) - 4 -> Asset.write(writer, instance as Asset) - 5 -> Trigger.write(writer, instance as Trigger) - 6 -> Role.write(writer, instance as Role) - 7 -> PermissionToken.write(writer, instance as PermissionToken) - 8 -> Configuration.write(writer, instance as Configuration) - 9 -> Executor.write(writer, instance as Executor) + 2 -> Trigger.write(writer, instance as Trigger) + 3 -> Role.write(writer, instance as Role) + 4 -> Configuration.write(writer, instance as Configuration) + 5 -> 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/DataEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEventFilter.kt new file mode 100644 index 000000000..1f7f25451 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DataEventFilter.kt @@ -0,0 +1,390 @@ +// +// 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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * DataEventFilter + * + * Generated from 'DataEventFilter' enum + */ +public sealed class DataEventFilter : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + override fun equals(other: kotlin.Any?): Boolean = when (this) { + is Any -> Any.equals(this, other) + else -> super.equals(other) } + + override fun hashCode(): Int = when (this) { + is Any -> Any.hashCode() + else -> super.hashCode() } + + /** + * 'Any' variant + */ + public class Any : DataEventFilter() { + 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.DataEventFilter.Any = try { + Any() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Any, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: jp.co.soramitsu.iroha2.generated.DataEventFilter.Any, o2: kotlin.Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".DataEventFilter.Any".hashCode() + } + } + + /** + * 'Peer' variant + */ + public data class Peer( + public val peerEventFilter: PeerEventFilter, + ) : DataEventFilter() { + 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.DataEventFilter.Peer = try { + Peer( + PeerEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Peer, + ): Unit = try { + PeerEventFilter.write(writer, instance.peerEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Domain' variant + */ + public data class Domain( + public val domainEventFilter: DomainEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Domain = try { + Domain( + DomainEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Domain, + ): Unit = try { + DomainEventFilter.write(writer, instance.domainEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Account' variant + */ + public data class Account( + public val accountEventFilter: AccountEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Account = try { + Account( + AccountEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Account, + ): Unit = try { + AccountEventFilter.write(writer, instance.accountEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val assetEventFilter: AssetEventFilter, + ) : DataEventFilter() { + 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.DataEventFilter.Asset = try { + Asset( + AssetEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Asset, + ): Unit = try { + AssetEventFilter.write(writer, instance.assetEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val assetDefinitionEventFilter: AssetDefinitionEventFilter, + ) : DataEventFilter() { + 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.DataEventFilter.AssetDefinition = try { + AssetDefinition( + AssetDefinitionEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.AssetDefinition, + ): Unit = try { + AssetDefinitionEventFilter.write(writer, instance.assetDefinitionEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val triggerEventFilter: TriggerEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Trigger = try { + Trigger( + TriggerEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Trigger, + ): Unit = try { + TriggerEventFilter.write(writer, instance.triggerEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Role' variant + */ + public data class Role( + public val roleEventFilter: RoleEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 7 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Role = try { + Role( + RoleEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Role, + ): Unit = try { + RoleEventFilter.write(writer, instance.roleEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Configuration' variant + */ + public data class Configuration( + public val configurationEventFilter: ConfigurationEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 8 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Configuration = try { + Configuration( + ConfigurationEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Configuration, + ): Unit = try { + ConfigurationEventFilter.write(writer, instance.configurationEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Executor' variant + */ + public data class Executor( + public val executorEventFilter: ExecutorEventFilter, + ) : DataEventFilter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 9 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DataEventFilter.Executor = try { + Executor( + ExecutorEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DataEventFilter.Executor, + ): Unit = try { + ExecutorEventFilter.write(writer, instance.executorEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): DataEventFilter = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Any.read(reader) + 1 -> Peer.read(reader) + 2 -> Domain.read(reader) + 3 -> Account.read(reader) + 4 -> Asset.read(reader) + 5 -> AssetDefinition.read(reader) + 6 -> Trigger.read(reader) + 7 -> Role.read(reader) + 8 -> Configuration.read(reader) + 9 -> Executor.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: DataEventFilter) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Any.write(writer, instance as Any) + 1 -> Peer.write(writer, instance as Peer) + 2 -> Domain.write(writer, instance as Domain) + 3 -> Account.write(writer, instance as Account) + 4 -> Asset.write(writer, instance as Asset) + 5 -> AssetDefinition.write(writer, instance as AssetDefinition) + 6 -> Trigger.write(writer, instance as Trigger) + 7 -> Role.write(writer, instance as Role) + 8 -> Configuration.write(writer, instance as Configuration) + 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/Divide.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Divide.kt deleted file mode 100644 index 3f51210ef..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Divide.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 - -/** - * Divide - * - * Generated from 'Divide' regular structure - */ -public data class Divide( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Divide = try { - Divide( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Divide): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Domain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Domain.kt index 382a4a45d..98d99c95d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Domain.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Domain.kt @@ -7,10 +7,8 @@ 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.comparator import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit -import kotlin.collections.Map /** * Domain @@ -19,9 +17,6 @@ import kotlin.collections.Map */ public data class Domain( public val id: DomainId, - public val accounts: Map, - public val assetDefinitions: Map, - public val assetTotalQuantities: Map, public val logo: IpfsPath? = null, public val metadata: Metadata, public val ownedBy: AccountId, @@ -30,17 +25,6 @@ public data class Domain( override fun read(reader: ScaleCodecReader): Domain = try { Domain( DomainId.read(reader), - reader.readMap(reader.readCompactInt(), { AccountId.read(reader) }, { Account.read(reader) }), - reader.readMap( - reader.readCompactInt(), - { AssetDefinitionId.read(reader) }, - { AssetDefinition.read(reader) }, - ), - reader.readMap( - reader.readCompactInt(), - { AssetDefinitionId.read(reader) }, - { NumericValue.read(reader) }, - ), reader.readNullable(IpfsPath) as IpfsPath?, Metadata.read(reader), AccountId.read(reader), @@ -51,27 +35,6 @@ public data class Domain( override fun write(writer: ScaleCodecWriter, instance: Domain): Unit = try { DomainId.write(writer, instance.id) - writer.writeCompact(instance.accounts.size) - instance.accounts.toSortedMap( - AccountId.comparator(), - ).forEach { (key, value) -> - AccountId.write(writer, key) - Account.write(writer, value) - } - writer.writeCompact(instance.assetDefinitions.size) - instance.assetDefinitions.toSortedMap( - AssetDefinitionId.comparator(), - ).forEach { (key, value) -> - AssetDefinitionId.write(writer, key) - AssetDefinition.write(writer, value) - } - writer.writeCompact(instance.assetTotalQuantities.size) - instance.assetTotalQuantities.toSortedMap( - AssetDefinitionId.comparator(), - ).forEach { (key, value) -> - AssetDefinitionId.write(writer, key) - NumericValue.write(writer, value) - } writer.writeNullable(IpfsPath, instance.logo) Metadata.write(writer, instance.metadata) AccountId.write(writer, instance.ownedBy) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEvent.kt index 86c3699bd..501d0a135 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEvent.kt @@ -24,21 +24,21 @@ public sealed class DomainEvent : ModelEnum { public abstract fun discriminant(): Int /** - * 'Account' variant + * 'Created' variant */ - public data class Account( - public val accountEvent: AccountEvent, + public data class Created( + public val domain: Domain, ) : DomainEvent() { 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.DomainEvent.Account = try { - Account( - AccountEvent.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEvent.Created = try { + Created( + Domain.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class DomainEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Account, + instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Created, ): Unit = try { - AccountEvent.write(writer, instance.accountEvent) + Domain.write(writer, instance.domain) } catch (ex: Exception) { throw wrapException(ex) } @@ -56,21 +56,21 @@ public sealed class DomainEvent : ModelEnum { } /** - * 'AssetDefinition' variant + * 'Deleted' variant */ - public data class AssetDefinition( - public val assetDefinitionEvent: AssetDefinitionEvent, + public data class Deleted( + public val domainId: DomainId, ) : DomainEvent() { 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.DomainEvent.AssetDefinition = try { - AssetDefinition( - AssetDefinitionEvent.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEvent.Deleted = try { + Deleted( + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,9 +78,9 @@ public sealed class DomainEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEvent.AssetDefinition, + instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Deleted, ): Unit = try { - AssetDefinitionEvent.write(writer, instance.assetDefinitionEvent) + DomainId.write(writer, instance.domainId) } catch (ex: Exception) { throw wrapException(ex) } @@ -88,21 +88,21 @@ public sealed class DomainEvent : ModelEnum { } /** - * 'Created' variant + * 'AssetDefinition' variant */ - public data class Created( - public val domain: Domain, + public data class AssetDefinition( + public val assetDefinitionEvent: AssetDefinitionEvent, ) : DomainEvent() { 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.DomainEvent.Created = try { - Created( - Domain.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEvent.AssetDefinition = try { + AssetDefinition( + AssetDefinitionEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -110,9 +110,9 @@ public sealed class DomainEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Created, + instance: jp.co.soramitsu.iroha2.generated.DomainEvent.AssetDefinition, ): Unit = try { - Domain.write(writer, instance.domain) + AssetDefinitionEvent.write(writer, instance.assetDefinitionEvent) } catch (ex: Exception) { throw wrapException(ex) } @@ -120,21 +120,21 @@ public sealed class DomainEvent : ModelEnum { } /** - * 'Deleted' variant + * 'Account' variant */ - public data class Deleted( - public val domainId: DomainId, + public data class Account( + public val accountEvent: AccountEvent, ) : DomainEvent() { 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.DomainEvent.Deleted = try { - Deleted( - DomainId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEvent.Account = try { + Account( + AccountEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -142,9 +142,9 @@ public sealed class DomainEvent : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Deleted, + instance: jp.co.soramitsu.iroha2.generated.DomainEvent.Account, ): Unit = try { - DomainId.write(writer, instance.domainId) + AccountEvent.write(writer, instance.accountEvent) } catch (ex: Exception) { throw wrapException(ex) } @@ -252,10 +252,10 @@ public sealed class DomainEvent : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Account.read(reader) - 1 -> AssetDefinition.read(reader) - 2 -> Created.read(reader) - 3 -> Deleted.read(reader) + 0 -> Created.read(reader) + 1 -> Deleted.read(reader) + 2 -> AssetDefinition.read(reader) + 3 -> Account.read(reader) 4 -> MetadataInserted.read(reader) 5 -> MetadataRemoved.read(reader) 6 -> OwnerChanged.read(reader) @@ -264,10 +264,10 @@ public sealed class DomainEvent : ModelEnum { override fun write(writer: ScaleCodecWriter, instance: DomainEvent) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Account.write(writer, instance as Account) - 1 -> AssetDefinition.write(writer, instance as AssetDefinition) - 2 -> Created.write(writer, instance as Created) - 3 -> Deleted.write(writer, instance as Deleted) + 0 -> Created.write(writer, instance as Created) + 1 -> Deleted.write(writer, instance as Deleted) + 2 -> AssetDefinition.write(writer, instance as AssetDefinition) + 3 -> Account.write(writer, instance as Account) 4 -> MetadataInserted.write(writer, instance as MetadataInserted) 5 -> MetadataRemoved.write(writer, instance as MetadataRemoved) 6 -> OwnerChanged.write(writer, instance as OwnerChanged) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEventFilter.kt index 1b745d46d..4e3aac02d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainEventFilter.kt @@ -3,315 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * DomainEventFilter * - * Generated from 'DomainEventFilter' enum + * Generated from 'DomainEventFilter' regular structure */ -public sealed class DomainEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByMetadataInserted -> ByMetadataInserted.equals(this, other) - is ByMetadataRemoved -> ByMetadataRemoved.equals(this, other) - is ByOwnerChanged -> ByOwnerChanged.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByMetadataInserted -> ByMetadataInserted.hashCode() - is ByMetadataRemoved -> ByMetadataRemoved.hashCode() - is ByOwnerChanged -> ByOwnerChanged.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : DomainEventFilter() { - 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.DomainEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByCreated, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByCreated, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".DomainEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : DomainEventFilter() { - 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.DomainEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByDeleted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByDeleted, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".DomainEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByMetadataInserted' variant - */ - public class ByMetadataInserted : DomainEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataInserted = try { - ByMetadataInserted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataInserted, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataInserted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".DomainEventFilter.ByMetadataInserted".hashCode() - } - } - - /** - * 'ByMetadataRemoved' variant - */ - public class ByMetadataRemoved : DomainEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataRemoved = try { - ByMetadataRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataRemoved, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByMetadataRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".DomainEventFilter.ByMetadataRemoved".hashCode() - } - } - - /** - * 'ByOwnerChanged' variant - */ - public class ByOwnerChanged : DomainEventFilter() { - 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.DomainEventFilter.ByOwnerChanged = try { - ByOwnerChanged() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByOwnerChanged, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByOwnerChanged, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".DomainEventFilter.ByOwnerChanged".hashCode() - } - } - - /** - * 'ByAccount' variant - */ - public data class ByAccount( - public val filterOptOfAccountFilter: FilterOptOfAccountFilter, - ) : DomainEventFilter() { - 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.DomainEventFilter.ByAccount = try { - ByAccount( - FilterOptOfAccountFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByAccount, - ): Unit = try { - FilterOptOfAccountFilter.write(writer, instance.filterOptOfAccountFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ByAssetDefinition' variant - */ - public data class ByAssetDefinition( - public val filterOptOfAssetDefinitionFilter: FilterOptOfAssetDefinitionFilter, - ) : DomainEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByAssetDefinition = try { - ByAssetDefinition( - FilterOptOfAssetDefinitionFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.DomainEventFilter.ByAssetDefinition, - ): Unit = - try { - FilterOptOfAssetDefinitionFilter.write(writer, instance.filterOptOfAssetDefinitionFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - +public data class DomainEventFilter( + public val idMatcher: DomainId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): DomainEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByDeleted.read(reader) - 2 -> ByMetadataInserted.read(reader) - 3 -> ByMetadataRemoved.read(reader) - 4 -> ByOwnerChanged.read(reader) - 5 -> ByAccount.read(reader) - 6 -> ByAssetDefinition.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: DomainEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByDeleted.write(writer, instance as ByDeleted) - 2 -> ByMetadataInserted.write(writer, instance as ByMetadataInserted) - 3 -> ByMetadataRemoved.write(writer, instance as ByMetadataRemoved) - 4 -> ByOwnerChanged.write(writer, instance as ByOwnerChanged) - 5 -> ByAccount.write(writer, instance as ByAccount) - 6 -> ByAssetDefinition.write(writer, instance as ByAssetDefinition) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): DomainEventFilter = try { + DomainEventFilter( + reader.readNullable(DomainId) as DomainId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: DomainEventFilter): Unit = try { + writer.writeNullable(DomainId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainFilter.kt deleted file mode 100644 index 7ff1756fc..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainFilter.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 - -/** - * DomainFilter - * - * Generated from 'DomainFilter' regular structure - */ -public data class DomainFilter( - public val originFilter: FilterOptOfOriginFilterOfDomainEvent, - public val eventFilter: FilterOptOfDomainEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): DomainFilter = try { - DomainFilter( - FilterOptOfOriginFilterOfDomainEvent.read(reader), - FilterOptOfDomainEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: DomainFilter): Unit = try { - FilterOptOfOriginFilterOfDomainEvent.write(writer, instance.originFilter) - FilterOptOfDomainEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainIdPredicateBox.kt new file mode 100644 index 000000000..c0ddd21c5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainIdPredicateBox.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * DomainIdPredicateBox + * + * Generated from 'DomainIdPredicateBox' enum + */ +public sealed class DomainIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val domainId: DomainId, + ) : DomainIdPredicateBox() { + 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.DomainIdPredicateBox.Equals = try { + Equals( + DomainId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DomainIdPredicateBox.Equals, + ): Unit = try { + DomainId.write(writer, instance.domainId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Name' variant + */ + public data class Name( + public val stringPredicateBox: StringPredicateBox, + ) : DomainIdPredicateBox() { + 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.DomainIdPredicateBox.Name = try { + Name( + StringPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DomainIdPredicateBox.Name, + ): Unit = try { + StringPredicateBox.write(writer, instance.stringPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): DomainIdPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + 1 -> Name.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: DomainIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + 1 -> Name.write(writer, instance as Name) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainOwnerChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainOwnerChanged.kt index c8fb87683..c2d2afa71 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainOwnerChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainOwnerChanged.kt @@ -16,7 +16,7 @@ import kotlin.Unit * Generated from 'DomainOwnerChanged' regular structure */ public data class DomainOwnerChanged( - public val domainId: DomainId, + public val domain: DomainId, public val newOwner: AccountId, ) { public companion object : ScaleReader, ScaleWriter { @@ -30,7 +30,7 @@ public data class DomainOwnerChanged( } override fun write(writer: ScaleCodecWriter, instance: DomainOwnerChanged): Unit = try { - DomainId.write(writer, instance.domainId) + DomainId.write(writer, instance.domain) AccountId.write(writer, instance.newOwner) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainPredicateBox.kt new file mode 100644 index 000000000..05141a1ba --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/DomainPredicateBox.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * DomainPredicateBox + * + * Generated from 'DomainPredicateBox' enum + */ +public sealed class DomainPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val domainIdPredicateBox: DomainIdPredicateBox, + ) : DomainPredicateBox() { + 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.DomainPredicateBox.Id = try { + Id( + DomainIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DomainPredicateBox.Id, + ): Unit = try { + DomainIdPredicateBox.write(writer, instance.domainIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Metadata' variant + */ + public data class Metadata( + public val metadataPredicateBox: MetadataPredicateBox, + ) : DomainPredicateBox() { + 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.DomainPredicateBox.Metadata = try { + Metadata( + MetadataPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.DomainPredicateBox.Metadata, + ): Unit = try { + MetadataPredicateBox.write(writer, instance.metadataPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): DomainPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + 1 -> Metadata.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: DomainPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + 1 -> Metadata.write(writer, instance as Metadata) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Event.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventBox.kt similarity index 66% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Event.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventBox.kt index 1fccc880b..4f24e6a5f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Event.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventBox.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * Event + * EventBox * - * Generated from 'Event' enum + * Generated from 'EventBox' enum */ -public sealed class Event : ModelEnum { +public sealed class EventBox : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,29 +27,28 @@ public sealed class Event : ModelEnum { * 'Pipeline' variant */ public data class Pipeline( - public val pipelineEvent: PipelineEvent, - ) : Event() { + public val pipelineEventBox: PipelineEventBox, + ) : EventBox() { 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.Event.Pipeline = - try { - Pipeline( - PipelineEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventBox.Pipeline = try { + Pipeline( + PipelineEventBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Event.Pipeline, + instance: jp.co.soramitsu.iroha2.generated.EventBox.Pipeline, ): Unit = try { - PipelineEvent.write(writer, instance.pipelineEvent) + PipelineEventBox.write(writer, instance.pipelineEventBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -61,25 +60,26 @@ public sealed class Event : ModelEnum { */ public data class Data( public val dataEvent: DataEvent, - ) : Event() { + ) : EventBox() { 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.Event.Data = try { - Data( - DataEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventBox.Data = + try { + Data( + DataEvent.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Event.Data, + instance: jp.co.soramitsu.iroha2.generated.EventBox.Data, ): Unit = try { DataEvent.write(writer, instance.dataEvent) } catch (ex: Exception) { @@ -93,25 +93,26 @@ public sealed class Event : ModelEnum { */ public data class Time( public val timeEvent: TimeEvent, - ) : Event() { + ) : EventBox() { 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.Event.Time = try { - Time( - TimeEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventBox.Time = + try { + Time( + TimeEvent.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Event.Time, + instance: jp.co.soramitsu.iroha2.generated.EventBox.Time, ): Unit = try { TimeEvent.write(writer, instance.timeEvent) } catch (ex: Exception) { @@ -125,15 +126,15 @@ public sealed class Event : ModelEnum { */ public data class ExecuteTrigger( public val executeTriggerEvent: ExecuteTriggerEvent, - ) : Event() { + ) : EventBox() { 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.Event.ExecuteTrigger = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventBox.ExecuteTrigger = try { ExecuteTrigger( ExecuteTriggerEvent.read(reader), ) @@ -143,7 +144,7 @@ public sealed class Event : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Event.ExecuteTrigger, + instance: jp.co.soramitsu.iroha2.generated.EventBox.ExecuteTrigger, ): Unit = try { ExecuteTriggerEvent.write(writer, instance.executeTriggerEvent) } catch (ex: Exception) { @@ -153,21 +154,21 @@ public sealed class Event : ModelEnum { } /** - * 'Notification' variant + * 'TriggerCompleted' variant */ - public data class Notification( - public val notificationEvent: NotificationEvent, - ) : Event() { + public data class TriggerCompleted( + public val triggerCompletedEvent: TriggerCompletedEvent, + ) : EventBox() { 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.Event.Notification = try { - Notification( - NotificationEvent.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventBox.TriggerCompleted = try { + TriggerCompleted( + TriggerCompletedEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -175,32 +176,35 @@ public sealed class Event : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Event.Notification, + instance: jp.co.soramitsu.iroha2.generated.EventBox.TriggerCompleted, ): Unit = try { - NotificationEvent.write(writer, instance.notificationEvent) + TriggerCompletedEvent.write(writer, instance.triggerCompletedEvent) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Event = when (val discriminant = reader.readUByte()) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): EventBox = when ( + val discriminant = + reader.readUByte() + ) { 0 -> Pipeline.read(reader) 1 -> Data.read(reader) 2 -> Time.read(reader) 3 -> ExecuteTrigger.read(reader) - 4 -> Notification.read(reader) + 4 -> TriggerCompleted.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: Event) { + override fun write(writer: ScaleCodecWriter, instance: EventBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Pipeline.write(writer, instance as Pipeline) 1 -> Data.write(writer, instance as Data) 2 -> Time.write(writer, instance as Time) 3 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) - 4 -> Notification.write(writer, instance as Notification) + 4 -> TriggerCompleted.write(writer, instance as TriggerCompleted) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventFilterBox.kt similarity index 58% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventFilterBox.kt index 26c98678b..0f0eebbb7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventFilterBox.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * FilterBox + * EventFilterBox * - * Generated from 'FilterBox' enum + * Generated from 'EventFilterBox' enum */ -public sealed class FilterBox : ModelEnum { +public sealed class EventFilterBox : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,18 +27,18 @@ public sealed class FilterBox : ModelEnum { * 'Pipeline' variant */ public data class Pipeline( - public val pipelineEventFilter: PipelineEventFilter, - ) : FilterBox() { + public val pipelineEventFilterBox: PipelineEventFilterBox, + ) : EventFilterBox() { 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.FilterBox.Pipeline = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventFilterBox.Pipeline = try { Pipeline( - PipelineEventFilter.read(reader), + PipelineEventFilterBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class FilterBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterBox.Pipeline, + instance: jp.co.soramitsu.iroha2.generated.EventFilterBox.Pipeline, ): Unit = try { - PipelineEventFilter.write(writer, instance.pipelineEventFilter) + PipelineEventFilterBox.write(writer, instance.pipelineEventFilterBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -59,29 +59,28 @@ public sealed class FilterBox : ModelEnum { * 'Data' variant */ public data class Data( - public val filterOptOfDataEntityFilter: FilterOptOfDataEntityFilter, - ) : FilterBox() { + public val dataEventFilter: DataEventFilter, + ) : EventFilterBox() { 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.FilterBox.Data = - try { - Data( - FilterOptOfDataEntityFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventFilterBox.Data = try { + Data( + DataEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterBox.Data, + instance: jp.co.soramitsu.iroha2.generated.EventFilterBox.Data, ): Unit = try { - FilterOptOfDataEntityFilter.write(writer, instance.filterOptOfDataEntityFilter) + DataEventFilter.write(writer, instance.dataEventFilter) } catch (ex: Exception) { throw wrapException(ex) } @@ -93,26 +92,25 @@ public sealed class FilterBox : ModelEnum { */ public data class Time( public val timeEventFilter: TimeEventFilter, - ) : FilterBox() { + ) : EventFilterBox() { 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.FilterBox.Time = - try { - Time( - TimeEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventFilterBox.Time = try { + Time( + TimeEventFilter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterBox.Time, + instance: jp.co.soramitsu.iroha2.generated.EventFilterBox.Time, ): Unit = try { TimeEventFilter.write(writer, instance.timeEventFilter) } catch (ex: Exception) { @@ -126,15 +124,15 @@ public sealed class FilterBox : ModelEnum { */ public data class ExecuteTrigger( public val executeTriggerEventFilter: ExecuteTriggerEventFilter, - ) : FilterBox() { + ) : EventFilterBox() { 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.FilterBox.ExecuteTrigger = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventFilterBox.ExecuteTrigger = try { ExecuteTrigger( ExecuteTriggerEventFilter.read(reader), ) @@ -144,7 +142,7 @@ public sealed class FilterBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterBox.ExecuteTrigger, + instance: jp.co.soramitsu.iroha2.generated.EventFilterBox.ExecuteTrigger, ): Unit = try { ExecuteTriggerEventFilter.write(writer, instance.executeTriggerEventFilter) } catch (ex: Exception) { @@ -154,21 +152,21 @@ public sealed class FilterBox : ModelEnum { } /** - * 'Notification' variant + * 'TriggerCompleted' variant */ - public data class Notification( - public val notificationEventFilter: NotificationEventFilter, - ) : FilterBox() { + public data class TriggerCompleted( + public val triggerCompletedEventFilter: TriggerCompletedEventFilter, + ) : EventFilterBox() { 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.FilterBox.Notification = try { - Notification( - NotificationEventFilter.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.EventFilterBox.TriggerCompleted = try { + TriggerCompleted( + TriggerCompletedEventFilter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -176,17 +174,17 @@ public sealed class FilterBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterBox.Notification, + instance: jp.co.soramitsu.iroha2.generated.EventFilterBox.TriggerCompleted, ): Unit = try { - NotificationEventFilter.write(writer, instance.notificationEventFilter) + TriggerCompletedEventFilter.write(writer, instance.triggerCompletedEventFilter) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterBox = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): EventFilterBox = when ( val discriminant = reader.readUByte() ) { @@ -194,17 +192,17 @@ public sealed class FilterBox : ModelEnum { 1 -> Data.read(reader) 2 -> Time.read(reader) 3 -> ExecuteTrigger.read(reader) - 4 -> Notification.read(reader) + 4 -> TriggerCompleted.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: FilterBox) { + override fun write(writer: ScaleCodecWriter, instance: EventFilterBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Pipeline.write(writer, instance as Pipeline) 1 -> Data.write(writer, instance as Data) 2 -> Time.write(writer, instance as Time) 3 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) - 4 -> Notification.write(writer, instance as Notification) + 4 -> TriggerCompleted.write(writer, instance as TriggerCompleted) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventMessage.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventMessage.kt index d5f5f3557..242f01359 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventMessage.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventMessage.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'EventMessage' regular structure */ public data class EventMessage( - public val event: Event, + public val eventBox: EventBox, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): EventMessage = try { EventMessage( - Event.read(reader), + EventBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: EventMessage): Unit = try { - Event.write(writer, instance.event) + EventBox.write(writer, instance.eventBox) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventSubscriptionRequest.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventSubscriptionRequest.kt index 1b3069e42..2f1050cbb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventSubscriptionRequest.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EventSubscriptionRequest.kt @@ -9,6 +9,7 @@ import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit +import kotlin.collections.List /** * EventSubscriptionRequest @@ -16,21 +17,24 @@ import kotlin.Unit * Generated from 'EventSubscriptionRequest' regular structure */ public data class EventSubscriptionRequest( - public val filterBox: FilterBox, + public val vecOfEventFilterBox: List, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): EventSubscriptionRequest = try { EventSubscriptionRequest( - FilterBox.read(reader), + reader.readVec(reader.readCompactInt()) { EventFilterBox.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: EventSubscriptionRequest): Unit = try { - FilterBox.write(writer, instance.filterBox) + writer.writeCompact(instance.vecOfEventFilterBox.size) + instance.vecOfEventFilterBox.forEach { value -> + EventFilterBox.write(writer, value) + } } 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 53d947639..db40f7a1f 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()) { InstructionExpr.read(reader) }, + reader.readVec(reader.readCompactInt()) { InstructionBox.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 -> - InstructionExpr.write(writer, value) + InstructionBox.write(writer, value) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTrigger.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTrigger.kt index ee9a688c8..a82b9d03d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTrigger.kt @@ -8,27 +8,31 @@ 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.String import kotlin.Unit /** - * ExecuteTriggerExpr + * ExecuteTrigger * - * Generated from 'ExecuteTriggerExpr' regular structure + * Generated from 'ExecuteTrigger' regular structure */ -public data class ExecuteTriggerExpr( - public val triggerId: EvaluatesTo, +public data class ExecuteTrigger( + public val trigger: TriggerId, + public val args: String? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ExecuteTriggerExpr = try { - ExecuteTriggerExpr( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecuteTrigger = try { + ExecuteTrigger( + TriggerId.read(reader), + reader.readNullable(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ExecuteTriggerExpr): Unit = try { - EvaluatesTo.write(writer, instance.triggerId) + override fun write(writer: ScaleCodecWriter, instance: ExecuteTrigger): Unit = try { + TriggerId.write(writer, instance.trigger) + writer.writeNullable(instance.args) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEvent.kt index 6998626ee..bacfbf0ab 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEvent.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -18,12 +19,14 @@ import kotlin.Unit public data class ExecuteTriggerEvent( public val triggerId: TriggerId, public val authority: AccountId, + public val args: String? = null, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): ExecuteTriggerEvent = try { ExecuteTriggerEvent( TriggerId.read(reader), AccountId.read(reader), + reader.readNullable(), ) } catch (ex: Exception) { throw wrapException(ex) @@ -32,6 +35,7 @@ public data class ExecuteTriggerEvent( override fun write(writer: ScaleCodecWriter, instance: ExecuteTriggerEvent): Unit = try { TriggerId.write(writer, instance.triggerId) AccountId.write(writer, instance.authority) + writer.writeNullable(instance.args) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEventFilter.kt index 569250eb7..0f0e6881d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecuteTriggerEventFilter.kt @@ -16,24 +16,24 @@ import kotlin.Unit * Generated from 'ExecuteTriggerEventFilter' regular structure */ public data class ExecuteTriggerEventFilter( - public val triggerId: TriggerId, - public val authority: AccountId, + public val triggerId: TriggerId? = null, + public val authority: AccountId? = null, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): ExecuteTriggerEventFilter = try { ExecuteTriggerEventFilter( - TriggerId.read(reader), - AccountId.read(reader), + reader.readNullable(TriggerId) as TriggerId?, + reader.readNullable(AccountId) as AccountId?, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: ExecuteTriggerEventFilter): Unit = try { - TriggerId.write(writer, instance.triggerId) - AccountId.write(writer, instance.authority) + writer.writeNullable(TriggerId, instance.triggerId) + writer.writeNullable(AccountId, instance.authority) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorDataModel.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorDataModel.kt new file mode 100644 index 000000000..d0dc37429 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorDataModel.kt @@ -0,0 +1,69 @@ +// +// 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.comparator +import jp.co.soramitsu.iroha2.wrapException +import kotlin.String +import kotlin.Unit +import kotlin.collections.List +import kotlin.collections.Map + +/** + * ExecutorDataModel + * + * Generated from 'ExecutorDataModel' regular structure + */ +public data class ExecutorDataModel( + public val parameters: Map, + public val instructions: List, + public val permissions: List, + public val schema: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecutorDataModel = try { + ExecutorDataModel( + reader.readMap( + reader.readCompactInt(), + { CustomParameterId.read(reader) }, + { CustomParameter.read(reader) }, + ), + reader.readVec(reader.readCompactInt()) { reader.readString() }, + reader.readVec(reader.readCompactInt()) { reader.readString() }, + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: ExecutorDataModel): Unit = try { + writer.writeCompact(instance.parameters.size) + instance.parameters.toSortedMap( + CustomParameterId.comparator(), + ).forEach { (key, value) -> + CustomParameterId.write(writer, key) + CustomParameter.write(writer, value) + } + writer.writeCompact(instance.instructions.size) + instance.instructions.sortedWith( + String.comparator(), + ).forEach { value -> + writer.writeAsList(value.toByteArray(Charsets.UTF_8)) + } + writer.writeCompact(instance.permissions.size) + instance.permissions.sortedWith( + String.comparator(), + ).forEach { value -> + writer.writeAsList(value.toByteArray(Charsets.UTF_8)) + } + writer.writeAsList(instance.schema.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt index 101b8d67a..e7fb9bd45 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEvent.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.Unit @@ -25,18 +23,12 @@ public sealed class ExecutorEvent : ModelEnum { */ public abstract fun discriminant(): Int - override fun equals(other: Any?): Boolean = when (this) { - is Upgraded -> Upgraded.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Upgraded -> Upgraded.hashCode() - else -> super.hashCode() } - /** * 'Upgraded' variant */ - public class Upgraded : ExecutorEvent() { + public data class Upgraded( + public val executorUpgrade: ExecutorUpgrade, + ) : ExecutorEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -45,7 +37,9 @@ public sealed class ExecutorEvent : ModelEnum { public const val DISCRIMINANT: Int = 0 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ExecutorEvent.Upgraded = try { - Upgraded() + Upgraded( + ExecutorUpgrade.read(reader), + ) } catch (ex: Exception) { throw wrapException(ex) } @@ -54,16 +48,10 @@ public sealed class ExecutorEvent : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.ExecutorEvent.Upgraded, ): Unit = try { + ExecutorUpgrade.write(writer, instance.executorUpgrade) } catch (ex: Exception) { throw wrapException(ex) } - - 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 = ".ExecutorEvent.Upgraded".hashCode() } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluatesTo.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEventFilter.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluatesTo.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEventFilter.kt index 9449c69f4..0f92ede73 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluatesTo.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorEventFilter.kt @@ -8,28 +8,28 @@ 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.Long import kotlin.Unit /** - * EvaluatesTo + * ExecutorEventFilter * - * Generated from 'EvaluatesTo' regular structure + * Generated from 'ExecutorEventFilter' regular structure */ -public data class EvaluatesTo( - public val expression: Expression, +public data class ExecutorEventFilter( + public val eventSet: Long, ) { - public companion object : ScaleReader>, ScaleWriter> { - override fun read(reader: ScaleCodecReader): EvaluatesTo = try { - EvaluatesTo( - Expression.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecutorEventFilter = try { + ExecutorEventFilter( + reader.readUint32(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: EvaluatesTo): Unit = try { - Expression.write(writer, instance.expression) + override fun write(writer: ScaleCodecWriter, instance: ExecutorEventFilter): Unit = try { + writer.writeUint32(instance.eventSet) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Equal.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorUpgrade.kt similarity index 51% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Equal.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorUpgrade.kt index a080e4937..5e08b9b56 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Equal.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorUpgrade.kt @@ -11,27 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * Equal + * ExecutorUpgrade * - * Generated from 'Equal' regular structure + * Generated from 'ExecutorUpgrade' regular structure */ -public data class Equal( - public val left: EvaluatesTo, - public val right: EvaluatesTo, +public data class ExecutorUpgrade( + public val newDataModel: ExecutorDataModel, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Equal = try { - Equal( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ExecutorUpgrade = try { + ExecutorUpgrade( + ExecutorDataModel.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Equal): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) + override fun write(writer: ScaleCodecWriter, instance: ExecutorUpgrade): Unit = try { + ExecutorDataModel.write(writer, instance.newDataModel) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Expression.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Expression.kt deleted file mode 100644 index b1f5d7419..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Expression.kt +++ /dev/null @@ -1,726 +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 - -/** - * Expression - * - * Generated from 'Expression' enum - */ -public sealed class Expression : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'Add' variant - */ - public data class Add( - public val add: jp.co.soramitsu.iroha2.generated.Add, - ) : Expression() { - 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.Expression.Add = - try { - Add( - jp.co.soramitsu.iroha2.generated.Add.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Add, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Add.write(writer, instance.add) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Subtract' variant - */ - public data class Subtract( - public val subtract: jp.co.soramitsu.iroha2.generated.Subtract, - ) : Expression() { - 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.Expression.Subtract = try { - Subtract( - jp.co.soramitsu.iroha2.generated.Subtract.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Subtract, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Subtract.write(writer, instance.subtract) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Multiply' variant - */ - public data class Multiply( - public val multiply: jp.co.soramitsu.iroha2.generated.Multiply, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Multiply = try { - Multiply( - jp.co.soramitsu.iroha2.generated.Multiply.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Multiply, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Multiply.write(writer, instance.multiply) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Divide' variant - */ - public data class Divide( - public val divide: jp.co.soramitsu.iroha2.generated.Divide, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Divide = try { - Divide( - jp.co.soramitsu.iroha2.generated.Divide.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Divide, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Divide.write(writer, instance.divide) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Mod' variant - */ - public data class Mod( - public val mod: jp.co.soramitsu.iroha2.generated.Mod, - ) : Expression() { - 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.Expression.Mod = - try { - Mod( - jp.co.soramitsu.iroha2.generated.Mod.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Mod, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Mod.write(writer, instance.mod) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'RaiseTo' variant - */ - public data class RaiseTo( - public val raiseTo: jp.co.soramitsu.iroha2.generated.RaiseTo, - ) : Expression() { - 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.Expression.RaiseTo = try { - RaiseTo( - jp.co.soramitsu.iroha2.generated.RaiseTo.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.RaiseTo, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.RaiseTo.write(writer, instance.raiseTo) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Greater' variant - */ - public data class Greater( - public val greater: jp.co.soramitsu.iroha2.generated.Greater, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Greater = try { - Greater( - jp.co.soramitsu.iroha2.generated.Greater.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Greater, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Greater.write(writer, instance.greater) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Less' variant - */ - public data class Less( - public val less: jp.co.soramitsu.iroha2.generated.Less, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Less = try { - Less( - jp.co.soramitsu.iroha2.generated.Less.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Less, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Less.write(writer, instance.less) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Equal' variant - */ - public data class Equal( - public val equal: jp.co.soramitsu.iroha2.generated.Equal, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Equal = try { - Equal( - jp.co.soramitsu.iroha2.generated.Equal.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Equal, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Equal.write(writer, instance.equal) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Not' variant - */ - public data class Not( - public val not: jp.co.soramitsu.iroha2.generated.Not, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 9 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Not = - try { - Not( - jp.co.soramitsu.iroha2.generated.Not.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Not, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Not.write(writer, instance.not) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'And' variant - */ - public data class And( - public val and: jp.co.soramitsu.iroha2.generated.And, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 10 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.And = - try { - And( - jp.co.soramitsu.iroha2.generated.And.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.And, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.And.write(writer, instance.and) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Or' variant - */ - public data class Or( - public val or: jp.co.soramitsu.iroha2.generated.Or, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 11 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Or = - try { - Or( - jp.co.soramitsu.iroha2.generated.Or.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Or, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Or.write(writer, instance.or) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'If' variant - */ - public data class If( - public val `if`: jp.co.soramitsu.iroha2.generated.If, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 12 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.If = - try { - If( - jp.co.soramitsu.iroha2.generated.If.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.If, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.If.write(writer, instance.`if`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Raw' variant - */ - public data class Raw( - public val `value`: Value, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 13 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Raw = - try { - Raw( - Value.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Raw, - ): Unit = try { - Value.write(writer, instance.`value`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Query' variant - */ - public data class Query( - public val queryBox: QueryBox, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 14 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Query = try { - Query( - QueryBox.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Query, - ): Unit = try { - QueryBox.write(writer, instance.queryBox) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Contains' variant - */ - public data class Contains( - public val contains: jp.co.soramitsu.iroha2.generated.Contains, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 15 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Contains = try { - Contains( - jp.co.soramitsu.iroha2.generated.Contains.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Contains, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Contains.write(writer, instance.contains) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ContainsAll' variant - */ - public data class ContainsAll( - public val containsAll: jp.co.soramitsu.iroha2.generated.ContainsAll, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 16 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.ContainsAll = try { - ContainsAll( - jp.co.soramitsu.iroha2.generated.ContainsAll.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.ContainsAll, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.ContainsAll.write(writer, instance.containsAll) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ContainsAny' variant - */ - public data class ContainsAny( - public val containsAny: jp.co.soramitsu.iroha2.generated.ContainsAny, - ) : Expression() { - 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.Expression.ContainsAny = try { - ContainsAny( - jp.co.soramitsu.iroha2.generated.ContainsAny.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.ContainsAny, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.ContainsAny.write(writer, instance.containsAny) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Where' variant - */ - public data class Where( - public val `where`: jp.co.soramitsu.iroha2.generated.Where, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 18 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.Where = try { - Where( - jp.co.soramitsu.iroha2.generated.Where.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.Where, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Where.write(writer, instance.`where`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ContextValue' variant - */ - public data class ContextValue( - public val contextValue: jp.co.soramitsu.iroha2.generated.ContextValue, - ) : Expression() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 19 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Expression.ContextValue = try { - ContextValue( - jp.co.soramitsu.iroha2.generated.ContextValue.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Expression.ContextValue, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.ContextValue.write(writer, instance.contextValue) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Expression = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Add.read(reader) - 1 -> Subtract.read(reader) - 2 -> Multiply.read(reader) - 3 -> Divide.read(reader) - 4 -> Mod.read(reader) - 5 -> RaiseTo.read(reader) - 6 -> Greater.read(reader) - 7 -> Less.read(reader) - 8 -> Equal.read(reader) - 9 -> Not.read(reader) - 10 -> And.read(reader) - 11 -> Or.read(reader) - 12 -> If.read(reader) - 13 -> Raw.read(reader) - 14 -> Query.read(reader) - 15 -> Contains.read(reader) - 16 -> ContainsAll.read(reader) - 17 -> ContainsAny.read(reader) - 18 -> Where.read(reader) - 19 -> ContextValue.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: Expression) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Add.write(writer, instance as Add) - 1 -> Subtract.write(writer, instance as Subtract) - 2 -> Multiply.write(writer, instance as Multiply) - 3 -> Divide.write(writer, instance as Divide) - 4 -> Mod.write(writer, instance as Mod) - 5 -> RaiseTo.write(writer, instance as RaiseTo) - 6 -> Greater.write(writer, instance as Greater) - 7 -> Less.write(writer, instance as Less) - 8 -> Equal.write(writer, instance as Equal) - 9 -> Not.write(writer, instance as Not) - 10 -> And.write(writer, instance as And) - 11 -> Or.write(writer, instance as Or) - 12 -> If.write(writer, instance as If) - 13 -> Raw.write(writer, instance as Raw) - 14 -> Query.write(writer, instance as Query) - 15 -> Contains.write(writer, instance as Contains) - 16 -> ContainsAll.write(writer, instance as ContainsAll) - 17 -> ContainsAny.write(writer, instance as ContainsAny) - 18 -> Where.write(writer, instance as Where) - 19 -> ContextValue.write(writer, instance as ContextValue) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FetchSize.kt similarity index 56% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FetchSize.kt index af2b81604..7883f4fc5 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fail.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FetchSize.kt @@ -8,28 +8,27 @@ 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.String import kotlin.Unit /** - * Fail + * FetchSize * - * Generated from 'Fail' regular structure + * Generated from 'FetchSize' regular structure */ -public data class Fail( - public val message: String, +public data class FetchSize( + public val fetchSize: NonZeroOfu32? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Fail = try { - Fail( - reader.readString(), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FetchSize = try { + FetchSize( + reader.readNullable(NonZeroOfu32) as NonZeroOfu32?, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Fail): Unit = try { - writer.writeAsList(instance.message.toByteArray(Charsets.UTF_8)) + override fun write(writer: ScaleCodecWriter, instance: FetchSize): Unit = try { + writer.writeNullable(NonZeroOfu32, instance.fetchSize) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountEventFilter.kt deleted file mode 100644 index c611f432c..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountEventFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAccountEventFilter - * - * Generated from 'FilterOptOfAccountEventFilter' enum - */ -public sealed class FilterOptOfAccountEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAccountEventFilter() { - 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.FilterOptOfAccountEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountEventFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAccountEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val accountEventFilter: AccountEventFilter, - ) : FilterOptOfAccountEventFilter() { - 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.FilterOptOfAccountEventFilter.BySome = try { - BySome( - AccountEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountEventFilter.BySome, - ): Unit = - try { - AccountEventFilter.write(writer, instance.accountEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAccountEventFilter = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAccountEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountFilter.kt deleted file mode 100644 index 259f8cb93..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAccountFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAccountFilter - * - * Generated from 'FilterOptOfAccountFilter' enum - */ -public sealed class FilterOptOfAccountFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAccountFilter() { - 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.FilterOptOfAccountFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAccountFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val accountFilter: AccountFilter, - ) : FilterOptOfAccountFilter() { - 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.FilterOptOfAccountFilter.BySome = try { - BySome( - AccountFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAccountFilter.BySome, - ): Unit = try { - AccountFilter.write(writer, instance.accountFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAccountFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAccountFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionEventFilter.kt deleted file mode 100644 index e0323ac1b..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionEventFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAssetDefinitionEventFilter - * - * Generated from 'FilterOptOfAssetDefinitionEventFilter' enum - */ -public sealed class FilterOptOfAssetDefinitionEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAssetDefinitionEventFilter() { - 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.FilterOptOfAssetDefinitionEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionEventFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAssetDefinitionEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val assetDefinitionEventFilter: AssetDefinitionEventFilter, - ) : FilterOptOfAssetDefinitionEventFilter() { - 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.FilterOptOfAssetDefinitionEventFilter.BySome = try { - BySome( - AssetDefinitionEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionEventFilter.BySome, - ): Unit = try { - AssetDefinitionEventFilter.write(writer, instance.assetDefinitionEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAssetDefinitionEventFilter = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAssetDefinitionEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionFilter.kt deleted file mode 100644 index 62ecc5c8d..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetDefinitionFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAssetDefinitionFilter - * - * Generated from 'FilterOptOfAssetDefinitionFilter' enum - */ -public sealed class FilterOptOfAssetDefinitionFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAssetDefinitionFilter() { - 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.FilterOptOfAssetDefinitionFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAssetDefinitionFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val assetDefinitionFilter: AssetDefinitionFilter, - ) : FilterOptOfAssetDefinitionFilter() { - 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.FilterOptOfAssetDefinitionFilter.BySome = try { - BySome( - AssetDefinitionFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetDefinitionFilter.BySome, - ): Unit = try { - AssetDefinitionFilter.write(writer, instance.assetDefinitionFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAssetDefinitionFilter = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAssetDefinitionFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetEventFilter.kt deleted file mode 100644 index 679f306a2..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetEventFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAssetEventFilter - * - * Generated from 'FilterOptOfAssetEventFilter' enum - */ -public sealed class FilterOptOfAssetEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAssetEventFilter() { - 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.FilterOptOfAssetEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetEventFilter.AcceptAll, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAssetEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val assetEventFilter: AssetEventFilter, - ) : FilterOptOfAssetEventFilter() { - 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.FilterOptOfAssetEventFilter.BySome = try { - BySome( - AssetEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetEventFilter.BySome, - ): Unit = try { - AssetEventFilter.write(writer, instance.assetEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAssetEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAssetEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetFilter.kt deleted file mode 100644 index c5f9066e3..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfAssetFilter.kt +++ /dev/null @@ -1,122 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfAssetFilter - * - * Generated from 'FilterOptOfAssetFilter' enum - */ -public sealed class FilterOptOfAssetFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfAssetFilter() { - 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.FilterOptOfAssetFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfAssetFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val assetFilter: AssetFilter, - ) : FilterOptOfAssetFilter() { - 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.FilterOptOfAssetFilter.BySome = try { - BySome( - AssetFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfAssetFilter.BySome, - ): Unit = try { - AssetFilter.write(writer, instance.assetFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfAssetFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfAssetFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDataEntityFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDataEntityFilter.kt deleted file mode 100644 index 5ed243e29..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDataEntityFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfDataEntityFilter - * - * Generated from 'FilterOptOfDataEntityFilter' enum - */ -public sealed class FilterOptOfDataEntityFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfDataEntityFilter() { - 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.FilterOptOfDataEntityFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDataEntityFilter.AcceptAll, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfDataEntityFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfDataEntityFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val dataEntityFilter: DataEntityFilter, - ) : FilterOptOfDataEntityFilter() { - 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.FilterOptOfDataEntityFilter.BySome = try { - BySome( - DataEntityFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDataEntityFilter.BySome, - ): Unit = try { - DataEntityFilter.write(writer, instance.dataEntityFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfDataEntityFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfDataEntityFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainEventFilter.kt deleted file mode 100644 index 83593aa77..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainEventFilter.kt +++ /dev/null @@ -1,126 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfDomainEventFilter - * - * Generated from 'FilterOptOfDomainEventFilter' enum - */ -public sealed class FilterOptOfDomainEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfDomainEventFilter() { - 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.FilterOptOfDomainEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainEventFilter.AcceptAll, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfDomainEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val domainEventFilter: DomainEventFilter, - ) : FilterOptOfDomainEventFilter() { - 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.FilterOptOfDomainEventFilter.BySome = try { - BySome( - DomainEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainEventFilter.BySome, - ): Unit = - try { - DomainEventFilter.write(writer, instance.domainEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfDomainEventFilter = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfDomainEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainFilter.kt deleted file mode 100644 index a8a6412cc..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfDomainFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfDomainFilter - * - * Generated from 'FilterOptOfDomainFilter' enum - */ -public sealed class FilterOptOfDomainFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfDomainFilter() { - 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.FilterOptOfDomainFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfDomainFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val domainFilter: DomainFilter, - ) : FilterOptOfDomainFilter() { - 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.FilterOptOfDomainFilter.BySome = try { - BySome( - DomainFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfDomainFilter.BySome, - ): Unit = try { - DomainFilter.write(writer, instance.domainFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfDomainFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfDomainFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAccountEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAccountEvent.kt deleted file mode 100644 index c19bcfec0..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAccountEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfAccountEvent - * - * Generated from 'FilterOptOfOriginFilterOfAccountEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfAccountEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfAccountEvent() { - 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.FilterOptOfOriginFilterOfAccountEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAccountEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAccountEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfAccountEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfAccountEvent: OriginFilterOfAccountEvent, - ) : FilterOptOfOriginFilterOfAccountEvent() { - 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.FilterOptOfOriginFilterOfAccountEvent.BySome = try { - BySome( - OriginFilterOfAccountEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAccountEvent.BySome, - ): Unit = try { - OriginFilterOfAccountEvent.write(writer, instance.originFilterOfAccountEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfAccountEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfAccountEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetDefinitionEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetDefinitionEvent.kt deleted file mode 100644 index df165431f..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetDefinitionEvent.kt +++ /dev/null @@ -1,131 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfAssetDefinitionEvent - * - * Generated from 'FilterOptOfOriginFilterOfAssetDefinitionEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfAssetDefinitionEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfAssetDefinitionEvent() { - 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.FilterOptOfOriginFilterOfAssetDefinitionEvent.AcceptAll = - try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetDefinitionEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetDefinitionEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = - ".FilterOptOfOriginFilterOfAssetDefinitionEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfAssetDefinitionEvent: OriginFilterOfAssetDefinitionEvent, - ) : FilterOptOfOriginFilterOfAssetDefinitionEvent() { - 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.FilterOptOfOriginFilterOfAssetDefinitionEvent.BySome = - try { - BySome( - OriginFilterOfAssetDefinitionEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetDefinitionEvent.BySome, - ): Unit = try { - OriginFilterOfAssetDefinitionEvent.write( - writer, - instance.originFilterOfAssetDefinitionEvent, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfAssetDefinitionEvent = - when (val discriminant = reader.readUByte()) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write( - writer: ScaleCodecWriter, - instance: FilterOptOfOriginFilterOfAssetDefinitionEvent, - ) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetEvent.kt deleted file mode 100644 index 2036e96b3..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfAssetEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfAssetEvent - * - * Generated from 'FilterOptOfOriginFilterOfAssetEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfAssetEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfAssetEvent() { - 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.FilterOptOfOriginFilterOfAssetEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfAssetEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfAssetEvent: OriginFilterOfAssetEvent, - ) : FilterOptOfOriginFilterOfAssetEvent() { - 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.FilterOptOfOriginFilterOfAssetEvent.BySome = try { - BySome( - OriginFilterOfAssetEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfAssetEvent.BySome, - ): Unit = try { - OriginFilterOfAssetEvent.write(writer, instance.originFilterOfAssetEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfAssetEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfAssetEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfDomainEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfDomainEvent.kt deleted file mode 100644 index 67ca037ef..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfDomainEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfDomainEvent - * - * Generated from 'FilterOptOfOriginFilterOfDomainEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfDomainEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfDomainEvent() { - 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.FilterOptOfOriginFilterOfDomainEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfDomainEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfDomainEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfDomainEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfDomainEvent: OriginFilterOfDomainEvent, - ) : FilterOptOfOriginFilterOfDomainEvent() { - 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.FilterOptOfOriginFilterOfDomainEvent.BySome = try { - BySome( - OriginFilterOfDomainEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfDomainEvent.BySome, - ): Unit = try { - OriginFilterOfDomainEvent.write(writer, instance.originFilterOfDomainEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfDomainEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfDomainEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfPeerEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfPeerEvent.kt deleted file mode 100644 index b2cdaade8..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfPeerEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfPeerEvent - * - * Generated from 'FilterOptOfOriginFilterOfPeerEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfPeerEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfPeerEvent() { - 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.FilterOptOfOriginFilterOfPeerEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfPeerEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfPeerEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfPeerEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfPeerEvent: OriginFilterOfPeerEvent, - ) : FilterOptOfOriginFilterOfPeerEvent() { - 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.FilterOptOfOriginFilterOfPeerEvent.BySome = try { - BySome( - OriginFilterOfPeerEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfPeerEvent.BySome, - ): Unit = try { - OriginFilterOfPeerEvent.write(writer, instance.originFilterOfPeerEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfPeerEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfPeerEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfRoleEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfRoleEvent.kt deleted file mode 100644 index 20cf4e2f9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfRoleEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfRoleEvent - * - * Generated from 'FilterOptOfOriginFilterOfRoleEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfRoleEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfRoleEvent() { - 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.FilterOptOfOriginFilterOfRoleEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfRoleEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfRoleEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfRoleEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfRoleEvent: OriginFilterOfRoleEvent, - ) : FilterOptOfOriginFilterOfRoleEvent() { - 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.FilterOptOfOriginFilterOfRoleEvent.BySome = try { - BySome( - OriginFilterOfRoleEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfRoleEvent.BySome, - ): Unit = try { - OriginFilterOfRoleEvent.write(writer, instance.originFilterOfRoleEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfRoleEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfRoleEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfTriggerEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfTriggerEvent.kt deleted file mode 100644 index 921661a9f..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfOriginFilterOfTriggerEvent.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfOriginFilterOfTriggerEvent - * - * Generated from 'FilterOptOfOriginFilterOfTriggerEvent' enum - */ -public sealed class FilterOptOfOriginFilterOfTriggerEvent : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfOriginFilterOfTriggerEvent() { - 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.FilterOptOfOriginFilterOfTriggerEvent.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfTriggerEvent.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfTriggerEvent.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfOriginFilterOfTriggerEvent.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val originFilterOfTriggerEvent: OriginFilterOfTriggerEvent, - ) : FilterOptOfOriginFilterOfTriggerEvent() { - 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.FilterOptOfOriginFilterOfTriggerEvent.BySome = try { - BySome( - OriginFilterOfTriggerEvent.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfOriginFilterOfTriggerEvent.BySome, - ): Unit = try { - OriginFilterOfTriggerEvent.write(writer, instance.originFilterOfTriggerEvent) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfOriginFilterOfTriggerEvent = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfOriginFilterOfTriggerEvent) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerEventFilter.kt deleted file mode 100644 index fa62354b3..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerEventFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfPeerEventFilter - * - * Generated from 'FilterOptOfPeerEventFilter' enum - */ -public sealed class FilterOptOfPeerEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfPeerEventFilter() { - 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.FilterOptOfPeerEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerEventFilter.AcceptAll, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfPeerEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val peerEventFilter: PeerEventFilter, - ) : FilterOptOfPeerEventFilter() { - 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.FilterOptOfPeerEventFilter.BySome = try { - BySome( - PeerEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerEventFilter.BySome, - ): Unit = try { - PeerEventFilter.write(writer, instance.peerEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfPeerEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfPeerEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerFilter.kt deleted file mode 100644 index 5c3c58e94..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfPeerFilter.kt +++ /dev/null @@ -1,122 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfPeerFilter - * - * Generated from 'FilterOptOfPeerFilter' enum - */ -public sealed class FilterOptOfPeerFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfPeerFilter() { - 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.FilterOptOfPeerFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfPeerFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val peerFilter: PeerFilter, - ) : FilterOptOfPeerFilter() { - 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.FilterOptOfPeerFilter.BySome = try { - BySome( - PeerFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfPeerFilter.BySome, - ): Unit = try { - PeerFilter.write(writer, instance.peerFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfPeerFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfPeerFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleEventFilter.kt deleted file mode 100644 index 7cd93fed5..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfRoleEventFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfRoleEventFilter - * - * Generated from 'FilterOptOfRoleEventFilter' enum - */ -public sealed class FilterOptOfRoleEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfRoleEventFilter() { - 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.FilterOptOfRoleEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleEventFilter.AcceptAll, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfRoleEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val roleEventFilter: RoleEventFilter, - ) : FilterOptOfRoleEventFilter() { - 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.FilterOptOfRoleEventFilter.BySome = try { - BySome( - RoleEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfRoleEventFilter.BySome, - ): Unit = try { - RoleEventFilter.write(writer, instance.roleEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfRoleEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfRoleEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerEventFilter.kt deleted file mode 100644 index b80a1f5e6..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerEventFilter.kt +++ /dev/null @@ -1,125 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfTriggerEventFilter - * - * Generated from 'FilterOptOfTriggerEventFilter' enum - */ -public sealed class FilterOptOfTriggerEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfTriggerEventFilter() { - 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.FilterOptOfTriggerEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerEventFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfTriggerEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val triggerEventFilter: TriggerEventFilter, - ) : FilterOptOfTriggerEventFilter() { - 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.FilterOptOfTriggerEventFilter.BySome = try { - BySome( - TriggerEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerEventFilter.BySome, - ): Unit = - try { - TriggerEventFilter.write(writer, instance.triggerEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfTriggerEventFilter = when ( - val - discriminant = reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfTriggerEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerFilter.kt deleted file mode 100644 index dc38f2cae..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FilterOptOfTriggerFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * FilterOptOfTriggerFilter - * - * Generated from 'FilterOptOfTriggerFilter' enum - */ -public sealed class FilterOptOfTriggerFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : FilterOptOfTriggerFilter() { - 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.FilterOptOfTriggerFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".FilterOptOfTriggerFilter.AcceptAll".hashCode() - } - } - - /** - * 'BySome' variant - */ - public data class BySome( - public val triggerFilter: TriggerFilter, - ) : FilterOptOfTriggerFilter() { - 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.FilterOptOfTriggerFilter.BySome = try { - BySome( - TriggerFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FilterOptOfTriggerFilter.BySome, - ): Unit = try { - TriggerFilter.write(writer, instance.triggerFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FilterOptOfTriggerFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> BySome.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: FilterOptOfTriggerFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> BySome.write(writer, instance as BySome) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountById.kt index 0db7c76d1..684034e0a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountById.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAccountById' regular structure */ public data class FindAccountById( - public val id: EvaluatesTo, + public val id: AccountId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAccountById = try { FindAccountById( - EvaluatesTo.read(reader) as EvaluatesTo, + AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAccountById): Unit = try { - EvaluatesTo.write(writer, instance.id) + AccountId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountKeyValueByIdAndKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountKeyValueByIdAndKey.kt index 0ba85b04d..3ec7ba137 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountKeyValueByIdAndKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountKeyValueByIdAndKey.kt @@ -16,16 +16,16 @@ import kotlin.Unit * Generated from 'FindAccountKeyValueByIdAndKey' regular structure */ public data class FindAccountKeyValueByIdAndKey( - public val id: EvaluatesTo, - public val key: EvaluatesTo, + public val id: AccountId, + public val key: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAccountKeyValueByIdAndKey = try { FindAccountKeyValueByIdAndKey( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + AccountId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -33,8 +33,8 @@ public data class FindAccountKeyValueByIdAndKey( override fun write(writer: ScaleCodecWriter, instance: FindAccountKeyValueByIdAndKey): Unit = try { - EvaluatesTo.write(writer, instance.id) - EvaluatesTo.write(writer, instance.key) + AccountId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByName.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountMetadata.kt similarity index 56% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByName.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountMetadata.kt index a91071ad9..42c47d23c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByName.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountMetadata.kt @@ -11,24 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * FindAccountsByName + * FindAccountMetadata * - * Generated from 'FindAccountsByName' regular structure + * Generated from 'FindAccountMetadata' regular structure */ -public data class FindAccountsByName( - public val name: EvaluatesTo, +public data class FindAccountMetadata( + public val id: AccountId, + public val key: Name, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FindAccountsByName = try { - FindAccountsByName( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAccountMetadata = try { + FindAccountMetadata( + AccountId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: FindAccountsByName): Unit = try { - EvaluatesTo.write(writer, instance.name) + override fun write(writer: ScaleCodecWriter, instance: FindAccountMetadata): Unit = try { + AccountId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokenSchema.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccounts.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokenSchema.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccounts.kt index 875239374..f497845e5 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokenSchema.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccounts.kt @@ -14,30 +14,28 @@ import kotlin.Int import kotlin.Unit /** - * FindPermissionTokenSchema + * FindAccounts * - * Generated from 'FindPermissionTokenSchema' regular structure + * Generated from 'FindAccounts' regular structure */ -public class FindPermissionTokenSchema { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FindPermissionTokenSchema = try { - FindPermissionTokenSchema() +public class FindAccounts { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAccounts = try { + FindAccounts() } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: FindPermissionTokenSchema): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: FindAccounts): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: FindPermissionTokenSchema, o2: Any?): Boolean = when (o2) { + public fun equals(o1: FindAccounts, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".FindPermissionTokenSchema".hashCode() + override fun hashCode(): Int = ".FindAccounts".hashCode() } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByDomainId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByDomainId.kt index 3941f2b2c..9a6a49a13 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByDomainId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsByDomainId.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAccountsByDomainId' regular structure */ public data class FindAccountsByDomainId( - public val domainId: EvaluatesTo, + public val domain: DomainId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAccountsByDomainId = try { FindAccountsByDomainId( - EvaluatesTo.read(reader) as EvaluatesTo, + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAccountsByDomainId): Unit = try { - EvaluatesTo.write(writer, instance.domainId) + DomainId.write(writer, instance.domain) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsWithAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsWithAsset.kt index 0ea02b2d7..e22c8b519 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsWithAsset.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAccountsWithAsset.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAccountsWithAsset' regular structure */ public data class FindAccountsWithAsset( - public val assetDefinitionId: EvaluatesTo, + public val assetDefinition: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAccountsWithAsset = try { FindAccountsWithAsset( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAccountsWithAsset): Unit = try { - EvaluatesTo.write(writer, instance.assetDefinitionId) + AssetDefinitionId.write(writer, instance.assetDefinition) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindActiveTriggerIds.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindActiveTriggerIds.kt new file mode 100644 index 000000000..4c9688a10 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindActiveTriggerIds.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindActiveTriggerIds + * + * Generated from 'FindActiveTriggerIds' regular structure + */ +public class FindActiveTriggerIds { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindActiveTriggerIds = try { + FindActiveTriggerIds() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindActiveTriggerIds): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindActiveTriggerIds, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindActiveTriggerIds".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetById.kt index 10392eb6e..e9757c51a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetById.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAssetById' regular structure */ public data class FindAssetById( - public val id: EvaluatesTo, + public val id: AssetId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetById = try { FindAssetById( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetById): Unit = try { - EvaluatesTo.write(writer, instance.id) + AssetId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionById.kt index afaa268ed..116a42897 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionById.kt @@ -16,21 +16,21 @@ import kotlin.Unit * Generated from 'FindAssetDefinitionById' regular structure */ public data class FindAssetDefinitionById( - public val id: EvaluatesTo, + public val id: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetDefinitionById = try { FindAssetDefinitionById( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetDefinitionById): Unit = try { - EvaluatesTo.write(writer, instance.id) + AssetDefinitionId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionKeyValueByIdAndKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionKeyValueByIdAndKey.kt index 5ef3586a9..ca002dd8a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionKeyValueByIdAndKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionKeyValueByIdAndKey.kt @@ -16,24 +16,24 @@ import kotlin.Unit * Generated from 'FindAssetDefinitionKeyValueByIdAndKey' regular structure */ public data class FindAssetDefinitionKeyValueByIdAndKey( - public val id: EvaluatesTo, - public val key: EvaluatesTo, + public val id: AssetDefinitionId, + public val key: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetDefinitionKeyValueByIdAndKey = try { FindAssetDefinitionKeyValueByIdAndKey( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + AssetDefinitionId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetDefinitionKeyValueByIdAndKey): Unit = try { - EvaluatesTo.write(writer, instance.id) - EvaluatesTo.write(writer, instance.key) + AssetDefinitionId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionMetadata.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionMetadata.kt new file mode 100644 index 000000000..62eb5f346 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetDefinitionMetadata.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 + +/** + * FindAssetDefinitionMetadata + * + * Generated from 'FindAssetDefinitionMetadata' regular structure + */ +public data class FindAssetDefinitionMetadata( + public val id: AssetDefinitionId, + public val key: Name, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAssetDefinitionMetadata = try { + FindAssetDefinitionMetadata( + AssetDefinitionId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindAssetDefinitionMetadata): Unit = try { + AssetDefinitionId.write(writer, instance.id) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetKeyValueByIdAndKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetKeyValueByIdAndKey.kt index 6fd9369cb..d81e70e13 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetKeyValueByIdAndKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetKeyValueByIdAndKey.kt @@ -16,24 +16,24 @@ import kotlin.Unit * Generated from 'FindAssetKeyValueByIdAndKey' regular structure */ public data class FindAssetKeyValueByIdAndKey( - public val id: EvaluatesTo, - public val key: EvaluatesTo, + public val id: AssetId, + public val key: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetKeyValueByIdAndKey = try { FindAssetKeyValueByIdAndKey( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + AssetId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetKeyValueByIdAndKey): Unit = try { - EvaluatesTo.write(writer, instance.id) - EvaluatesTo.write(writer, instance.key) + AssetId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValueOfKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetMetadata.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValueOfKey.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetMetadata.kt index e035b1be9..2dbe3cd3f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValueOfKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetMetadata.kt @@ -11,27 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * ValueOfKey + * FindAssetMetadata * - * Generated from 'ValueOfKey' regular structure + * Generated from 'FindAssetMetadata' regular structure */ -public data class ValueOfKey( +public data class FindAssetMetadata( + public val id: AssetId, public val key: Name, - public val predicate: ValuePredicate, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ValueOfKey = try { - ValueOfKey( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAssetMetadata = try { + FindAssetMetadata( + AssetId.read(reader), Name.read(reader), - ValuePredicate.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: ValueOfKey): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: FindAssetMetadata): Unit = try { + AssetId.write(writer, instance.id) Name.write(writer, instance.key) - ValuePredicate.write(writer, instance.predicate) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetQuantityById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetQuantityById.kt index 932410f6d..bc6c76a13 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetQuantityById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetQuantityById.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAssetQuantityById' regular structure */ public data class FindAssetQuantityById( - public val id: EvaluatesTo, + public val id: AssetId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetQuantityById = try { FindAssetQuantityById( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetQuantityById): Unit = try { - EvaluatesTo.write(writer, instance.id) + AssetId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssets.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssets.kt new file mode 100644 index 000000000..4de441a0d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssets.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindAssets + * + * Generated from 'FindAssets' regular structure + */ +public class FindAssets { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAssets = try { + FindAssets() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindAssets): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindAssets, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindAssets".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAccountId.kt index 6e3558cbe..4f4f75f40 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAccountId.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAssetsByAccountId' regular structure */ public data class FindAssetsByAccountId( - public val accountId: EvaluatesTo, + public val account: AccountId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetsByAccountId = try { FindAssetsByAccountId( - EvaluatesTo.read(reader) as EvaluatesTo, + AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetsByAccountId): Unit = try { - EvaluatesTo.write(writer, instance.accountId) + AccountId.write(writer, instance.account) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAssetDefinitionId.kt index 974c0a320..cdcfc5bbe 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAssetDefinitionId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByAssetDefinitionId.kt @@ -16,14 +16,14 @@ import kotlin.Unit * Generated from 'FindAssetsByAssetDefinitionId' regular structure */ public data class FindAssetsByAssetDefinitionId( - public val assetDefinitionId: EvaluatesTo, + public val assetDefinition: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetsByAssetDefinitionId = try { FindAssetsByAssetDefinitionId( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -31,7 +31,7 @@ public data class FindAssetsByAssetDefinitionId( override fun write(writer: ScaleCodecWriter, instance: FindAssetsByAssetDefinitionId): Unit = try { - EvaluatesTo.write(writer, instance.assetDefinitionId) + AssetDefinitionId.write(writer, instance.assetDefinition) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainId.kt index ef87fbb64..19ac46ef9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainId.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAssetsByDomainId' regular structure */ public data class FindAssetsByDomainId( - public val domainId: EvaluatesTo, + public val domain: DomainId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetsByDomainId = try { FindAssetsByDomainId( - EvaluatesTo.read(reader) as EvaluatesTo, + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetsByDomainId): Unit = try { - EvaluatesTo.write(writer, instance.domainId) + DomainId.write(writer, instance.domain) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainIdAndAssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainIdAndAssetDefinitionId.kt index be9ee5172..cfdadd4f2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainIdAndAssetDefinitionId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByDomainIdAndAssetDefinitionId.kt @@ -16,16 +16,16 @@ import kotlin.Unit * Generated from 'FindAssetsByDomainIdAndAssetDefinitionId' regular structure */ public data class FindAssetsByDomainIdAndAssetDefinitionId( - public val domainId: EvaluatesTo, - public val assetDefinitionId: EvaluatesTo, + public val domain: DomainId, + public val assetDefinition: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetsByDomainIdAndAssetDefinitionId = try { FindAssetsByDomainIdAndAssetDefinitionId( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + DomainId.read(reader), + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -35,8 +35,8 @@ public data class FindAssetsByDomainIdAndAssetDefinitionId( writer: ScaleCodecWriter, instance: FindAssetsByDomainIdAndAssetDefinitionId, ): Unit = try { - EvaluatesTo.write(writer, instance.domainId) - EvaluatesTo.write(writer, instance.assetDefinitionId) + DomainId.write(writer, instance.domain) + AssetDefinitionId.write(writer, instance.assetDefinition) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByName.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByName.kt index 4cc1cb5f9..6a2f1ebe0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByName.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsByName.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindAssetsByName' regular structure */ public data class FindAssetsByName( - public val name: EvaluatesTo, + public val name: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindAssetsByName = try { FindAssetsByName( - EvaluatesTo.read(reader) as EvaluatesTo, + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindAssetsByName): Unit = try { - EvaluatesTo.write(writer, instance.name) + Name.write(writer, instance.name) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsDefinitions.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsDefinitions.kt new file mode 100644 index 000000000..f714d7fe5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindAssetsDefinitions.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindAssetsDefinitions + * + * Generated from 'FindAssetsDefinitions' regular structure + */ +public class FindAssetsDefinitions { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindAssetsDefinitions = try { + FindAssetsDefinitions() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindAssetsDefinitions): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindAssetsDefinitions, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindAssetsDefinitions".hashCode() + } +} 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 340224bf3..7f2cc1271 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,19 +16,19 @@ import kotlin.Unit * Generated from 'FindBlockHeaderByHash' regular structure */ public data class FindBlockHeaderByHash( - public val hash: EvaluatesTo>, + public val hash: HashOf, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindBlockHeaderByHash = try { FindBlockHeaderByHash( - EvaluatesTo.read(reader) as EvaluatesTo>, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindBlockHeaderByHash): Unit = try { - EvaluatesTo.write(writer, instance.hash) + HashOf.write(writer, instance.hash) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaders.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaders.kt new file mode 100644 index 000000000..d76648349 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlockHeaders.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindBlockHeaders + * + * Generated from 'FindBlockHeaders' regular structure + */ +public class FindBlockHeaders { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindBlockHeaders = try { + FindBlockHeaders() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindBlockHeaders): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindBlockHeaders, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindBlockHeaders".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlocks.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlocks.kt new file mode 100644 index 000000000..950ecc220 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindBlocks.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindBlocks + * + * Generated from 'FindBlocks' regular structure + */ +public class FindBlocks { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindBlocks = try { + FindBlocks() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindBlocks): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindBlocks, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindBlocks".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainById.kt index ac6a3f3bc..f2043fecb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainById.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindDomainById' regular structure */ public data class FindDomainById( - public val id: EvaluatesTo, + public val id: DomainId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindDomainById = try { FindDomainById( - EvaluatesTo.read(reader) as EvaluatesTo, + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindDomainById): Unit = try { - EvaluatesTo.write(writer, instance.id) + DomainId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainKeyValueByIdAndKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainKeyValueByIdAndKey.kt index 315d40e96..75f2c65c3 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainKeyValueByIdAndKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainKeyValueByIdAndKey.kt @@ -16,24 +16,24 @@ import kotlin.Unit * Generated from 'FindDomainKeyValueByIdAndKey' regular structure */ public data class FindDomainKeyValueByIdAndKey( - public val id: EvaluatesTo, - public val key: EvaluatesTo, + public val id: DomainId, + public val key: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindDomainKeyValueByIdAndKey = try { FindDomainKeyValueByIdAndKey( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + DomainId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindDomainKeyValueByIdAndKey): Unit = try { - EvaluatesTo.write(writer, instance.id) - EvaluatesTo.write(writer, instance.key) + DomainId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainMetadata.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainMetadata.kt new file mode 100644 index 000000000..8fc317f3a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomainMetadata.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 + +/** + * FindDomainMetadata + * + * Generated from 'FindDomainMetadata' regular structure + */ +public data class FindDomainMetadata( + public val id: DomainId, + public val key: Name, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindDomainMetadata = try { + FindDomainMetadata( + DomainId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindDomainMetadata): Unit = try { + DomainId.write(writer, instance.id) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomains.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomains.kt new file mode 100644 index 000000000..f38ee835e --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindDomains.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindDomains + * + * Generated from 'FindDomains' regular structure + */ +public class FindDomains { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindDomains = try { + FindDomains() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindDomains): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindDomains, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindDomains".hashCode() + } +} 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 d24d648cd..6bb6ffa0b 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) @@ -346,53 +346,21 @@ public sealed class FindError : ModelEnum { } /** - * 'PermissionToken' variant + * 'Permission' variant */ - public data class PermissionToken( - public val name: Name, + public data class Permission( + public val permission: jp.co.soramitsu.iroha2.generated.Permission, ) : FindError() { 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.FindError.PermissionToken = try { - PermissionToken( - Name.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FindError.PermissionToken, - ): Unit = try { - Name.write(writer, instance.name) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Parameter' variant - */ - public data class Parameter( - public val parameterId: ParameterId, - ) : FindError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 11 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.FindError.Parameter = try { - Parameter( - ParameterId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.FindError.Permission = try { + Permission( + jp.co.soramitsu.iroha2.generated.Permission.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -400,9 +368,9 @@ public sealed class FindError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.FindError.Parameter, + instance: jp.co.soramitsu.iroha2.generated.FindError.Permission, ): Unit = try { - ParameterId.write(writer, instance.parameterId) + jp.co.soramitsu.iroha2.generated.Permission.write(writer, instance.permission) } catch (ex: Exception) { throw wrapException(ex) } @@ -420,7 +388,7 @@ public sealed class FindError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 12 + public const val DISCRIMINANT: Int = 11 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.FindError.PublicKey = try { PublicKey( @@ -456,9 +424,8 @@ public sealed class FindError : ModelEnum { 7 -> Peer.read(reader) 8 -> Trigger.read(reader) 9 -> Role.read(reader) - 10 -> PermissionToken.read(reader) - 11 -> Parameter.read(reader) - 12 -> PublicKey.read(reader) + 10 -> Permission.read(reader) + 11 -> PublicKey.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: FindError) { @@ -474,9 +441,8 @@ public sealed class FindError : ModelEnum { 7 -> Peer.write(writer, instance as Peer) 8 -> Trigger.write(writer, instance as Trigger) 9 -> Role.write(writer, instance as Role) - 10 -> PermissionToken.write(writer, instance as PermissionToken) - 11 -> Parameter.write(writer, instance as Parameter) - 12 -> PublicKey.write(writer, instance as PublicKey) + 10 -> Permission.write(writer, instance as Permission) + 11 -> PublicKey.write(writer, instance as PublicKey) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindExecutorDataModel.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindExecutorDataModel.kt new file mode 100644 index 000000000..8e0a97916 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindExecutorDataModel.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindExecutorDataModel + * + * Generated from 'FindExecutorDataModel' regular structure + */ +public class FindExecutorDataModel { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindExecutorDataModel = try { + FindExecutorDataModel() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindExecutorDataModel): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindExecutorDataModel, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindExecutorDataModel".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindParameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindParameters.kt new file mode 100644 index 000000000..38cba1bc0 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindParameters.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindParameters + * + * Generated from 'FindParameters' regular structure + */ +public class FindParameters { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindParameters = try { + FindParameters() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindParameters): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindParameters, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindParameters".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPeers.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPeers.kt new file mode 100644 index 000000000..37e309d9e --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPeers.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindPeers + * + * Generated from 'FindPeers' regular structure + */ +public class FindPeers { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindPeers = try { + FindPeers() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindPeers): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindPeers, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindPeers".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionsByAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionsByAccountId.kt new file mode 100644 index 000000000..f9df0335c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionsByAccountId.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * FindPermissionsByAccountId + * + * Generated from 'FindPermissionsByAccountId' regular structure + */ +public data class FindPermissionsByAccountId( + public val id: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): FindPermissionsByAccountId = try { + FindPermissionsByAccountId( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindPermissionsByAccountId): Unit = try { + AccountId.write(writer, instance.id) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleByRoleId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleByRoleId.kt index 59798a0fb..1241ec0be 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleByRoleId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleByRoleId.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindRoleByRoleId' regular structure */ public data class FindRoleByRoleId( - public val id: EvaluatesTo, + public val id: RoleId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindRoleByRoleId = try { FindRoleByRoleId( - EvaluatesTo.read(reader) as EvaluatesTo, + RoleId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindRoleByRoleId): Unit = try { - EvaluatesTo.write(writer, instance.id) + RoleId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleIds.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleIds.kt new file mode 100644 index 000000000..eda4a74ae --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoleIds.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindRoleIds + * + * Generated from 'FindRoleIds' regular structure + */ +public class FindRoleIds { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindRoleIds = try { + FindRoleIds() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindRoleIds): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindRoleIds, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindRoleIds".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoles.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoles.kt new file mode 100644 index 000000000..1544198f0 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRoles.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindRoles + * + * Generated from 'FindRoles' regular structure + */ +public class FindRoles { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindRoles = try { + FindRoles() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindRoles): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindRoles, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindRoles".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRolesByAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRolesByAccountId.kt index 202ae69dd..2a2779902 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRolesByAccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindRolesByAccountId.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindRolesByAccountId' regular structure */ public data class FindRolesByAccountId( - public val id: EvaluatesTo, + public val id: AccountId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindRolesByAccountId = try { FindRolesByAccountId( - EvaluatesTo.read(reader) as EvaluatesTo, + AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindRolesByAccountId): Unit = try { - EvaluatesTo.write(writer, instance.id) + AccountId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTotalAssetQuantityByAssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTotalAssetQuantityByAssetDefinitionId.kt index 8087e3660..a47b6e0e3 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTotalAssetQuantityByAssetDefinitionId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTotalAssetQuantityByAssetDefinitionId.kt @@ -16,14 +16,14 @@ import kotlin.Unit * Generated from 'FindTotalAssetQuantityByAssetDefinitionId' regular structure */ public data class FindTotalAssetQuantityByAssetDefinitionId( - public val id: EvaluatesTo, + public val id: AssetDefinitionId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTotalAssetQuantityByAssetDefinitionId = try { FindTotalAssetQuantityByAssetDefinitionId( - EvaluatesTo.read(reader) as EvaluatesTo, + AssetDefinitionId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -33,7 +33,7 @@ public data class FindTotalAssetQuantityByAssetDefinitionId( writer: ScaleCodecWriter, instance: FindTotalAssetQuantityByAssetDefinitionId, ): Unit = try { - EvaluatesTo.write(writer, instance.id) + AssetDefinitionId.write(writer, instance.id) } 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 ef9d688e0..2e33e449d 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,19 +16,19 @@ import kotlin.Unit * Generated from 'FindTransactionByHash' regular structure */ public data class FindTransactionByHash( - public val hash: EvaluatesTo>, + public val hash: HashOf, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTransactionByHash = try { FindTransactionByHash( - EvaluatesTo.read(reader) as EvaluatesTo>, + HashOf.read(reader) as HashOf, ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindTransactionByHash): Unit = try { - EvaluatesTo.write(writer, instance.hash) + HashOf.write(writer, instance.hash) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactions.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactions.kt new file mode 100644 index 000000000..5655b26bc --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactions.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindTransactions + * + * Generated from 'FindTransactions' regular structure + */ +public class FindTransactions { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindTransactions = try { + FindTransactions() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindTransactions): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindTransactions, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindTransactions".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionsByAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionsByAccountId.kt index 9af0e01de..8d1e744a0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionsByAccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTransactionsByAccountId.kt @@ -16,21 +16,21 @@ import kotlin.Unit * Generated from 'FindTransactionsByAccountId' regular structure */ public data class FindTransactionsByAccountId( - public val accountId: EvaluatesTo, + public val account: AccountId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTransactionsByAccountId = try { FindTransactionsByAccountId( - EvaluatesTo.read(reader) as EvaluatesTo, + AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindTransactionsByAccountId): Unit = try { - EvaluatesTo.write(writer, instance.accountId) + AccountId.write(writer, instance.account) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerById.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerById.kt index 1f239cec2..62bcc12a0 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerById.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerById.kt @@ -16,19 +16,19 @@ import kotlin.Unit * Generated from 'FindTriggerById' regular structure */ public data class FindTriggerById( - public val id: EvaluatesTo, + public val id: TriggerId, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTriggerById = try { FindTriggerById( - EvaluatesTo.read(reader) as EvaluatesTo, + TriggerId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: FindTriggerById): Unit = try { - EvaluatesTo.write(writer, instance.id) + TriggerId.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerKeyValueByIdAndKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerKeyValueByIdAndKey.kt index 7b234fc98..6991ade0f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerKeyValueByIdAndKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerKeyValueByIdAndKey.kt @@ -16,16 +16,16 @@ import kotlin.Unit * Generated from 'FindTriggerKeyValueByIdAndKey' regular structure */ public data class FindTriggerKeyValueByIdAndKey( - public val id: EvaluatesTo, - public val key: EvaluatesTo, + public val id: TriggerId, + public val key: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): FindTriggerKeyValueByIdAndKey = try { FindTriggerKeyValueByIdAndKey( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + TriggerId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -33,8 +33,8 @@ public data class FindTriggerKeyValueByIdAndKey( override fun write(writer: ScaleCodecWriter, instance: FindTriggerKeyValueByIdAndKey): Unit = try { - EvaluatesTo.write(writer, instance.id) - EvaluatesTo.write(writer, instance.key) + TriggerId.write(writer, instance.id) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerMetadata.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerMetadata.kt new file mode 100644 index 000000000..f9c573e76 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggerMetadata.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 + +/** + * FindTriggerMetadata + * + * Generated from 'FindTriggerMetadata' regular structure + */ +public data class FindTriggerMetadata( + public val id: TriggerId, + public val key: Name, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindTriggerMetadata = try { + FindTriggerMetadata( + TriggerId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindTriggerMetadata): Unit = try { + TriggerId.write(writer, instance.id) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggers.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggers.kt new file mode 100644 index 000000000..1c6f355f8 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggers.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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * FindTriggers + * + * Generated from 'FindTriggers' regular structure + */ +public class FindTriggers { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): FindTriggers = try { + FindTriggers() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: FindTriggers): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: FindTriggers, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".FindTriggers".hashCode() + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokensByAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityDomainId.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokensByAccountId.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityDomainId.kt index 9bb846a33..22bafc566 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindPermissionTokensByAccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityDomainId.kt @@ -11,27 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * FindPermissionTokensByAccountId + * FindTriggersByAuthorityDomainId * - * Generated from 'FindPermissionTokensByAccountId' regular structure + * Generated from 'FindTriggersByAuthorityDomainId' regular structure */ -public data class FindPermissionTokensByAccountId( - public val id: EvaluatesTo, +public data class FindTriggersByAuthorityDomainId( + public val domain: DomainId, ) { public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): FindPermissionTokensByAccountId = try { - FindPermissionTokensByAccountId( - EvaluatesTo.read(reader) as EvaluatesTo, + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): FindTriggersByAuthorityDomainId = try { + FindTriggersByAuthorityDomainId( + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: FindPermissionTokensByAccountId): Unit = + override fun write(writer: ScaleCodecWriter, instance: FindTriggersByAuthorityDomainId): Unit = try { - EvaluatesTo.write(writer, instance.id) + DomainId.write(writer, instance.domain) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByDomainId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityId.kt similarity index 57% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByDomainId.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityId.kt index c182f8a65..465aa36b9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByDomainId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/FindTriggersByAuthorityId.kt @@ -11,24 +11,26 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * FindTriggersByDomainId + * FindTriggersByAuthorityId * - * Generated from 'FindTriggersByDomainId' regular structure + * Generated from 'FindTriggersByAuthorityId' regular structure */ -public data class FindTriggersByDomainId( - public val domainId: EvaluatesTo, +public data class FindTriggersByAuthorityId( + public val account: AccountId, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): FindTriggersByDomainId = try { - FindTriggersByDomainId( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): FindTriggersByAuthorityId = try { + FindTriggersByAuthorityId( + AccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: FindTriggersByDomainId): Unit = try { - EvaluatesTo.write(writer, instance.domainId) + override fun write(writer: ScaleCodecWriter, instance: FindTriggersByAuthorityId): Unit = try { + AccountId.write(writer, instance.account) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fixed.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fixed.kt deleted file mode 100644 index 4ac58bec6..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Fixed.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.fromFixedPoint -import jp.co.soramitsu.iroha2.toFixedPoint -import jp.co.soramitsu.iroha2.wrapException -import java.math.BigDecimal -import kotlin.Unit - -/** - * Fixed - * - * Generated from 'Fixed' regular structure - */ -public data class Fixed( - public val fixedPointOfI64: BigDecimal, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Fixed = try { - Fixed( - reader.readInt64().toBigInteger().fromFixedPoint(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Fixed): Unit = try { - writer.writeInt64(instance.fixedPointOfI64.toFixedPoint().toLong()) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ForwardCursor.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ForwardCursor.kt index 7987ec4dd..2e34383b1 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ForwardCursor.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ForwardCursor.kt @@ -17,7 +17,7 @@ import kotlin.Unit * Generated from 'ForwardCursor' regular structure */ public data class ForwardCursor( - public val queryId: String? = null, + public val query: String? = null, public val cursor: NonZeroOfu64? = null, ) { public companion object : ScaleReader, ScaleWriter { @@ -31,7 +31,7 @@ public data class ForwardCursor( } override fun write(writer: ScaleCodecWriter, instance: ForwardCursor): Unit = try { - writer.writeNullable(instance.queryId) + writer.writeNullable(instance.query) writer.writeNullable(NonZeroOfu64, instance.cursor) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GenericPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GenericPredicateBox.kt index fd91a3064..2e8de023b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GenericPredicateBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GenericPredicateBox.kt @@ -16,7 +16,7 @@ import kotlin.Unit /** * GenericPredicateBox * - * Generated from 'GenericPredicateBox' enum + * Generated from 'GenericPredicateBox' enum */ public sealed class GenericPredicateBox : ModelEnum { /** @@ -28,8 +28,8 @@ public sealed class GenericPredicateBox : ModelEnum { * 'And' variant */ public data class And( - public val nonTrivial: NonTrivial>, - ) : GenericPredicateBox() { + public val nonTrivial: NonTrivial>, + ) : GenericPredicateBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -39,7 +39,7 @@ public sealed class GenericPredicateBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.GenericPredicateBox.And = try { And( - NonTrivial.read(reader) as NonTrivial>, + NonTrivial.read(reader) as NonTrivial>, ) } catch (ex: Exception) { throw wrapException(ex) @@ -60,8 +60,8 @@ public sealed class GenericPredicateBox : ModelEnum { * 'Or' variant */ public data class Or( - public val nonTrivial: NonTrivial>, - ) : GenericPredicateBox() { + public val nonTrivial: NonTrivial>, + ) : GenericPredicateBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -71,7 +71,7 @@ public sealed class GenericPredicateBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.GenericPredicateBox.Or = try { Or( - NonTrivial.read(reader) as NonTrivial>, + NonTrivial.read(reader) as NonTrivial>, ) } catch (ex: Exception) { throw wrapException(ex) @@ -92,8 +92,8 @@ public sealed class GenericPredicateBox : ModelEnum { * 'Not' variant */ public data class Not( - public val genericPredicateBox: GenericPredicateBox, - ) : GenericPredicateBox() { + public val genericPredicateBox: GenericPredicateBox, + ) : GenericPredicateBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -103,7 +103,7 @@ public sealed class GenericPredicateBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.GenericPredicateBox.Not = try { Not( - GenericPredicateBox.read(reader) as GenericPredicateBox, + GenericPredicateBox.read(reader) as GenericPredicateBox, ) } catch (ex: Exception) { throw wrapException(ex) @@ -124,8 +124,8 @@ public sealed class GenericPredicateBox : ModelEnum { * 'Raw' variant */ public data class Raw( - public val valuePredicate: ValuePredicate, - ) : GenericPredicateBox() { + public val queryOutputPredicate: QueryOutputPredicate, + ) : GenericPredicateBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : @@ -135,7 +135,7 @@ public sealed class GenericPredicateBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.GenericPredicateBox.Raw = try { Raw( - ValuePredicate.read(reader), + QueryOutputPredicate.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -145,7 +145,7 @@ public sealed class GenericPredicateBox : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.GenericPredicateBox.Raw, ): Unit = try { - ValuePredicate.write(writer, instance.valuePredicate) + QueryOutputPredicate.write(writer, instance.queryOutputPredicate) } 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/GrantBox.kt new file mode 100644 index 000000000..e59d56c41 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantBox.kt @@ -0,0 +1,142 @@ +// +// 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 + +/** + * GrantBox + * + * Generated from 'GrantBox' enum + */ +public sealed class GrantBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Permission' variant + */ + public data class Permission( + public val grantOfPermissionAndAccount: GrantOfPermissionAndAccount, + ) : GrantBox() { + 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.GrantBox.Permission = try { + Permission( + GrantOfPermissionAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.GrantBox.Permission, + ): Unit = try { + GrantOfPermissionAndAccount.write(writer, instance.grantOfPermissionAndAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Role' variant + */ + public data class Role( + public val grantOfRoleIdAndAccount: GrantOfRoleIdAndAccount, + ) : GrantBox() { + 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.GrantBox.Role = + try { + Role( + GrantOfRoleIdAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.GrantBox.Role, + ): Unit = try { + GrantOfRoleIdAndAccount.write(writer, instance.grantOfRoleIdAndAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'RolePermission' variant + */ + public data class RolePermission( + public val grantOfPermissionAndRole: GrantOfPermissionAndRole, + ) : GrantBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.GrantBox.RolePermission = try { + RolePermission( + GrantOfPermissionAndRole.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.GrantBox.RolePermission, + ): Unit = try { + GrantOfPermissionAndRole.write(writer, instance.grantOfPermissionAndRole) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): GrantBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Permission.read(reader) + 1 -> Role.read(reader) + 2 -> RolePermission.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: GrantBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Permission.write(writer, instance as Permission) + 1 -> Role.write(writer, instance as Role) + 2 -> RolePermission.write(writer, instance as RolePermission) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.kt deleted file mode 100644 index 08b3fac41..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantExpr.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 - -/** - * GrantExpr - * - * Generated from 'GrantExpr' regular structure - */ -public data class GrantExpr( - public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): GrantExpr = try { - GrantExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: GrantExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) - EvaluatesTo.write(writer, instance.destinationId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndAccount.kt new file mode 100644 index 000000000..89c3a0087 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndAccount.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 + +/** + * GrantOfPermissionAndAccount + * + * Generated from 'GrantOfPermissionAndAccount' regular structure + */ +public data class GrantOfPermissionAndAccount( + public val `object`: Permission, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): GrantOfPermissionAndAccount = try { + GrantOfPermissionAndAccount( + Permission.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: GrantOfPermissionAndAccount): Unit = try { + Permission.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndRole.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndRole.kt new file mode 100644 index 000000000..75269183a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfPermissionAndRole.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 + +/** + * GrantOfPermissionAndRole + * + * Generated from 'GrantOfPermissionAndRole' regular structure + */ +public data class GrantOfPermissionAndRole( + public val `object`: Permission, + public val destination: RoleId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): GrantOfPermissionAndRole = try { + GrantOfPermissionAndRole( + Permission.read(reader), + RoleId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: GrantOfPermissionAndRole): Unit = try { + Permission.write(writer, instance.`object`) + RoleId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfRoleIdAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfRoleIdAndAccount.kt new file mode 100644 index 000000000..549bb4de9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/GrantOfRoleIdAndAccount.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 + +/** + * GrantOfRoleIdAndAccount + * + * Generated from 'GrantOfRoleIdAndAccount' regular structure + */ +public data class GrantOfRoleIdAndAccount( + public val `object`: RoleId, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): GrantOfRoleIdAndAccount = try { + GrantOfRoleIdAndAccount( + RoleId.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: GrantOfRoleIdAndAccount): Unit = try { + RoleId.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Greater.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Greater.kt deleted file mode 100644 index c664b7127..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Greater.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 - -/** - * Greater - * - * Generated from 'Greater' regular structure - */ -public data class Greater( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Greater = try { - Greater( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Greater): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Hash.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Hash.kt index c6bc1a065..6b987937e 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Hash.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Hash.kt @@ -8,7 +8,10 @@ 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.ByteArray +import kotlin.Int import kotlin.Unit /** @@ -19,6 +22,15 @@ import kotlin.Unit public data class Hash( public val arrayOfU8: ByteArray, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Hash) return false + if (!arrayOfU8.contentEquals(other.arrayOfU8)) return false + return true + } + + override fun hashCode(): Int = arrayOfU8.contentHashCode() + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Hash = try { Hash( diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdBox.kt index 03bb48cb4..5271a7e82 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IdBox.kt @@ -252,21 +252,21 @@ public sealed class IdBox : ModelEnum { } /** - * 'PermissionTokenId' variant + * 'Permission' variant */ - public data class PermissionTokenId( - public val name: Name, + public data class Permission( + public val permission: jp.co.soramitsu.iroha2.generated.Permission, ) : IdBox() { 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.IdBox.PermissionTokenId = try { - PermissionTokenId( - Name.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.IdBox.Permission = try { + Permission( + jp.co.soramitsu.iroha2.generated.Permission.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -274,9 +274,9 @@ public sealed class IdBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.IdBox.PermissionTokenId, + instance: jp.co.soramitsu.iroha2.generated.IdBox.Permission, ): Unit = try { - Name.write(writer, instance.name) + jp.co.soramitsu.iroha2.generated.Permission.write(writer, instance.permission) } catch (ex: Exception) { throw wrapException(ex) } @@ -284,21 +284,21 @@ public sealed class IdBox : ModelEnum { } /** - * 'ParameterId' variant + * 'CustomParameterId' variant */ - public data class ParameterId( - public val parameterId: jp.co.soramitsu.iroha2.generated.ParameterId, + public data class CustomParameterId( + public val customParameterId: jp.co.soramitsu.iroha2.generated.CustomParameterId, ) : IdBox() { 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.IdBox.ParameterId = try { - ParameterId( - jp.co.soramitsu.iroha2.generated.ParameterId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.IdBox.CustomParameterId = try { + CustomParameterId( + jp.co.soramitsu.iroha2.generated.CustomParameterId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -306,9 +306,9 @@ public sealed class IdBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.IdBox.ParameterId, + instance: jp.co.soramitsu.iroha2.generated.IdBox.CustomParameterId, ): Unit = try { - jp.co.soramitsu.iroha2.generated.ParameterId.write(writer, instance.parameterId) + jp.co.soramitsu.iroha2.generated.CustomParameterId.write(writer, instance.customParameterId) } catch (ex: Exception) { throw wrapException(ex) } @@ -324,8 +324,8 @@ public sealed class IdBox : ModelEnum { 4 -> PeerId.read(reader) 5 -> TriggerId.read(reader) 6 -> RoleId.read(reader) - 7 -> PermissionTokenId.read(reader) - 8 -> ParameterId.read(reader) + 7 -> Permission.read(reader) + 8 -> CustomParameterId.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: IdBox) { @@ -338,8 +338,8 @@ public sealed class IdBox : ModelEnum { 4 -> PeerId.write(writer, instance as PeerId) 5 -> TriggerId.write(writer, instance as TriggerId) 6 -> RoleId.write(writer, instance as RoleId) - 7 -> PermissionTokenId.write(writer, instance as PermissionTokenId) - 8 -> ParameterId.write(writer, instance as ParameterId) + 7 -> Permission.write(writer, instance as Permission) + 8 -> CustomParameterId.write(writer, instance as CustomParameterId) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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 4b5159833..02a5a5a20 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 @@ -126,7 +126,7 @@ public sealed class IdentifiableBox : ModelEnum { * 'NewRole' variant */ public data class NewRole( - public val newRole: jp.co.soramitsu.iroha2.generated.NewRole, + public val role: jp.co.soramitsu.iroha2.generated.Role, ) : IdentifiableBox() { override fun discriminant(): Int = DISCRIMINANT @@ -137,7 +137,7 @@ public sealed class IdentifiableBox : ModelEnum { override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.IdentifiableBox.NewRole = try { NewRole( - jp.co.soramitsu.iroha2.generated.NewRole.read(reader), + jp.co.soramitsu.iroha2.generated.Role.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -147,7 +147,7 @@ public sealed class IdentifiableBox : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.IdentifiableBox.NewRole, ): Unit = try { - jp.co.soramitsu.iroha2.generated.NewRole.write(writer, instance.newRole) + jp.co.soramitsu.iroha2.generated.Role.write(writer, instance.role) } catch (ex: Exception) { throw wrapException(ex) } @@ -318,7 +318,7 @@ public sealed class IdentifiableBox : ModelEnum { * 'Trigger' variant */ public data class Trigger( - public val triggerOfTriggeringFilterBox: TriggerOfTriggeringFilterBox, + public val trigger: jp.co.soramitsu.iroha2.generated.Trigger, ) : 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( - TriggerOfTriggeringFilterBox.read(reader), + jp.co.soramitsu.iroha2.generated.Trigger.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 { - TriggerOfTriggeringFilterBox.write(writer, instance.triggerOfTriggeringFilterBox) + jp.co.soramitsu.iroha2.generated.Trigger.write(writer, instance.trigger) } catch (ex: Exception) { throw wrapException(ex) } @@ -379,21 +379,21 @@ public sealed class IdentifiableBox : ModelEnum { } /** - * 'Parameter' variant + * 'CustomParameter' variant */ - public data class Parameter( - public val parameter: jp.co.soramitsu.iroha2.generated.Parameter, + public data class CustomParameter( + public val customParameter: jp.co.soramitsu.iroha2.generated.CustomParameter, ) : IdentifiableBox() { 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.IdentifiableBox.Parameter = try { - Parameter( - jp.co.soramitsu.iroha2.generated.Parameter.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.IdentifiableBox.CustomParameter = try { + CustomParameter( + jp.co.soramitsu.iroha2.generated.CustomParameter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -401,9 +401,9 @@ public sealed class IdentifiableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.IdentifiableBox.Parameter, + instance: jp.co.soramitsu.iroha2.generated.IdentifiableBox.CustomParameter, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Parameter.write(writer, instance.parameter) + jp.co.soramitsu.iroha2.generated.CustomParameter.write(writer, instance.customParameter) } catch (ex: Exception) { throw wrapException(ex) } @@ -426,7 +426,7 @@ public sealed class IdentifiableBox : ModelEnum { 8 -> Asset.read(reader) 9 -> Trigger.read(reader) 10 -> Role.read(reader) - 11 -> Parameter.read(reader) + 11 -> CustomParameter.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: IdentifiableBox) { @@ -443,7 +443,7 @@ public sealed class IdentifiableBox : ModelEnum { 8 -> Asset.write(writer, instance as Asset) 9 -> Trigger.write(writer, instance as Trigger) 10 -> Role.write(writer, instance as Role) - 11 -> Parameter.write(writer, instance as Parameter) + 11 -> CustomParameter.write(writer, instance as CustomParameter) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/If.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/If.kt deleted file mode 100644 index a63bc5111..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/If.kt +++ /dev/null @@ -1,43 +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.Boolean -import kotlin.Unit - -/** - * If - * - * Generated from 'If' regular structure - */ -public data class If( - public val condition: EvaluatesTo, - public val then: EvaluatesTo, - public val otherwise: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): If = try { - If( - 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: If): Unit = try { - EvaluatesTo.write(writer, instance.condition) - EvaluatesTo.write(writer, instance.then) - EvaluatesTo.write(writer, instance.otherwise) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt index f71697e9d..da498696b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionBox.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * InstructionExpr + * InstructionBox * - * Generated from 'InstructionExpr' enum + * Generated from 'InstructionBox' enum */ -public sealed class InstructionExpr : ModelEnum { +public sealed class InstructionBox : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,18 +27,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Register' variant */ public data class Register( - public val registerExpr: RegisterExpr, - ) : InstructionExpr() { + public val registerBox: RegisterBox, + ) : InstructionBox() { 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.InstructionExpr.Register = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Register = try { Register( - RegisterExpr.read(reader), + RegisterBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Register, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Register, ): Unit = try { - RegisterExpr.write(writer, instance.registerExpr) + RegisterBox.write(writer, instance.registerBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -59,18 +59,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Unregister' variant */ public data class Unregister( - public val unregisterExpr: UnregisterExpr, - ) : InstructionExpr() { + public val unregisterBox: UnregisterBox, + ) : InstructionBox() { 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.InstructionExpr.Unregister = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Unregister = try { Unregister( - UnregisterExpr.read(reader), + UnregisterBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,9 +78,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Unregister, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Unregister, ): Unit = try { - UnregisterExpr.write(writer, instance.unregisterExpr) + UnregisterBox.write(writer, instance.unregisterBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -91,18 +91,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Mint' variant */ public data class Mint( - public val mintExpr: MintExpr, - ) : InstructionExpr() { + public val mintBox: MintBox, + ) : InstructionBox() { 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.InstructionExpr.Mint = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Mint = try { Mint( - MintExpr.read(reader), + MintBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -110,9 +110,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Mint, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Mint, ): Unit = try { - MintExpr.write(writer, instance.mintExpr) + MintBox.write(writer, instance.mintBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -123,18 +123,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Burn' variant */ public data class Burn( - public val burnExpr: BurnExpr, - ) : InstructionExpr() { + public val burnBox: BurnBox, + ) : InstructionBox() { 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.InstructionExpr.Burn = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Burn = try { Burn( - BurnExpr.read(reader), + BurnBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -142,9 +142,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Burn, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Burn, ): Unit = try { - BurnExpr.write(writer, instance.burnExpr) + BurnBox.write(writer, instance.burnBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -155,18 +155,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Transfer' variant */ public data class Transfer( - public val transferExpr: TransferExpr, - ) : InstructionExpr() { + public val transferBox: TransferBox, + ) : InstructionBox() { 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.InstructionExpr.Transfer = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Transfer = try { Transfer( - TransferExpr.read(reader), + TransferBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -174,105 +174,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Transfer, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Transfer, ): Unit = try { - TransferExpr.write(writer, instance.transferExpr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'If' variant - */ - public data class If( - public val conditionalExpr: ConditionalExpr, - ) : InstructionExpr() { - 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.InstructionExpr.If = try { - If( - ConditionalExpr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.If, - ): Unit = try { - ConditionalExpr.write(writer, instance.conditionalExpr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Pair' variant - */ - public data class Pair( - public val pairExpr: PairExpr, - ) : InstructionExpr() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Pair = try { - Pair( - PairExpr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Pair, - ): Unit = try { - PairExpr.write(writer, instance.pairExpr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Sequence' variant - */ - public data class Sequence( - public val sequenceExpr: SequenceExpr, - ) : InstructionExpr() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Sequence = try { - Sequence( - SequenceExpr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Sequence, - ): Unit = try { - SequenceExpr.write(writer, instance.sequenceExpr) + TransferBox.write(writer, instance.transferBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -283,18 +187,18 @@ public sealed class InstructionExpr : ModelEnum { * 'SetKeyValue' variant */ public data class SetKeyValue( - public val setKeyValueExpr: SetKeyValueExpr, - ) : InstructionExpr() { + public val setKeyValueBox: SetKeyValueBox, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 5 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.SetKeyValue = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.SetKeyValue = try { SetKeyValue( - SetKeyValueExpr.read(reader), + SetKeyValueBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -302,9 +206,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.SetKeyValue, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.SetKeyValue, ): Unit = try { - SetKeyValueExpr.write(writer, instance.setKeyValueExpr) + SetKeyValueBox.write(writer, instance.setKeyValueBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -315,18 +219,18 @@ public sealed class InstructionExpr : ModelEnum { * 'RemoveKeyValue' variant */ public data class RemoveKeyValue( - public val removeKeyValueExpr: RemoveKeyValueExpr, - ) : InstructionExpr() { + public val removeKeyValueBox: RemoveKeyValueBox, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 9 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.RemoveKeyValue = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.RemoveKeyValue = try { RemoveKeyValue( - RemoveKeyValueExpr.read(reader), + RemoveKeyValueBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -334,9 +238,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.RemoveKeyValue, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.RemoveKeyValue, ): Unit = try { - RemoveKeyValueExpr.write(writer, instance.removeKeyValueExpr) + RemoveKeyValueBox.write(writer, instance.removeKeyValueBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -347,18 +251,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Grant' variant */ public data class Grant( - public val grantExpr: GrantExpr, - ) : InstructionExpr() { + public val grantBox: GrantBox, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 10 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 7 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Grant = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Grant = try { Grant( - GrantExpr.read(reader), + GrantBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -366,9 +270,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Grant, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Grant, ): Unit = try { - GrantExpr.write(writer, instance.grantExpr) + GrantBox.write(writer, instance.grantBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -379,18 +283,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Revoke' variant */ public data class Revoke( - public val revokeExpr: RevokeExpr, - ) : InstructionExpr() { + public val revokeBox: RevokeBox, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 11 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 8 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Revoke = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Revoke = try { Revoke( - RevokeExpr.read(reader), + RevokeBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -398,9 +302,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Revoke, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Revoke, ): Unit = try { - RevokeExpr.write(writer, instance.revokeExpr) + RevokeBox.write(writer, instance.revokeBox) } catch (ex: Exception) { throw wrapException(ex) } @@ -411,18 +315,18 @@ public sealed class InstructionExpr : ModelEnum { * 'ExecuteTrigger' variant */ public data class ExecuteTrigger( - public val executeTriggerExpr: ExecuteTriggerExpr, - ) : InstructionExpr() { + public val executeTrigger: jp.co.soramitsu.iroha2.generated.ExecuteTrigger, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 12 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 9 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.ExecuteTrigger = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.ExecuteTrigger = try { ExecuteTrigger( - ExecuteTriggerExpr.read(reader), + jp.co.soramitsu.iroha2.generated.ExecuteTrigger.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -430,9 +334,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.ExecuteTrigger, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.ExecuteTrigger, ): Unit = try { - ExecuteTriggerExpr.write(writer, instance.executeTriggerExpr) + jp.co.soramitsu.iroha2.generated.ExecuteTrigger.write(writer, instance.executeTrigger) } catch (ex: Exception) { throw wrapException(ex) } @@ -443,50 +347,18 @@ public sealed class InstructionExpr : ModelEnum { * 'SetParameter' variant */ public data class SetParameter( - public val setParameterExpr: SetParameterExpr, - ) : InstructionExpr() { + public val setParameter: jp.co.soramitsu.iroha2.generated.SetParameter, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 13 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 10 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.SetParameter = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.SetParameter = try { SetParameter( - SetParameterExpr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.SetParameter, - ): Unit = try { - SetParameterExpr.write(writer, instance.setParameterExpr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'NewParameter' variant - */ - public data class NewParameter( - public val newParameterExpr: NewParameterExpr, - ) : InstructionExpr() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 14 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.NewParameter = try { - NewParameter( - NewParameterExpr.read(reader), + jp.co.soramitsu.iroha2.generated.SetParameter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -494,9 +366,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.NewParameter, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.SetParameter, ): Unit = try { - NewParameterExpr.write(writer, instance.newParameterExpr) + jp.co.soramitsu.iroha2.generated.SetParameter.write(writer, instance.setParameter) } catch (ex: Exception) { throw wrapException(ex) } @@ -507,18 +379,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Upgrade' variant */ public data class Upgrade( - public val upgradeExpr: UpgradeExpr, - ) : InstructionExpr() { + public val upgrade: jp.co.soramitsu.iroha2.generated.Upgrade, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 15 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 11 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Upgrade = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Upgrade = try { Upgrade( - UpgradeExpr.read(reader), + jp.co.soramitsu.iroha2.generated.Upgrade.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -526,9 +398,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Upgrade, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Upgrade, ): Unit = try { - UpgradeExpr.write(writer, instance.upgradeExpr) + jp.co.soramitsu.iroha2.generated.Upgrade.write(writer, instance.upgrade) } catch (ex: Exception) { throw wrapException(ex) } @@ -539,18 +411,18 @@ public sealed class InstructionExpr : ModelEnum { * 'Log' variant */ public data class Log( - public val logExpr: LogExpr, - ) : InstructionExpr() { + public val log: jp.co.soramitsu.iroha2.generated.Log, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 16 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 12 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Log = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Log = try { Log( - LogExpr.read(reader), + jp.co.soramitsu.iroha2.generated.Log.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -558,9 +430,9 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Log, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Log, ): Unit = try { - LogExpr.write(writer, instance.logExpr) + jp.co.soramitsu.iroha2.generated.Log.write(writer, instance.log) } catch (ex: Exception) { throw wrapException(ex) } @@ -568,21 +440,21 @@ public sealed class InstructionExpr : ModelEnum { } /** - * 'Fail' variant + * 'Custom' variant */ - public data class Fail( - public val fail: jp.co.soramitsu.iroha2.generated.Fail, - ) : InstructionExpr() { + public data class Custom( + public val customInstruction: CustomInstruction, + ) : InstructionBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 17 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 13 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExpr.Fail = try { - Fail( - jp.co.soramitsu.iroha2.generated.Fail.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionBox.Custom = try { + Custom( + CustomInstruction.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -590,17 +462,17 @@ public sealed class InstructionExpr : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExpr.Fail, + instance: jp.co.soramitsu.iroha2.generated.InstructionBox.Custom, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Fail.write(writer, instance.fail) + CustomInstruction.write(writer, instance.customInstruction) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): InstructionExpr = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): InstructionBox = when ( val discriminant = reader.readUByte() ) { @@ -609,22 +481,18 @@ public sealed class InstructionExpr : ModelEnum { 2 -> Mint.read(reader) 3 -> Burn.read(reader) 4 -> Transfer.read(reader) - 5 -> If.read(reader) - 6 -> Pair.read(reader) - 7 -> Sequence.read(reader) - 8 -> SetKeyValue.read(reader) - 9 -> RemoveKeyValue.read(reader) - 10 -> Grant.read(reader) - 11 -> Revoke.read(reader) - 12 -> ExecuteTrigger.read(reader) - 13 -> SetParameter.read(reader) - 14 -> NewParameter.read(reader) - 15 -> Upgrade.read(reader) - 16 -> Log.read(reader) - 17 -> Fail.read(reader) + 5 -> SetKeyValue.read(reader) + 6 -> RemoveKeyValue.read(reader) + 7 -> Grant.read(reader) + 8 -> Revoke.read(reader) + 9 -> ExecuteTrigger.read(reader) + 10 -> SetParameter.read(reader) + 11 -> Upgrade.read(reader) + 12 -> Log.read(reader) + 13 -> Custom.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: InstructionExpr) { + override fun write(writer: ScaleCodecWriter, instance: InstructionBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Register.write(writer, instance as Register) @@ -632,19 +500,15 @@ public sealed class InstructionExpr : ModelEnum { 2 -> Mint.write(writer, instance as Mint) 3 -> Burn.write(writer, instance as Burn) 4 -> Transfer.write(writer, instance as Transfer) - 5 -> If.write(writer, instance as If) - 6 -> Pair.write(writer, instance as Pair) - 7 -> Sequence.write(writer, instance as Sequence) - 8 -> SetKeyValue.write(writer, instance as SetKeyValue) - 9 -> RemoveKeyValue.write(writer, instance as RemoveKeyValue) - 10 -> Grant.write(writer, instance as Grant) - 11 -> Revoke.write(writer, instance as Revoke) - 12 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) - 13 -> SetParameter.write(writer, instance as SetParameter) - 14 -> NewParameter.write(writer, instance as NewParameter) - 15 -> Upgrade.write(writer, instance as Upgrade) - 16 -> Log.write(writer, instance as Log) - 17 -> Fail.write(writer, instance as Fail) + 5 -> SetKeyValue.write(writer, instance as SetKeyValue) + 6 -> RemoveKeyValue.write(writer, instance as RemoveKeyValue) + 7 -> Grant.write(writer, instance as Grant) + 8 -> Revoke.write(writer, instance as Revoke) + 9 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) + 10 -> SetParameter.write(writer, instance as SetParameter) + 11 -> Upgrade.write(writer, instance as Upgrade) + 12 -> Log.write(writer, instance as Log) + 13 -> Custom.write(writer, instance as Custom) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionEvaluationError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionEvaluationError.kt index a3b1b562f..1d78f7592 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionEvaluationError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionEvaluationError.kt @@ -24,39 +24,6 @@ public sealed class InstructionEvaluationError : ModelEnum { */ public abstract fun discriminant(): Int - /** - * 'Expression' variant - */ - public data class Expression( - public val evaluationError: EvaluationError, - ) : InstructionEvaluationError() { - 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.InstructionEvaluationError.Expression = try { - Expression( - EvaluationError.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionEvaluationError.Expression, - ): Unit = - try { - EvaluationError.write(writer, instance.evaluationError) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Unsupported' variant */ @@ -68,7 +35,7 @@ public sealed class InstructionEvaluationError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 1 + public const val DISCRIMINANT: Int = 0 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionEvaluationError.Unsupported = try { Unsupported( @@ -101,7 +68,7 @@ public sealed class InstructionEvaluationError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 2 + public const val DISCRIMINANT: Int = 1 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionEvaluationError.PermissionParameter = try { PermissionParameter( @@ -133,7 +100,7 @@ public sealed class InstructionEvaluationError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 3 + public const val DISCRIMINANT: Int = 2 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionEvaluationError.Type = try { Type( @@ -161,19 +128,17 @@ public sealed class InstructionEvaluationError : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Expression.read(reader) - 1 -> Unsupported.read(reader) - 2 -> PermissionParameter.read(reader) - 3 -> Type.read(reader) + 0 -> Unsupported.read(reader) + 1 -> PermissionParameter.read(reader) + 2 -> Type.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: InstructionEvaluationError) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Expression.write(writer, instance as Expression) - 1 -> Unsupported.write(writer, instance as Unsupported) - 2 -> PermissionParameter.write(writer, instance as PermissionParameter) - 3 -> Type.write(writer, instance as Type) + 0 -> Unsupported.write(writer, instance as Unsupported) + 1 -> PermissionParameter.write(writer, instance as PermissionParameter) + 2 -> Type.write(writer, instance as Type) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionError.kt index 6b3921c58..760bb061c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionExecutionError.kt @@ -251,70 +251,6 @@ public sealed class InstructionExecutionError : ModelEnum { } } - /** - * 'Metadata' variant - */ - public data class Metadata( - public val metadataError: MetadataError, - ) : InstructionExecutionError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExecutionError.Metadata = try { - Metadata( - MetadataError.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExecutionError.Metadata, - ): Unit = try { - MetadataError.write(writer, instance.metadataError) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Fail' variant - */ - public data class Fail( - public val string: String, - ) : InstructionExecutionError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExecutionError.Fail = try { - Fail( - reader.readString(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionExecutionError.Fail, - ): Unit = try { - writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'InvalidParameter' variant */ @@ -326,7 +262,7 @@ public sealed class InstructionExecutionError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 9 + public const val DISCRIMINANT: Int = 7 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExecutionError.InvalidParameter = try { InvalidParameter( @@ -358,7 +294,7 @@ public sealed class InstructionExecutionError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 10 + public const val DISCRIMINANT: Int = 8 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionExecutionError.InvariantViolation = try { InvariantViolation( @@ -393,10 +329,8 @@ public sealed class InstructionExecutionError : ModelEnum { 4 -> Repetition.read(reader) 5 -> Mintability.read(reader) 6 -> Math.read(reader) - 7 -> Metadata.read(reader) - 8 -> Fail.read(reader) - 9 -> InvalidParameter.read(reader) - 10 -> InvariantViolation.read(reader) + 7 -> InvalidParameter.read(reader) + 8 -> InvariantViolation.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: InstructionExecutionError) { @@ -409,10 +343,8 @@ public sealed class InstructionExecutionError : ModelEnum { 4 -> Repetition.write(writer, instance as Repetition) 5 -> Mintability.write(writer, instance as Mintability) 6 -> Math.write(writer, instance as Math) - 7 -> Metadata.write(writer, instance as Metadata) - 8 -> Fail.write(writer, instance as Fail) - 9 -> InvalidParameter.write(writer, instance as InvalidParameter) - 10 -> InvariantViolation.write(writer, instance as InvariantViolation) + 7 -> InvalidParameter.write(writer, instance as InvalidParameter) + 8 -> InvariantViolation.write(writer, instance as InvariantViolation) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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 3fcf06d2a..96f0c4d1b 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: InstructionExpr, + public val instruction: InstructionBox, public val reason: String, ) { public companion object : @@ -25,7 +25,7 @@ public data class InstructionExecutionFail( ScaleWriter { override fun read(reader: ScaleCodecReader): InstructionExecutionFail = try { InstructionExecutionFail( - InstructionExpr.read(reader), + InstructionBox.read(reader), reader.readString(), ) } catch (ex: Exception) { @@ -33,7 +33,7 @@ public data class InstructionExecutionFail( } override fun write(writer: ScaleCodecWriter, instance: InstructionExecutionFail): Unit = try { - InstructionExpr.write(writer, instance.instruction) + InstructionBox.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/InstructionType.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionType.kt index fc003c261..cd9cc929b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionType.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InstructionType.kt @@ -31,19 +31,15 @@ public sealed class InstructionType : ModelEnum { is Mint -> Mint.equals(this, other) is Burn -> Burn.equals(this, other) is Transfer -> Transfer.equals(this, other) - is If -> If.equals(this, other) - is Pair -> Pair.equals(this, other) - is Sequence -> Sequence.equals(this, other) is SetKeyValue -> SetKeyValue.equals(this, other) is RemoveKeyValue -> RemoveKeyValue.equals(this, other) is Grant -> Grant.equals(this, other) is Revoke -> Revoke.equals(this, other) is ExecuteTrigger -> ExecuteTrigger.equals(this, other) is SetParameter -> SetParameter.equals(this, other) - is NewParameter -> NewParameter.equals(this, other) is Upgrade -> Upgrade.equals(this, other) is Log -> Log.equals(this, other) - is Fail -> Fail.equals(this, other) + is Custom -> Custom.equals(this, other) else -> super.equals(other) } override fun hashCode(): Int = when (this) { @@ -52,19 +48,15 @@ public sealed class InstructionType : ModelEnum { is Mint -> Mint.hashCode() is Burn -> Burn.hashCode() is Transfer -> Transfer.hashCode() - is If -> If.hashCode() - is Pair -> Pair.hashCode() - is Sequence -> Sequence.hashCode() is SetKeyValue -> SetKeyValue.hashCode() is RemoveKeyValue -> RemoveKeyValue.hashCode() is Grant -> Grant.hashCode() is Revoke -> Revoke.hashCode() is ExecuteTrigger -> ExecuteTrigger.hashCode() is SetParameter -> SetParameter.hashCode() - is NewParameter -> NewParameter.hashCode() is Upgrade -> Upgrade.hashCode() is Log -> Log.hashCode() - is Fail -> Fail.hashCode() + is Custom -> Custom.hashCode() else -> super.hashCode() } /** @@ -237,108 +229,6 @@ public sealed class InstructionType : ModelEnum { } } - /** - * 'If' variant - */ - public class If : InstructionType() { - 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.InstructionType.If = try { - If() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionType.If, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.InstructionType.If, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".InstructionType.If".hashCode() - } - } - - /** - * 'Pair' variant - */ - public class Pair : InstructionType() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Pair = try { - Pair() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionType.Pair, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.InstructionType.Pair, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".InstructionType.Pair".hashCode() - } - } - - /** - * 'Sequence' variant - */ - public class Sequence : InstructionType() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Sequence = try { - Sequence() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionType.Sequence, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.InstructionType.Sequence, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".InstructionType.Sequence".hashCode() - } - } - /** * 'SetKeyValue' variant */ @@ -348,7 +238,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 8 + public const val DISCRIMINANT: Int = 5 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.SetKeyValue = try { SetKeyValue() @@ -382,7 +272,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 9 + public const val DISCRIMINANT: Int = 6 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.RemoveKeyValue = try { RemoveKeyValue() @@ -419,7 +309,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 10 + public const val DISCRIMINANT: Int = 7 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Grant = try { Grant() @@ -453,7 +343,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 11 + public const val DISCRIMINANT: Int = 8 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Revoke = try { Revoke() @@ -487,7 +377,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 12 + public const val DISCRIMINANT: Int = 9 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.ExecuteTrigger = try { ExecuteTrigger() @@ -524,7 +414,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 13 + public const val DISCRIMINANT: Int = 10 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.SetParameter = try { SetParameter() @@ -552,43 +442,6 @@ public sealed class InstructionType : ModelEnum { } } - /** - * 'NewParameter' variant - */ - public class NewParameter : InstructionType() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 14 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.NewParameter = try { - NewParameter() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionType.NewParameter, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.InstructionType.NewParameter, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".InstructionType.NewParameter".hashCode() - } - } - /** * 'Upgrade' variant */ @@ -598,7 +451,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 15 + public const val DISCRIMINANT: Int = 11 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Upgrade = try { Upgrade() @@ -632,7 +485,7 @@ public sealed class InstructionType : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 16 + public const val DISCRIMINANT: Int = 12 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Log = try { Log() @@ -658,36 +511,36 @@ public sealed class InstructionType : ModelEnum { } /** - * 'Fail' variant + * 'Custom' variant */ - public class Fail : InstructionType() { + public class Custom : InstructionType() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 17 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 13 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Fail = try { - Fail() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InstructionType.Custom = try { + Custom() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InstructionType.Fail, + instance: jp.co.soramitsu.iroha2.generated.InstructionType.Custom, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.InstructionType.Fail, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.InstructionType.Custom, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".InstructionType.Fail".hashCode() + override fun hashCode(): Int = ".InstructionType.Custom".hashCode() } } @@ -701,19 +554,15 @@ public sealed class InstructionType : ModelEnum { 2 -> Mint.read(reader) 3 -> Burn.read(reader) 4 -> Transfer.read(reader) - 5 -> If.read(reader) - 6 -> Pair.read(reader) - 7 -> Sequence.read(reader) - 8 -> SetKeyValue.read(reader) - 9 -> RemoveKeyValue.read(reader) - 10 -> Grant.read(reader) - 11 -> Revoke.read(reader) - 12 -> ExecuteTrigger.read(reader) - 13 -> SetParameter.read(reader) - 14 -> NewParameter.read(reader) - 15 -> Upgrade.read(reader) - 16 -> Log.read(reader) - 17 -> Fail.read(reader) + 5 -> SetKeyValue.read(reader) + 6 -> RemoveKeyValue.read(reader) + 7 -> Grant.read(reader) + 8 -> Revoke.read(reader) + 9 -> ExecuteTrigger.read(reader) + 10 -> SetParameter.read(reader) + 11 -> Upgrade.read(reader) + 12 -> Log.read(reader) + 13 -> Custom.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: InstructionType) { @@ -724,19 +573,15 @@ public sealed class InstructionType : ModelEnum { 2 -> Mint.write(writer, instance as Mint) 3 -> Burn.write(writer, instance as Burn) 4 -> Transfer.write(writer, instance as Transfer) - 5 -> If.write(writer, instance as If) - 6 -> Pair.write(writer, instance as Pair) - 7 -> Sequence.write(writer, instance as Sequence) - 8 -> SetKeyValue.write(writer, instance as SetKeyValue) - 9 -> RemoveKeyValue.write(writer, instance as RemoveKeyValue) - 10 -> Grant.write(writer, instance as Grant) - 11 -> Revoke.write(writer, instance as Revoke) - 12 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) - 13 -> SetParameter.write(writer, instance as SetParameter) - 14 -> NewParameter.write(writer, instance as NewParameter) - 15 -> Upgrade.write(writer, instance as Upgrade) - 16 -> Log.write(writer, instance as Log) - 17 -> Fail.write(writer, instance as Fail) + 5 -> SetKeyValue.write(writer, instance as SetKeyValue) + 6 -> RemoveKeyValue.write(writer, instance as RemoveKeyValue) + 7 -> Grant.write(writer, instance as Grant) + 8 -> Revoke.write(writer, instance as Revoke) + 9 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) + 10 -> SetParameter.write(writer, instance as SetParameter) + 11 -> Upgrade.write(writer, instance as Upgrade) + 12 -> Log.write(writer, instance as Log) + 13 -> Custom.write(writer, instance as Custom) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu16.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu16.kt deleted file mode 100644 index a6697b572..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu16.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.Int -import kotlin.Unit - -/** - * IntervalOfu16 - * - * Generated from 'IntervalOfu16' regular structure - */ -public data class IntervalOfu16( - public val start: Int, - public val limit: Int, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): IntervalOfu16 = try { - IntervalOfu16( - reader.readUint16(), - reader.readUint16(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: IntervalOfu16): Unit = try { - writer.writeUint16(instance.start) - writer.writeUint16(instance.limit) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu8.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu8.kt deleted file mode 100644 index ef48fb7f4..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/IntervalOfu8.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.Short -import kotlin.Unit - -/** - * IntervalOfu8 - * - * Generated from 'IntervalOfu8' regular structure - */ -public data class IntervalOfu8( - public val start: Short, - public val limit: Short, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): IntervalOfu8 = try { - IntervalOfu8( - reader.readUByte().toShort(), - reader.readUByte().toShort(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: IntervalOfu8): Unit = try { - writer.writeUByte(instance.start) - writer.writeUByte(instance.limit) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InvalidParameterError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InvalidParameterError.kt index 1dfc266a3..55914c99b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InvalidParameterError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/InvalidParameterError.kt @@ -27,11 +27,11 @@ public sealed class InvalidParameterError : ModelEnum { public abstract fun discriminant(): Int override fun equals(other: Any?): Boolean = when (this) { - is NameLength -> NameLength.equals(this, other) + is TimeTriggerInThePast -> TimeTriggerInThePast.equals(this, other) else -> super.equals(other) } override fun hashCode(): Int = when (this) { - is NameLength -> NameLength.hashCode() + is TimeTriggerInThePast -> TimeTriggerInThePast.hashCode() else -> super.hashCode() } /** @@ -67,39 +67,39 @@ public sealed class InvalidParameterError : ModelEnum { } /** - * 'NameLength' variant + * 'TimeTriggerInThePast' variant */ - public class NameLength : InvalidParameterError() { + public class TimeTriggerInThePast : InvalidParameterError() { 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.InvalidParameterError.NameLength = try { - NameLength() + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.InvalidParameterError.TimeTriggerInThePast = try { + TimeTriggerInThePast() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.InvalidParameterError.NameLength, + instance: jp.co.soramitsu.iroha2.generated.InvalidParameterError.TimeTriggerInThePast, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } public fun equals( - o1: jp.co.soramitsu.iroha2.generated.InvalidParameterError.NameLength, + o1: jp.co.soramitsu.iroha2.generated.InvalidParameterError.TimeTriggerInThePast, o2: Any?, ): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".InvalidParameterError.NameLength".hashCode() + override fun hashCode(): Int = ".InvalidParameterError.TimeTriggerInThePast".hashCode() } } @@ -109,14 +109,14 @@ public sealed class InvalidParameterError : ModelEnum { reader.readUByte() ) { 0 -> Wasm.read(reader) - 1 -> NameLength.read(reader) + 1 -> TimeTriggerInThePast.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: InvalidParameterError) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Wasm.write(writer, instance as Wasm) - 1 -> NameLength.write(writer, instance as NameLength) + 1 -> TimeTriggerInThePast.write(writer, instance as TimeTriggerInThePast) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Addr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Addr.kt index 8dd7362b5..ff92ed36c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Addr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Addr.kt @@ -8,7 +8,10 @@ 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.ByteArray +import kotlin.Int import kotlin.Unit /** @@ -19,6 +22,15 @@ import kotlin.Unit public data class Ipv4Addr( public val arrayOfU8: ByteArray, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Ipv4Addr) return false + if (!arrayOfU8.contentEquals(other.arrayOfU8)) return false + return true + } + + override fun hashCode(): Int = arrayOfU8.contentHashCode() + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Ipv4Addr = try { Ipv4Addr( diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Predicate.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Predicate.kt deleted file mode 100644 index 4b6080f17..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv4Predicate.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.Array -import kotlin.Unit - -/** - * Ipv4Predicate - * - * Generated from 'Ipv4Predicate' regular structure - */ -public data class Ipv4Predicate( - public val arrayOfIntervalOfu8: Array, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Ipv4Predicate = try { - Ipv4Predicate( - reader.readArray(4) { IntervalOfu8.read(reader) }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Ipv4Predicate): Unit = try { - instance.arrayOfIntervalOfu8.forEach { value -> - IntervalOfu8.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv6Predicate.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv6Predicate.kt deleted file mode 100644 index 3dfbb26b9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Ipv6Predicate.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.Array -import kotlin.Unit - -/** - * Ipv6Predicate - * - * Generated from 'Ipv6Predicate' regular structure - */ -public data class Ipv6Predicate( - public val arrayOfIntervalOfu16: Array, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Ipv6Predicate = try { - Ipv6Predicate( - reader.readArray(8) { IntervalOfu16.read(reader) }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Ipv6Predicate): Unit = try { - instance.arrayOfIntervalOfu16.forEach { value -> - IntervalOfu16.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Less.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Less.kt deleted file mode 100644 index 668a47949..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Less.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 - -/** - * Less - * - * Generated from 'Less' regular structure - */ -public data class Less( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Less = try { - Less( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Less): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Limits.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Log.kt similarity index 53% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Limits.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Log.kt index 3699915e0..5f02f1f83 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Limits.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Log.kt @@ -8,31 +8,31 @@ 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.Long +import kotlin.String import kotlin.Unit /** - * Limits + * Log * - * Generated from 'Limits' regular structure + * Generated from 'Log' regular structure */ -public data class Limits( - public val maxLen: Long, - public val maxEntryByteSize: Long, +public data class Log( + public val level: Level, + public val msg: String, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Limits = try { - Limits( - reader.readUint32(), - reader.readUint32(), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Log = try { + Log( + Level.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Limits): Unit = try { - writer.writeUint32(instance.maxLen) - writer.writeUint32(instance.maxEntryByteSize) + override fun write(writer: ScaleCodecWriter, instance: Log): Unit = try { + Level.write(writer, instance.level) + writer.writeAsList(instance.msg.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.kt deleted file mode 100644 index f6c2d8b0c..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/LogExpr.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.String -import kotlin.Unit - -/** - * LogExpr - * - * Generated from 'LogExpr' regular structure - */ -public data class LogExpr( - public val level: EvaluatesTo, - public val msg: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): LogExpr = try { - LogExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: LogExpr): Unit = try { - EvaluatesTo.write(writer, instance.level) - EvaluatesTo.write(writer, instance.msg) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MathError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MathError.kt index 5414de899..e3ec6fe97 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MathError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MathError.kt @@ -249,42 +249,6 @@ public sealed class MathError : ModelEnum { } } - /** - * 'BinaryOpIncompatibleNumericValueTypes' variant - */ - public data class BinaryOpIncompatibleNumericValueTypes( - public val binaryOpIncompatibleNumericValueTypesError: - BinaryOpIncompatibleNumericValueTypesError, - ) : MathError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.MathError.BinaryOpIncompatibleNumericValueTypes = try { - BinaryOpIncompatibleNumericValueTypes( - BinaryOpIncompatibleNumericValueTypesError.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MathError.BinaryOpIncompatibleNumericValueTypes, - ): Unit = try { - BinaryOpIncompatibleNumericValueTypesError.write( - writer, - instance.binaryOpIncompatibleNumericValueTypesError, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'FixedPointConversion' variant */ @@ -296,7 +260,7 @@ public sealed class MathError : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 7 + public const val DISCRIMINANT: Int = 6 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.MathError.FixedPointConversion = try { FixedPointConversion( @@ -328,8 +292,7 @@ public sealed class MathError : ModelEnum { 3 -> NegativeValue.read(reader) 4 -> DomainViolation.read(reader) 5 -> Unknown.read(reader) - 6 -> BinaryOpIncompatibleNumericValueTypes.read(reader) - 7 -> FixedPointConversion.read(reader) + 6 -> FixedPointConversion.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: MathError) { @@ -341,12 +304,7 @@ public sealed class MathError : ModelEnum { 3 -> NegativeValue.write(writer, instance as NegativeValue) 4 -> DomainViolation.write(writer, instance as DomainViolation) 5 -> Unknown.write(writer, instance as Unknown) - 6 -> BinaryOpIncompatibleNumericValueTypes.write( - writer, - instance as - BinaryOpIncompatibleNumericValueTypes, - ) - 7 -> FixedPointConversion.write(writer, instance as FixedPointConversion) + 6 -> FixedPointConversion.write(writer, instance as FixedPointConversion) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Metadata.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Metadata.kt index d686dd02a..528ddc575 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Metadata.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Metadata.kt @@ -9,6 +9,7 @@ import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.comparator import jp.co.soramitsu.iroha2.wrapException +import kotlin.String import kotlin.Unit import kotlin.collections.Map @@ -18,24 +19,24 @@ import kotlin.collections.Map * Generated from 'Metadata' regular structure */ public data class Metadata( - public val map: Map, + public val sortedMapOfName: Map, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Metadata = try { Metadata( - reader.readMap(reader.readCompactInt(), { Name.read(reader) }, { Value.read(reader) }), + reader.readMap(reader.readCompactInt(), { Name.read(reader) }, { reader.readString() }), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: Metadata): Unit = try { - writer.writeCompact(instance.map.size) - instance.map.toSortedMap( + writer.writeCompact(instance.sortedMapOfName.size) + instance.sortedMapOfName.toSortedMap( Name.comparator(), ).forEach { (key, value) -> Name.write(writer, key) - Value.write(writer, value) + writer.writeAsList(value.toByteArray(Charsets.UTF_8)) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAccountId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAccountId.kt index dc21d2cb1..6e8a77ace 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAccountId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAccountId.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -16,9 +17,9 @@ import kotlin.Unit * Generated from 'MetadataChangedOfAccountId' regular structure */ public data class MetadataChangedOfAccountId( - public val targetId: AccountId, + public val target: AccountId, public val key: Name, - public val `value`: Value, + public val `value`: String, ) { public companion object : ScaleReader, @@ -27,16 +28,16 @@ public data class MetadataChangedOfAccountId( MetadataChangedOfAccountId( AccountId.read(reader), Name.read(reader), - Value.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: MetadataChangedOfAccountId): Unit = try { - AccountId.write(writer, instance.targetId) + AccountId.write(writer, instance.target) Name.write(writer, instance.key) - Value.write(writer, instance.`value`) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetDefinitionId.kt index 152d8f64f..dca636649 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetDefinitionId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetDefinitionId.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -16,9 +17,9 @@ import kotlin.Unit * Generated from 'MetadataChangedOfAssetDefinitionId' regular structure */ public data class MetadataChangedOfAssetDefinitionId( - public val targetId: AssetDefinitionId, + public val target: AssetDefinitionId, public val key: Name, - public val `value`: Value, + public val `value`: String, ) { public companion object : ScaleReader, @@ -27,16 +28,16 @@ public data class MetadataChangedOfAssetDefinitionId( MetadataChangedOfAssetDefinitionId( AssetDefinitionId.read(reader), Name.read(reader), - Value.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: MetadataChangedOfAssetDefinitionId): Unit = try { - AssetDefinitionId.write(writer, instance.targetId) + AssetDefinitionId.write(writer, instance.target) Name.write(writer, instance.key) - Value.write(writer, instance.`value`) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetId.kt index 20418d646..dd84cede1 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfAssetId.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -16,9 +17,9 @@ import kotlin.Unit * Generated from 'MetadataChangedOfAssetId' regular structure */ public data class MetadataChangedOfAssetId( - public val targetId: AssetId, + public val target: AssetId, public val key: Name, - public val `value`: Value, + public val `value`: String, ) { public companion object : ScaleReader, @@ -27,16 +28,16 @@ public data class MetadataChangedOfAssetId( MetadataChangedOfAssetId( AssetId.read(reader), Name.read(reader), - Value.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: MetadataChangedOfAssetId): Unit = try { - AssetId.write(writer, instance.targetId) + AssetId.write(writer, instance.target) Name.write(writer, instance.key) - Value.write(writer, instance.`value`) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfDomainId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfDomainId.kt index c7dfe45fa..f3be34eeb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfDomainId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfDomainId.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -16,9 +17,9 @@ import kotlin.Unit * Generated from 'MetadataChangedOfDomainId' regular structure */ public data class MetadataChangedOfDomainId( - public val targetId: DomainId, + public val target: DomainId, public val key: Name, - public val `value`: Value, + public val `value`: String, ) { public companion object : ScaleReader, @@ -27,16 +28,16 @@ public data class MetadataChangedOfDomainId( MetadataChangedOfDomainId( DomainId.read(reader), Name.read(reader), - Value.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: MetadataChangedOfDomainId): Unit = try { - DomainId.write(writer, instance.targetId) + DomainId.write(writer, instance.target) Name.write(writer, instance.key) - Value.write(writer, instance.`value`) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfTriggerId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfTriggerId.kt index d04ab9069..7145c306b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfTriggerId.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataChangedOfTriggerId.kt @@ -8,6 +8,7 @@ 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.String import kotlin.Unit /** @@ -16,9 +17,9 @@ import kotlin.Unit * Generated from 'MetadataChangedOfTriggerId' regular structure */ public data class MetadataChangedOfTriggerId( - public val targetId: TriggerId, + public val target: TriggerId, public val key: Name, - public val `value`: Value, + public val `value`: String, ) { public companion object : ScaleReader, @@ -27,16 +28,16 @@ public data class MetadataChangedOfTriggerId( MetadataChangedOfTriggerId( TriggerId.read(reader), Name.read(reader), - Value.read(reader), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: MetadataChangedOfTriggerId): Unit = try { - TriggerId.write(writer, instance.targetId) + TriggerId.write(writer, instance.target) Name.write(writer, instance.key) - Value.write(writer, instance.`value`) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataError.kt deleted file mode 100644 index da3fc80fb..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataError.kt +++ /dev/null @@ -1,221 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * MetadataError - * - * Generated from 'MetadataError' enum - */ -public sealed class MetadataError : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is EmptyPath -> EmptyPath.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is EmptyPath -> EmptyPath.hashCode() - else -> super.hashCode() } - - /** - * 'EntryTooBig' variant - */ - public data class EntryTooBig( - public val sizeError: SizeError, - ) : MetadataError() { - 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.MetadataError.EntryTooBig = try { - EntryTooBig( - SizeError.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MetadataError.EntryTooBig, - ): Unit = try { - SizeError.write(writer, instance.sizeError) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'OverallSize' variant - */ - public data class OverallSize( - public val sizeError: SizeError, - ) : MetadataError() { - 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.MetadataError.OverallSize = try { - OverallSize( - SizeError.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MetadataError.OverallSize, - ): Unit = try { - SizeError.write(writer, instance.sizeError) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'EmptyPath' variant - */ - public class EmptyPath : MetadataError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.MetadataError.EmptyPath = try { - EmptyPath() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MetadataError.EmptyPath, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.MetadataError.EmptyPath, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".MetadataError.EmptyPath".hashCode() - } - } - - /** - * 'MissingSegment' variant - */ - public data class MissingSegment( - public val name: Name, - ) : MetadataError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.MetadataError.MissingSegment = try { - MissingSegment( - Name.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MetadataError.MissingSegment, - ): Unit = try { - Name.write(writer, instance.name) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'InvalidSegment' variant - */ - public data class InvalidSegment( - public val name: Name, - ) : MetadataError() { - 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.MetadataError.InvalidSegment = try { - InvalidSegment( - Name.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.MetadataError.InvalidSegment, - ): Unit = try { - Name.write(writer, instance.name) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): MetadataError = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> EntryTooBig.read(reader) - 1 -> OverallSize.read(reader) - 2 -> EmptyPath.read(reader) - 3 -> MissingSegment.read(reader) - 4 -> InvalidSegment.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: MetadataError) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> EntryTooBig.write(writer, instance as EntryTooBig) - 1 -> OverallSize.write(writer, instance as OverallSize) - 2 -> EmptyPath.write(writer, instance as EmptyPath) - 3 -> MissingSegment.write(writer, instance as MissingSegment) - 4 -> InvalidSegment.write(writer, instance as InvalidSegment) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataPredicateBox.kt new file mode 100644 index 000000000..1c99d97cd --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MetadataPredicateBox.kt @@ -0,0 +1,37 @@ +// +// 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 kotlin.Int + +/** + * MetadataPredicateBox + * + * Generated from 'MetadataPredicateBox' enum + */ +public sealed class MetadataPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): MetadataPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: MetadataPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} 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/MintBox.kt new file mode 100644 index 000000000..dad362578 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintBox.kt @@ -0,0 +1,108 @@ +// +// 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 + +/** + * MintBox + * + * Generated from 'MintBox' enum + */ +public sealed class MintBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Asset' variant + */ + public data class Asset( + public val mintOfNumericAndAsset: MintOfNumericAndAsset, + ) : MintBox() { + 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.MintBox.Asset = + try { + Asset( + MintOfNumericAndAsset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.MintBox.Asset, + ): Unit = try { + MintOfNumericAndAsset.write(writer, instance.mintOfNumericAndAsset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'TriggerRepetitions' variant + */ + public data class TriggerRepetitions( + public val mintOfu32AndTrigger: MintOfu32AndTrigger, + ) : MintBox() { + 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.MintBox.TriggerRepetitions = try { + TriggerRepetitions( + MintOfu32AndTrigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.MintBox.TriggerRepetitions, + ): Unit = try { + MintOfu32AndTrigger.write(writer, instance.mintOfu32AndTrigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): MintBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Asset.read(reader) + 1 -> TriggerRepetitions.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: MintBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Asset.write(writer, instance as Asset) + 1 -> TriggerRepetitions.write(writer, instance as TriggerRepetitions) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.kt deleted file mode 100644 index 18b99bddf..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintExpr.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 - -/** - * MintExpr - * - * Generated from 'MintExpr' regular structure - */ -public data class MintExpr( - public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): MintExpr = try { - MintExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: MintExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) - EvaluatesTo.write(writer, instance.destinationId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfNumericAndAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfNumericAndAsset.kt new file mode 100644 index 000000000..bfb7c849b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfNumericAndAsset.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 + +/** + * MintOfNumericAndAsset + * + * Generated from 'MintOfNumericAndAsset' regular structure + */ +public data class MintOfNumericAndAsset( + public val `object`: Numeric, + public val destination: AssetId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): MintOfNumericAndAsset = try { + MintOfNumericAndAsset( + Numeric.read(reader), + AssetId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: MintOfNumericAndAsset): Unit = try { + Numeric.write(writer, instance.`object`) + AssetId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfu32AndTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfu32AndTrigger.kt new file mode 100644 index 000000000..35f188325 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MintOfu32AndTrigger.kt @@ -0,0 +1,40 @@ +// +// 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.Long +import kotlin.Unit + +/** + * MintOfu32AndTrigger + * + * Generated from 'MintOfu32AndTrigger' regular structure + */ +public data class MintOfu32AndTrigger( + public val `object`: Long, + public val destination: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): MintOfu32AndTrigger = try { + MintOfu32AndTrigger( + reader.readUint32(), + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: MintOfu32AndTrigger): Unit = try { + writer.writeUint32(instance.`object`) + TriggerId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mod.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mismatch.kt similarity index 50% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mod.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mismatch.kt index db17fbd57..081ad703b 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mod.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Mismatch.kt @@ -8,30 +8,31 @@ 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 /** - * Mod + * Mismatch * - * Generated from 'Mod' regular structure + * Generated from 'Mismatch' regular structure */ -public data class Mod( - public val left: EvaluatesTo, - public val right: EvaluatesTo, +public data class Mismatch( + public val expected: AssetType, + public val `actual`: AssetType, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Mod = try { - Mod( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader>, ScaleWriter> { + override fun read(reader: ScaleCodecReader): Mismatch = try { + Mismatch( + AssetType.read(reader), + AssetType.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Mod): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) + override fun write(writer: ScaleCodecWriter, instance: Mismatch): Unit = try { + AssetType.write(writer, instance.expected) + AssetType.write(writer, instance.`actual`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetDefinitionId.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetDefinitionId.kt deleted file mode 100644 index 622ee1af4..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetDefinitionId.kt +++ /dev/null @@ -1,41 +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 - -/** - * MismatchOfAssetDefinitionId - * - * Generated from 'MismatchOfAssetDefinitionId' regular structure - */ -public data class MismatchOfAssetDefinitionId( - public val expected: AssetDefinitionId, - public val `actual`: AssetDefinitionId, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): MismatchOfAssetDefinitionId = try { - MismatchOfAssetDefinitionId( - AssetDefinitionId.read(reader), - AssetDefinitionId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: MismatchOfAssetDefinitionId): Unit = try { - AssetDefinitionId.write(writer, instance.expected) - AssetDefinitionId.write(writer, instance.`actual`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetValueType.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetValueType.kt deleted file mode 100644 index acb3a920e..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfAssetValueType.kt +++ /dev/null @@ -1,41 +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 - -/** - * MismatchOfAssetValueType - * - * Generated from 'MismatchOfAssetValueType' regular structure - */ -public data class MismatchOfAssetValueType( - public val expected: AssetValueType, - public val `actual`: AssetValueType, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): MismatchOfAssetValueType = try { - MismatchOfAssetValueType( - AssetValueType.read(reader), - AssetValueType.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: MismatchOfAssetValueType): Unit = try { - AssetValueType.write(writer, instance.expected) - AssetValueType.write(writer, instance.`actual`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfValue.kt deleted file mode 100644 index 30c59e1c1..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/MismatchOfValue.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 - -/** - * MismatchOfValue - * - * Generated from 'MismatchOfValue' regular structure - */ -public data class MismatchOfValue( - public val expected: Value, - public val `actual`: Value, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): MismatchOfValue = try { - MismatchOfValue( - Value.read(reader), - Value.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: MismatchOfValue): Unit = try { - Value.write(writer, instance.expected) - Value.write(writer, instance.`actual`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Multiply.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Multiply.kt deleted file mode 100644 index 1f1a8c7db..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Multiply.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 - -/** - * Multiply - * - * Generated from 'Multiply' regular structure - */ -public data class Multiply( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Multiply = try { - Multiply( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Multiply): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAccount.kt index b43e6508b..048a59580 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAccount.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAccount.kt @@ -7,10 +7,8 @@ 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.comparator import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit -import kotlin.collections.List /** * NewAccount @@ -19,14 +17,12 @@ import kotlin.collections.List */ public data class NewAccount( public val id: AccountId, - public val signatories: List, public val metadata: Metadata, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): NewAccount = try { NewAccount( AccountId.read(reader), - reader.readVec(reader.readCompactInt()) { PublicKey.read(reader) }, Metadata.read(reader), ) } catch (ex: Exception) { @@ -35,12 +31,6 @@ public data class NewAccount( override fun write(writer: ScaleCodecWriter, instance: NewAccount): Unit = try { AccountId.write(writer, instance.id) - writer.writeCompact(instance.signatories.size) - instance.signatories.sortedWith( - PublicKey.comparator(), - ).forEach { value -> - PublicKey.write(writer, value) - } Metadata.write(writer, instance.metadata) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAssetDefinition.kt index 01ac6bbed..723b7c43c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAssetDefinition.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewAssetDefinition.kt @@ -17,7 +17,7 @@ import kotlin.Unit */ public data class NewAssetDefinition( public val id: AssetDefinitionId, - public val valueType: AssetValueType, + public val type: AssetType, public val mintable: Mintable, public val logo: IpfsPath? = null, public val metadata: Metadata, @@ -26,7 +26,7 @@ public data class NewAssetDefinition( override fun read(reader: ScaleCodecReader): NewAssetDefinition = try { NewAssetDefinition( AssetDefinitionId.read(reader), - AssetValueType.read(reader), + AssetType.read(reader), Mintable.read(reader), reader.readNullable(IpfsPath) as IpfsPath?, Metadata.read(reader), @@ -37,7 +37,7 @@ public data class NewAssetDefinition( override fun write(writer: ScaleCodecWriter, instance: NewAssetDefinition): Unit = try { AssetDefinitionId.write(writer, instance.id) - AssetValueType.write(writer, instance.valueType) + AssetType.write(writer, instance.type) Mintable.write(writer, instance.mintable) writer.writeNullable(IpfsPath, instance.logo) Metadata.write(writer, instance.metadata) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt deleted file mode 100644 index c9e759d74..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewParameterExpr.kt +++ /dev/null @@ -1,36 +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 - -/** - * NewParameterExpr - * - * Generated from 'NewParameterExpr' regular structure - */ -public data class NewParameterExpr( - public val parameter: EvaluatesTo, -) { - 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: 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/NonTrivial.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NonTrivial.kt index 8e42b6122..29e2e976d 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NonTrivial.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NonTrivial.kt @@ -15,17 +15,17 @@ import kotlin.collections.List /** * NonTrivial * - * Generated from 'NonTrivial>' regular structure + * Generated from 'NonTrivial>' regular structure */ public data class NonTrivial( - public val vecOfValuePredicate: List>, + public val vecOfQueryOutputPredicate: List>, ) { public companion object : ScaleReader>, ScaleWriter> { override fun read(reader: ScaleCodecReader): NonTrivial = try { NonTrivial( reader.readVec(reader.readCompactInt()) { GenericPredicateBox.read(reader) as - GenericPredicateBox + GenericPredicateBox }, ) } catch (ex: Exception) { @@ -33,8 +33,8 @@ public data class NonTrivial( } override fun write(writer: ScaleCodecWriter, instance: NonTrivial): Unit = try { - writer.writeCompact(instance.vecOfValuePredicate.size) - instance.vecOfValuePredicate.forEach { value -> + writer.writeCompact(instance.vecOfQueryOutputPredicate.size) + instance.vecOfQueryOutputPredicate.forEach { value -> GenericPredicateBox.write(writer, value) } } catch (ex: Exception) { diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NotificationEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NotificationEventFilter.kt deleted file mode 100644 index 4bd12670f..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NotificationEventFilter.kt +++ /dev/null @@ -1,124 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * NotificationEventFilter - * - * Generated from 'NotificationEventFilter' enum - */ -public sealed class NotificationEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is AcceptAll -> AcceptAll.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is AcceptAll -> AcceptAll.hashCode() - else -> super.hashCode() } - - /** - * 'AcceptAll' variant - */ - public class AcceptAll : NotificationEventFilter() { - 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.NotificationEventFilter.AcceptAll = try { - AcceptAll() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NotificationEventFilter.AcceptAll, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.NotificationEventFilter.AcceptAll, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".NotificationEventFilter.AcceptAll".hashCode() - } - } - - /** - * 'TriggerCompleted' variant - */ - public data class TriggerCompleted( - public val triggerCompletedEventFilter: TriggerCompletedEventFilter, - ) : NotificationEventFilter() { - 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.NotificationEventFilter.TriggerCompleted = try { - TriggerCompleted( - TriggerCompletedEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NotificationEventFilter.TriggerCompleted, - ): Unit = try { - TriggerCompletedEventFilter.write(writer, instance.triggerCompletedEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): NotificationEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> AcceptAll.read(reader) - 1 -> TriggerCompleted.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: NotificationEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> AcceptAll.write(writer, instance as AcceptAll) - 1 -> TriggerCompleted.write(writer, instance as TriggerCompleted) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Numeric.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Numeric.kt new file mode 100644 index 000000000..20b5baa41 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Numeric.kt @@ -0,0 +1,43 @@ +// +// 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.codec.reader.CompactBigIntReader +import jp.co.soramitsu.iroha2.codec.writer.CompactULongWriter +import jp.co.soramitsu.iroha2.wrapException +import java.math.BigInteger +import kotlin.Long +import kotlin.Unit + +/** + * Numeric + * + * Generated from 'Numeric' regular structure + */ +public data class Numeric( + public val mantissa: BigInteger, + public val scale: Long, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Numeric = try { + Numeric( + reader.read(CompactBigIntReader()), + reader.readCompactInt().toLong(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: Numeric): Unit = try { + writer.write(CompactULongWriter(), instance.mantissa.toLong()) + writer.write(CompactULongWriter(), instance.scale.toLong()) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Not.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericSpec.kt similarity index 57% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Not.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericSpec.kt index 5fa1b8074..257bb0c76 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Not.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericSpec.kt @@ -8,28 +8,28 @@ 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.Long import kotlin.Unit /** - * Not + * NumericSpec * - * Generated from 'Not' regular structure + * Generated from 'NumericSpec' regular structure */ -public data class Not( - public val expression: EvaluatesTo, +public data class NumericSpec( + public val scale: Long? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Not = try { - Not( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): NumericSpec = try { + NumericSpec( + reader.readNullable(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: Not): Unit = try { - EvaluatesTo.write(writer, instance.expression) + override fun write(writer: ScaleCodecWriter, instance: NumericSpec): Unit = try { + writer.writeNullable(instance.scale) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericValue.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericValue.kt deleted file mode 100644 index 386f773de..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NumericValue.kt +++ /dev/null @@ -1,177 +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 java.math.BigInteger -import kotlin.Int -import kotlin.Long -import kotlin.Unit - -/** - * NumericValue - * - * Generated from 'NumericValue' enum - */ -public sealed class NumericValue : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'U32' variant - */ - public data class U32( - public val u32: Long, - ) : NumericValue() { - 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.NumericValue.U32 = try { - U32( - reader.readUint32(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NumericValue.U32, - ): Unit = try { - writer.writeUint32(instance.u32) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'U64' variant - */ - public data class U64( - public val u64: BigInteger, - ) : NumericValue() { - 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.NumericValue.U64 = try { - U64( - reader.readUint64(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NumericValue.U64, - ): Unit = try { - writer.writeUint64(instance.u64) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'U128' variant - */ - public data class U128( - public val u128: BigInteger, - ) : NumericValue() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.NumericValue.U128 = try { - U128( - reader.readUint128(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NumericValue.U128, - ): Unit = try { - writer.writeUint128(instance.u128) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Fixed' variant - */ - public data class Fixed( - public val fixed: jp.co.soramitsu.iroha2.generated.Fixed, - ) : NumericValue() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.NumericValue.Fixed = try { - Fixed( - jp.co.soramitsu.iroha2.generated.Fixed.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.NumericValue.Fixed, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Fixed.write(writer, instance.fixed) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): NumericValue = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> U32.read(reader) - 1 -> U64.read(reader) - 2 -> U128.read(reader) - 3 -> Fixed.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: NumericValue) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> U32.write(writer, instance as U32) - 1 -> U64.write(writer, instance as U64) - 2 -> U128.write(writer, instance as U128) - 3 -> Fixed.write(writer, instance as Fixed) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Or.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Or.kt deleted file mode 100644 index 9b3b0bd0b..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Or.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.Boolean -import kotlin.Unit - -/** - * Or - * - * Generated from 'Or' regular structure - */ -public data class Or( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Or = try { - Or( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Or): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pagination.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pagination.kt new file mode 100644 index 000000000..cf62e6c1f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Pagination.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 + +/** + * Pagination + * + * Generated from 'Pagination' regular structure + */ +public data class Pagination( + public val limit: NonZeroOfu32? = null, + public val start: NonZeroOfu64? = null, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Pagination = try { + Pagination( + reader.readNullable(NonZeroOfu32) as NonZeroOfu32?, + reader.readNullable(NonZeroOfu64) as NonZeroOfu64?, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: Pagination): Unit = try { + writer.writeNullable(NonZeroOfu32, instance.limit) + writer.writeNullable(NonZeroOfu64, instance.start) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.kt deleted file mode 100644 index f69aa607a..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PairExpr.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 - -/** - * PairExpr - * - * Generated from 'PairExpr' regular structure - */ -public data class PairExpr( - public val leftInstruction: InstructionExpr, - public val rightInstruction: InstructionExpr, -) { - 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: 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/Parameter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameter.kt index d585fc8ea..5147fa1bf 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameter.kt @@ -3,37 +3,241 @@ // 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 /** * Parameter * - * Generated from 'Parameter' regular structure + * Generated from 'Parameter' enum */ -public data class Parameter( - public val id: ParameterId, - public val `val`: Value, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Parameter = try { - Parameter( - ParameterId.read(reader), - Value.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) +public sealed class Parameter : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Sumeragi' variant + */ + public data class Sumeragi( + public val sumeragiParameter: SumeragiParameter, + ) : Parameter() { + 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.Parameter.Sumeragi = try { + Sumeragi( + SumeragiParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.Sumeragi, + ): Unit = try { + SumeragiParameter.write(writer, instance.sumeragiParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Block' variant + */ + public data class Block( + public val blockParameter: BlockParameter, + ) : Parameter() { + 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.Parameter.Block = try { + Block( + BlockParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.Block, + ): Unit = try { + BlockParameter.write(writer, instance.blockParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Transaction' variant + */ + public data class Transaction( + public val transactionParameter: TransactionParameter, + ) : Parameter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Parameter.Transaction = try { + Transaction( + TransactionParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.Transaction, + ): Unit = try { + TransactionParameter.write(writer, instance.transactionParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'SmartContract' variant + */ + public data class SmartContract( + public val smartContractParameter: SmartContractParameter, + ) : Parameter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Parameter.SmartContract = try { + SmartContract( + SmartContractParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.SmartContract, + ): Unit = try { + SmartContractParameter.write(writer, instance.smartContractParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Executor' variant + */ + public data class Executor( + public val smartContractParameter: SmartContractParameter, + ) : Parameter() { + 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.Parameter.Executor = try { + Executor( + SmartContractParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.Executor, + ): Unit = try { + SmartContractParameter.write(writer, instance.smartContractParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } } + } + + /** + * 'Custom' variant + */ + public data class Custom( + public val customParameter: CustomParameter, + ) : Parameter() { + 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.Parameter.Custom = try { + Custom( + CustomParameter.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.Parameter.Custom, + ): Unit = try { + CustomParameter.write(writer, instance.customParameter) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Parameter = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Sumeragi.read(reader) + 1 -> Block.read(reader) + 2 -> Transaction.read(reader) + 3 -> SmartContract.read(reader) + 4 -> Executor.read(reader) + 5 -> Custom.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: Parameter): Unit = try { - ParameterId.write(writer, instance.id) - Value.write(writer, instance.`val`) - } catch (ex: Exception) { - throw wrapException(ex) + override fun write(writer: ScaleCodecWriter, instance: Parameter) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Sumeragi.write(writer, instance as Sumeragi) + 1 -> Block.write(writer, instance as Block) + 2 -> Transaction.write(writer, instance as Transaction) + 3 -> SmartContract.write(writer, instance as SmartContract) + 4 -> Executor.write(writer, instance as Executor) + 5 -> Custom.write(writer, instance as Custom) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionToken.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterChanged.kt similarity index 50% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionToken.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterChanged.kt index 790c49717..ae97fda88 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionToken.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ParameterChanged.kt @@ -11,27 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * PermissionToken + * ParameterChanged * - * Generated from 'PermissionToken' regular structure + * Generated from 'ParameterChanged' regular structure */ -public data class PermissionToken( - public val definitionId: Name, - public val payload: StringWithJson, +public data class ParameterChanged( + public val oldValue: Parameter, + public val newValue: Parameter, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PermissionToken = try { - PermissionToken( - Name.read(reader), - StringWithJson.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): ParameterChanged = try { + ParameterChanged( + Parameter.read(reader), + Parameter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: PermissionToken): Unit = try { - Name.write(writer, instance.definitionId) - StringWithJson.write(writer, instance.payload) + override fun write(writer: ScaleCodecWriter, instance: ParameterChanged): Unit = try { + Parameter.write(writer, instance.oldValue) + Parameter.write(writer, instance.newValue) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameters.kt new file mode 100644 index 000000000..30c7f5a03 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Parameters.kt @@ -0,0 +1,63 @@ +// +// 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.comparator +import jp.co.soramitsu.iroha2.wrapException +import kotlin.Unit +import kotlin.collections.Map + +/** + * Parameters + * + * Generated from 'Parameters' regular structure + */ +public data class Parameters( + public val sumeragi: SumeragiParameters, + public val block: BlockParameters, + public val transaction: TransactionParameters, + public val executor: SmartContractParameters, + public val smartContract: SmartContractParameters, + public val custom: Map, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Parameters = try { + Parameters( + SumeragiParameters.read(reader), + BlockParameters.read(reader), + TransactionParameters.read(reader), + SmartContractParameters.read(reader), + SmartContractParameters.read(reader), + reader.readMap( + reader.readCompactInt(), + { CustomParameterId.read(reader) }, + { CustomParameter.read(reader) }, + ), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: Parameters): Unit = try { + SumeragiParameters.write(writer, instance.sumeragi) + BlockParameters.write(writer, instance.block) + TransactionParameters.write(writer, instance.transaction) + SmartContractParameters.write(writer, instance.executor) + SmartContractParameters.write(writer, instance.smartContract) + writer.writeCompact(instance.custom.size) + instance.custom.toSortedMap( + CustomParameterId.comparator(), + ).forEach { (key, value) -> + CustomParameterId.write(writer, key) + CustomParameter.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerEventFilter.kt index 388ffa4b1..6d56f9e64 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerEventFilter.kt @@ -3,121 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * PeerEventFilter * - * Generated from 'PeerEventFilter' enum + * Generated from 'PeerEventFilter' regular structure */ -public sealed class PeerEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByAdded -> ByAdded.equals(this, other) - is ByRemoved -> ByRemoved.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByAdded -> ByAdded.hashCode() - is ByRemoved -> ByRemoved.hashCode() - else -> super.hashCode() } - - /** - * 'ByAdded' variant - */ - public class ByAdded : PeerEventFilter() { - 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.PeerEventFilter.ByAdded = try { - ByAdded() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PeerEventFilter.ByAdded, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PeerEventFilter.ByAdded, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PeerEventFilter.ByAdded".hashCode() - } - } - - /** - * 'ByRemoved' variant - */ - public class ByRemoved : PeerEventFilter() { - 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.PeerEventFilter.ByRemoved = try { - ByRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PeerEventFilter.ByRemoved, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PeerEventFilter.ByRemoved, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PeerEventFilter.ByRemoved".hashCode() - } - } - +public data class PeerEventFilter( + public val idMatcher: PeerId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PeerEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByAdded.read(reader) - 1 -> ByRemoved.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): PeerEventFilter = try { + PeerEventFilter( + reader.readNullable(PeerId) as PeerId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } - override fun write(writer: ScaleCodecWriter, instance: PeerEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByAdded.write(writer, instance as ByAdded) - 1 -> ByRemoved.write(writer, instance as ByRemoved) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun write(writer: ScaleCodecWriter, instance: PeerEventFilter): Unit = try { + writer.writeNullable(PeerId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerFilter.kt deleted file mode 100644 index e322f3bdf..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerFilter.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 - -/** - * PeerFilter - * - * Generated from 'PeerFilter' regular structure - */ -public data class PeerFilter( - public val originFilter: FilterOptOfOriginFilterOfPeerEvent, - public val eventFilter: FilterOptOfPeerEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PeerFilter = try { - PeerFilter( - FilterOptOfOriginFilterOfPeerEvent.read(reader), - FilterOptOfPeerEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: PeerFilter): Unit = try { - FilterOptOfOriginFilterOfPeerEvent.write(writer, instance.originFilter) - FilterOptOfPeerEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerPredicateBox.kt new file mode 100644 index 000000000..e3e35d08d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PeerPredicateBox.kt @@ -0,0 +1,37 @@ +// +// 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 kotlin.Int + +/** + * PeerPredicateBox + * + * Generated from 'PeerPredicateBox' enum + */ +public sealed class PeerPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PeerPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: PeerPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionRemoved.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Permission.kt similarity index 50% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionRemoved.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Permission.kt index ede1e4bd1..4fd9a4e3c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionRemoved.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Permission.kt @@ -8,30 +8,31 @@ 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.String import kotlin.Unit /** - * PermissionRemoved + * Permission * - * Generated from 'PermissionRemoved' regular structure + * Generated from 'Permission' regular structure */ -public data class PermissionRemoved( - public val roleId: RoleId, - public val permissionTokenId: Name, +public data class Permission( + public val name: String, + public val payload: String, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PermissionRemoved = try { - PermissionRemoved( - RoleId.read(reader), - Name.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Permission = try { + Permission( + reader.readString(), + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: PermissionRemoved): Unit = try { - RoleId.write(writer, instance.roleId) - Name.write(writer, instance.permissionTokenId) + override fun write(writer: ScaleCodecWriter, instance: Permission): Unit = try { + writer.writeAsList(instance.name.toByteArray(Charsets.UTF_8)) + writer.writeAsList(instance.payload.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionPredicateBox.kt new file mode 100644 index 000000000..993954fde --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionPredicateBox.kt @@ -0,0 +1,37 @@ +// +// 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 kotlin.Int + +/** + * PermissionPredicateBox + * + * Generated from 'PermissionPredicateBox' enum + */ +public sealed class PermissionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PermissionPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: PermissionPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchema.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchema.kt deleted file mode 100644 index 9be931674..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchema.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.String -import kotlin.Unit -import kotlin.collections.List - -/** - * PermissionTokenSchema - * - * Generated from 'PermissionTokenSchema' regular structure - */ -public data class PermissionTokenSchema( - public val tokenIds: List, - public val schema: String, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PermissionTokenSchema = try { - PermissionTokenSchema( - reader.readVec(reader.readCompactInt()) { Name.read(reader) }, - reader.readString(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: PermissionTokenSchema): Unit = try { - writer.writeCompact(instance.tokenIds.size) - instance.tokenIds.forEach { value -> - Name.write(writer, value) - } - writer.writeAsList(instance.schema.toByteArray(Charsets.UTF_8)) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchemaUpdateEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchemaUpdateEvent.kt deleted file mode 100644 index 4048c8ea9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PermissionTokenSchemaUpdateEvent.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 - -/** - * PermissionTokenSchemaUpdateEvent - * - * Generated from 'PermissionTokenSchemaUpdateEvent' regular structure - */ -public data class PermissionTokenSchemaUpdateEvent( - public val oldSchema: PermissionTokenSchema, - public val newSchema: PermissionTokenSchema, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): PermissionTokenSchemaUpdateEvent = try { - PermissionTokenSchemaUpdateEvent( - PermissionTokenSchema.read(reader), - PermissionTokenSchema.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: PermissionTokenSchemaUpdateEvent): Unit = - try { - PermissionTokenSchema.write(writer, instance.oldSchema) - PermissionTokenSchema.write(writer, instance.newSchema) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEntityKind.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEntityKind.kt deleted file mode 100644 index 18bac80de..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEntityKind.kt +++ /dev/null @@ -1,126 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * PipelineEntityKind - * - * Generated from 'PipelineEntityKind' enum - */ -public sealed class PipelineEntityKind : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is Block -> Block.equals(this, other) - is Transaction -> Transaction.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Block -> Block.hashCode() - is Transaction -> Transaction.hashCode() - else -> super.hashCode() } - - /** - * 'Block' variant - */ - public class Block : PipelineEntityKind() { - 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.PipelineEntityKind.Block = try { - Block() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineEntityKind.Block, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PipelineEntityKind.Block, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineEntityKind.Block".hashCode() - } - } - - /** - * 'Transaction' variant - */ - public class Transaction : PipelineEntityKind() { - 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.PipelineEntityKind.Transaction = try { - Transaction() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineEntityKind.Transaction, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.PipelineEntityKind.Transaction, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineEntityKind.Transaction".hashCode() - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineEntityKind = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Block.read(reader) - 1 -> Transaction.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: PipelineEntityKind) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Block.write(writer, instance as Block) - 1 -> Transaction.write(writer, instance as Transaction) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEvent.kt deleted file mode 100644 index 095b79293..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEvent.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 - -/** - * PipelineEvent - * - * Generated from 'PipelineEvent' regular structure - */ -public data class PipelineEvent( - public val entityKind: PipelineEntityKind, - public val status: PipelineStatus, - public val hash: Hash, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineEvent = try { - PipelineEvent( - PipelineEntityKind.read(reader), - PipelineStatus.read(reader), - Hash.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: PipelineEvent): Unit = try { - PipelineEntityKind.write(writer, instance.entityKind) - PipelineStatus.write(writer, instance.status) - Hash.write(writer, instance.hash) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} 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/PipelineEventBox.kt similarity index 63% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/HashValue.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventBox.kt index 9b6eff62e..2b02650d1 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/PipelineEventBox.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * HashValue + * PipelineEventBox * - * Generated from 'HashValue' enum + * Generated from 'PipelineEventBox' enum */ -public sealed class HashValue : ModelEnum { +public sealed class PipelineEventBox : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,18 +27,18 @@ public sealed class HashValue : ModelEnum { * 'Transaction' variant */ public data class Transaction( - public val hashOf: HashOf, - ) : HashValue() { + public val transactionEvent: TransactionEvent, + ) : PipelineEventBox() { 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.HashValue.Transaction = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineEventBox.Transaction = try { Transaction( - HashOf.read(reader) as HashOf, + TransactionEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class HashValue : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.HashValue.Transaction, + instance: jp.co.soramitsu.iroha2.generated.PipelineEventBox.Transaction, ): Unit = try { - HashOf.write(writer, instance.hashOf) + TransactionEvent.write(writer, instance.transactionEvent) } catch (ex: Exception) { throw wrapException(ex) } @@ -59,18 +59,18 @@ public sealed class HashValue : ModelEnum { * 'Block' variant */ public data class Block( - public val hashOf: HashOf, - ) : HashValue() { + public val blockEvent: BlockEvent, + ) : PipelineEventBox() { 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.HashValue.Block = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineEventBox.Block = try { Block( - HashOf.read(reader) as HashOf, + BlockEvent.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,17 +78,17 @@ public sealed class HashValue : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.HashValue.Block, + instance: jp.co.soramitsu.iroha2.generated.PipelineEventBox.Block, ): Unit = try { - HashOf.write(writer, instance.hashOf) + BlockEvent.write(writer, instance.blockEvent) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): HashValue = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PipelineEventBox = when ( val discriminant = reader.readUByte() ) { @@ -96,7 +96,7 @@ public sealed class HashValue : ModelEnum { 1 -> Block.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: HashValue) { + override fun write(writer: ScaleCodecWriter, instance: PipelineEventBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Transaction.write(writer, instance as Transaction) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilter.kt deleted file mode 100644 index ff3e8ae9a..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilter.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 - -/** - * PipelineEventFilter - * - * Generated from 'PipelineEventFilter' regular structure - */ -public data class PipelineEventFilter( - public val entityKind: PipelineEntityKind? = null, - public val statusKind: PipelineStatusKind? = null, - public val hash: Hash? = null, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineEventFilter = try { - PipelineEventFilter( - reader.readNullable(PipelineEntityKind) as PipelineEntityKind?, - reader.readNullable(PipelineStatusKind) as PipelineStatusKind?, - reader.readNullable(Hash) as Hash?, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: PipelineEventFilter): Unit = try { - writer.writeNullable(PipelineEntityKind, instance.entityKind) - writer.writeNullable(PipelineStatusKind, instance.statusKind) - writer.writeNullable(Hash, instance.hash) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineRejectionReason.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilterBox.kt similarity index 62% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineRejectionReason.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilterBox.kt index ab8095bf0..6d6b170ec 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineRejectionReason.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineEventFilterBox.kt @@ -13,32 +13,32 @@ import kotlin.Int import kotlin.Unit /** - * PipelineRejectionReason + * PipelineEventFilterBox * - * Generated from 'PipelineRejectionReason' enum + * Generated from 'PipelineEventFilterBox' enum */ -public sealed class PipelineRejectionReason : ModelEnum { +public sealed class PipelineEventFilterBox : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'Block' variant + * 'Transaction' variant */ - public data class Block( - public val blockRejectionReason: BlockRejectionReason, - ) : PipelineRejectionReason() { + public data class Transaction( + public val transactionEventFilter: TransactionEventFilter, + ) : PipelineEventFilterBox() { 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.PipelineRejectionReason.Block = try { - Block( - BlockRejectionReason.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineEventFilterBox.Transaction = try { + Transaction( + TransactionEventFilter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class PipelineRejectionReason : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineRejectionReason.Block, + instance: jp.co.soramitsu.iroha2.generated.PipelineEventFilterBox.Transaction, ): Unit = try { - BlockRejectionReason.write(writer, instance.blockRejectionReason) + TransactionEventFilter.write(writer, instance.transactionEventFilter) } catch (ex: Exception) { throw wrapException(ex) } @@ -56,21 +56,21 @@ public sealed class PipelineRejectionReason : ModelEnum { } /** - * 'Transaction' variant + * 'Block' variant */ - public data class Transaction( - public val transactionRejectionReason: TransactionRejectionReason, - ) : PipelineRejectionReason() { + public data class Block( + public val blockEventFilter: BlockEventFilter, + ) : PipelineEventFilterBox() { 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.PipelineRejectionReason.Transaction = try { - Transaction( - TransactionRejectionReason.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineEventFilterBox.Block = try { + Block( + BlockEventFilter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,32 +78,29 @@ public sealed class PipelineRejectionReason : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineRejectionReason.Transaction, - ): Unit = - try { - TransactionRejectionReason.write(writer, instance.transactionRejectionReason) - } catch (ex: Exception) { - throw wrapException(ex) - } + instance: jp.co.soramitsu.iroha2.generated.PipelineEventFilterBox.Block, + ): Unit = try { + BlockEventFilter.write(writer, instance.blockEventFilter) + } catch (ex: Exception) { + throw wrapException(ex) + } } } - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineRejectionReason = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PipelineEventFilterBox = when ( val discriminant = reader.readUByte() ) { - 0 -> Block.read(reader) - 1 -> Transaction.read(reader) + 0 -> Transaction.read(reader) + 1 -> Block.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: PipelineRejectionReason) { + override fun write(writer: ScaleCodecWriter, instance: PipelineEventFilterBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Block.write(writer, instance as Block) - 1 -> Transaction.write(writer, instance as Transaction) + 0 -> Transaction.write(writer, instance as Transaction) + 1 -> Block.write(writer, instance as Block) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatus.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatus.kt deleted file mode 100644 index 8f42ca546..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatus.kt +++ /dev/null @@ -1,157 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * PipelineStatus - * - * Generated from 'PipelineStatus' enum - */ -public sealed class PipelineStatus : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is Validating -> Validating.equals(this, other) - is Committed -> Committed.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Validating -> Validating.hashCode() - is Committed -> Committed.hashCode() - else -> super.hashCode() } - - /** - * 'Validating' variant - */ - public class Validating : PipelineStatus() { - 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.PipelineStatus.Validating = try { - Validating() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatus.Validating, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PipelineStatus.Validating, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineStatus.Validating".hashCode() - } - } - - /** - * 'Rejected' variant - */ - public data class Rejected( - public val pipelineRejectionReason: PipelineRejectionReason, - ) : PipelineStatus() { - 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.PipelineStatus.Rejected = try { - Rejected( - PipelineRejectionReason.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatus.Rejected, - ): Unit = try { - PipelineRejectionReason.write(writer, instance.pipelineRejectionReason) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Committed' variant - */ - public class Committed : PipelineStatus() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineStatus.Committed = try { - Committed() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatus.Committed, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PipelineStatus.Committed, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineStatus.Committed".hashCode() - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineStatus = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Validating.read(reader) - 1 -> Rejected.read(reader) - 2 -> Committed.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: PipelineStatus) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Validating.write(writer, instance as Validating) - 1 -> Rejected.write(writer, instance as Rejected) - 2 -> Committed.write(writer, instance as Committed) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatusKind.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatusKind.kt deleted file mode 100644 index cb7f0645c..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PipelineStatusKind.kt +++ /dev/null @@ -1,167 +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.Boolean -import kotlin.Int -import kotlin.Unit - -/** - * PipelineStatusKind - * - * Generated from 'PipelineStatusKind' enum - */ -public sealed class PipelineStatusKind : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is Validating -> Validating.equals(this, other) - is Rejected -> Rejected.equals(this, other) - is Committed -> Committed.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Validating -> Validating.hashCode() - is Rejected -> Rejected.hashCode() - is Committed -> Committed.hashCode() - else -> super.hashCode() } - - /** - * 'Validating' variant - */ - public class Validating : PipelineStatusKind() { - 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.PipelineStatusKind.Validating = try { - Validating() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Validating, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Validating, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineStatusKind.Validating".hashCode() - } - } - - /** - * 'Rejected' variant - */ - public class Rejected : PipelineStatusKind() { - 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.PipelineStatusKind.Rejected = try { - Rejected() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Rejected, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Rejected, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineStatusKind.Rejected".hashCode() - } - } - - /** - * 'Committed' variant - */ - public class Committed : PipelineStatusKind() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Committed = try { - Committed() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Committed, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.PipelineStatusKind.Committed, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".PipelineStatusKind.Committed".hashCode() - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): PipelineStatusKind = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Validating.read(reader) - 1 -> Rejected.read(reader) - 2 -> Committed.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: PipelineStatusKind) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Validating.write(writer, instance as Validating) - 1 -> Rejected.write(writer, instance as Rejected) - 2 -> Committed.write(writer, instance as Committed) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKey.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKey.kt index 2785b6bc7..56b6b44b2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKey.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKey.kt @@ -8,7 +8,10 @@ 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.ByteArray +import kotlin.Int import kotlin.Unit /** @@ -17,9 +20,19 @@ import kotlin.Unit * Generated from 'PublicKey' regular structure */ public data class PublicKey( - public val digestFunction: Algorithm, + public val algorithm: Algorithm, public val payload: ByteArray, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is PublicKey) return false + if (algorithm != other.algorithm) return false + if (!payload.contentEquals(other.payload)) return false + return true + } + + override fun hashCode(): Int = algorithm.hashCode() * 31 + payload.contentHashCode() + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): PublicKey = try { PublicKey( @@ -31,7 +44,7 @@ public data class PublicKey( } override fun write(writer: ScaleCodecWriter, instance: PublicKey): Unit = try { - Algorithm.write(writer, instance.digestFunction) + Algorithm.write(writer, instance.algorithm) writer.writeAsList(instance.payload) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKeyPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKeyPredicateBox.kt new file mode 100644 index 000000000..9ae7921f2 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/PublicKeyPredicateBox.kt @@ -0,0 +1,73 @@ +// +// 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 + +/** + * PublicKeyPredicateBox + * + * Generated from 'PublicKeyPredicateBox' enum + */ +public sealed class PublicKeyPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val publicKey: PublicKey, + ) : PublicKeyPredicateBox() { + 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.PublicKeyPredicateBox.Equals = try { + Equals( + PublicKey.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.PublicKeyPredicateBox.Equals, + ): Unit = try { + PublicKey.write(writer, instance.publicKey) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): PublicKeyPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: PublicKeyPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} 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 39f8c150e..75343e0a7 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 @@ -124,41 +124,6 @@ public sealed class QueryBox : ModelEnum { } } - /** - * 'FindAccountsByName' variant - */ - public data class FindAccountsByName( - public val findAccountsByName: jp.co.soramitsu.iroha2.generated.FindAccountsByName, - ) : QueryBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAccountsByName = try { - FindAccountsByName( - jp.co.soramitsu.iroha2.generated.FindAccountsByName.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindAccountsByName, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.FindAccountsByName.write( - writer, - instance.findAccountsByName, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'FindAccountsByDomainId' variant */ @@ -170,7 +135,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 4 + public const val DISCRIMINANT: Int = 3 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAccountsByDomainId = try { FindAccountsByDomainId( @@ -205,7 +170,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 5 + public const val DISCRIMINANT: Int = 4 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAccountsWithAsset = try { FindAccountsWithAsset( @@ -240,7 +205,7 @@ public sealed class QueryBox : 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.QueryBox.FindAllAssets = try { FindAllAssets( @@ -272,7 +237,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 7 + public const val DISCRIMINANT: Int = 6 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAllAssetsDefinitions = try { FindAllAssetsDefinitions( @@ -307,7 +272,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 8 + public const val DISCRIMINANT: Int = 7 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetById = try { FindAssetById( @@ -339,7 +304,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 9 + public const val DISCRIMINANT: Int = 8 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetDefinitionById = try { FindAssetDefinitionById( @@ -374,7 +339,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 10 + public const val DISCRIMINANT: Int = 9 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetsByName = try { FindAssetsByName( @@ -406,7 +371,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 11 + public const val DISCRIMINANT: Int = 10 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetsByAccountId = try { FindAssetsByAccountId( @@ -442,7 +407,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 12 + public const val DISCRIMINANT: Int = 11 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetsByAssetDefinitionId = try { FindAssetsByAssetDefinitionId( @@ -478,7 +443,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 13 + public const val DISCRIMINANT: Int = 12 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetsByDomainId = try { FindAssetsByDomainId( @@ -514,7 +479,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 14 + public const val DISCRIMINANT: Int = 13 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetsByDomainIdAndAssetDefinitionId = try { FindAssetsByDomainIdAndAssetDefinitionId( @@ -549,7 +514,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 15 + public const val DISCRIMINANT: Int = 14 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetQuantityById = try { FindAssetQuantityById( @@ -585,7 +550,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 16 + public const val DISCRIMINANT: Int = 15 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTotalAssetQuantityByAssetDefinitionId = try { FindTotalAssetQuantityByAssetDefinitionId( @@ -621,7 +586,7 @@ public sealed class QueryBox : ModelEnum { public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 17 + public const val DISCRIMINANT: Int = 16 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindAssetKeyValueByIdAndKey = try { FindAssetKeyValueByIdAndKey( @@ -658,7 +623,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.FindAssetDefinitionKeyValueByIdAndKey = try { FindAssetDefinitionKeyValueByIdAndKey( @@ -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.FindAllDomains = try { FindAllDomains( @@ -725,7 +690,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.FindDomainById = try { FindDomainById( @@ -758,7 +723,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.FindDomainKeyValueByIdAndKey = try { FindDomainKeyValueByIdAndKey( @@ -794,7 +759,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.FindAllPeers = try { FindAllPeers( @@ -826,7 +791,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.FindAllBlocks = try { FindAllBlocks( @@ -858,7 +823,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.FindAllBlockHeaders = try { FindAllBlockHeaders( @@ -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.FindBlockHeaderByHash = try { FindBlockHeaderByHash( @@ -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.FindAllTransactions = try { FindAllTransactions( @@ -964,7 +929,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.FindTransactionsByAccountId = try { FindTransactionsByAccountId( @@ -1000,7 +965,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.FindTransactionByHash = try { FindTransactionByHash( @@ -1025,22 +990,22 @@ public sealed class QueryBox : ModelEnum { } /** - * 'FindPermissionTokensByAccountId' variant + * 'FindPermissionsByAccountId' variant */ - public data class FindPermissionTokensByAccountId( - public val findPermissionTokensByAccountId: - jp.co.soramitsu.iroha2.generated.FindPermissionTokensByAccountId, + public data class FindPermissionsByAccountId( + public val findPermissionsByAccountId: + jp.co.soramitsu.iroha2.generated.FindPermissionsByAccountId, ) : QueryBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 29 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 28 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokensByAccountId = try { - FindPermissionTokensByAccountId( - jp.co.soramitsu.iroha2.generated.FindPermissionTokensByAccountId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionsByAccountId = try { + FindPermissionsByAccountId( + jp.co.soramitsu.iroha2.generated.FindPermissionsByAccountId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -1048,35 +1013,35 @@ public sealed class QueryBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokensByAccountId, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.FindPermissionTokensByAccountId.write( - writer, - instance.findPermissionTokensByAccountId, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } + instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionsByAccountId, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindPermissionsByAccountId.write( + writer, + instance.findPermissionsByAccountId, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } } } /** - * 'FindPermissionTokenSchema' variant + * 'FindExecutorDataModel' variant */ - public data class FindPermissionTokenSchema( - public val findPermissionTokenSchema: - jp.co.soramitsu.iroha2.generated.FindPermissionTokenSchema, + public data class FindExecutorDataModel( + public val findExecutorDataModel: jp.co.soramitsu.iroha2.generated.FindExecutorDataModel, ) : QueryBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 30 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 29 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokenSchema = try { - FindPermissionTokenSchema( - jp.co.soramitsu.iroha2.generated.FindPermissionTokenSchema.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindExecutorDataModel = try { + FindExecutorDataModel( + jp.co.soramitsu.iroha2.generated.FindExecutorDataModel.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -1084,11 +1049,11 @@ public sealed class QueryBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindPermissionTokenSchema, + instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindExecutorDataModel, ): Unit = try { - jp.co.soramitsu.iroha2.generated.FindPermissionTokenSchema.write( + jp.co.soramitsu.iroha2.generated.FindExecutorDataModel.write( writer, - instance.findPermissionTokenSchema, + instance.findExecutorDataModel, ) } catch (ex: Exception) { throw wrapException(ex) @@ -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.FindAllActiveTriggerIds = try { FindAllActiveTriggerIds( @@ -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.FindTriggerById = try { FindTriggerById( @@ -1175,7 +1140,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.FindTriggerKeyValueByIdAndKey = try { FindTriggerKeyValueByIdAndKey( @@ -1201,21 +1166,58 @@ public sealed class QueryBox : ModelEnum { } /** - * 'FindTriggersByDomainId' variant + * 'FindTriggersByAuthorityId' variant + */ + public data class FindTriggersByAuthorityId( + public val findTriggersByAuthorityId: + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityId, + ) : QueryBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 33 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByAuthorityId = try { + FindTriggersByAuthorityId( + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByAuthorityId, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityId.write( + writer, + instance.findTriggersByAuthorityId, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindTriggersByAuthorityDomainId' variant */ - public data class FindTriggersByDomainId( - public val findTriggersByDomainId: jp.co.soramitsu.iroha2.generated.FindTriggersByDomainId, + public data class FindTriggersByAuthorityDomainId( + public val findTriggersByAuthorityDomainId: + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityDomainId, ) : QueryBox() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { + ScaleReader, + ScaleWriter { public const val DISCRIMINANT: Int = 34 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByDomainId = try { - FindTriggersByDomainId( - jp.co.soramitsu.iroha2.generated.FindTriggersByDomainId.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByAuthorityDomainId = try { + FindTriggersByAuthorityDomainId( + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityDomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -1223,11 +1225,11 @@ public sealed class QueryBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByDomainId, + instance: jp.co.soramitsu.iroha2.generated.QueryBox.FindTriggersByAuthorityDomainId, ): Unit = try { - jp.co.soramitsu.iroha2.generated.FindTriggersByDomainId.write( + jp.co.soramitsu.iroha2.generated.FindTriggersByAuthorityDomainId.write( writer, - instance.findTriggersByDomainId, + instance.findTriggersByAuthorityDomainId, ) } catch (ex: Exception) { throw wrapException(ex) @@ -1406,38 +1408,38 @@ public sealed class QueryBox : ModelEnum { 0 -> FindAllAccounts.read(reader) 1 -> FindAccountById.read(reader) 2 -> FindAccountKeyValueByIdAndKey.read(reader) - 3 -> FindAccountsByName.read(reader) - 4 -> FindAccountsByDomainId.read(reader) - 5 -> FindAccountsWithAsset.read(reader) - 6 -> FindAllAssets.read(reader) - 7 -> FindAllAssetsDefinitions.read(reader) - 8 -> FindAssetById.read(reader) - 9 -> FindAssetDefinitionById.read(reader) - 10 -> FindAssetsByName.read(reader) - 11 -> FindAssetsByAccountId.read(reader) - 12 -> FindAssetsByAssetDefinitionId.read(reader) - 13 -> FindAssetsByDomainId.read(reader) - 14 -> FindAssetsByDomainIdAndAssetDefinitionId.read(reader) - 15 -> FindAssetQuantityById.read(reader) - 16 -> FindTotalAssetQuantityByAssetDefinitionId.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) + 3 -> FindAccountsByDomainId.read(reader) + 4 -> FindAccountsWithAsset.read(reader) + 5 -> FindAllAssets.read(reader) + 6 -> FindAllAssetsDefinitions.read(reader) + 7 -> FindAssetById.read(reader) + 8 -> FindAssetDefinitionById.read(reader) + 9 -> FindAssetsByName.read(reader) + 10 -> FindAssetsByAccountId.read(reader) + 11 -> FindAssetsByAssetDefinitionId.read(reader) + 12 -> FindAssetsByDomainId.read(reader) + 13 -> FindAssetsByDomainIdAndAssetDefinitionId.read(reader) + 14 -> FindAssetQuantityById.read(reader) + 15 -> FindTotalAssetQuantityByAssetDefinitionId.read(reader) + 16 -> FindAssetKeyValueByIdAndKey.read(reader) + 17 -> FindAssetDefinitionKeyValueByIdAndKey.read(reader) + 18 -> FindAllDomains.read(reader) + 19 -> FindDomainById.read(reader) + 20 -> FindDomainKeyValueByIdAndKey.read(reader) + 21 -> FindAllPeers.read(reader) + 22 -> FindAllBlocks.read(reader) + 23 -> FindAllBlockHeaders.read(reader) + 24 -> FindBlockHeaderByHash.read(reader) + 25 -> FindAllTransactions.read(reader) + 26 -> FindTransactionsByAccountId.read(reader) + 27 -> FindTransactionByHash.read(reader) + 28 -> FindPermissionsByAccountId.read(reader) + 29 -> FindExecutorDataModel.read(reader) + 30 -> FindAllActiveTriggerIds.read(reader) + 31 -> FindTriggerById.read(reader) + 32 -> FindTriggerKeyValueByIdAndKey.read(reader) + 33 -> FindTriggersByAuthorityId.read(reader) + 34 -> FindTriggersByAuthorityDomainId.read(reader) 35 -> FindAllRoles.read(reader) 36 -> FindAllRoleIds.read(reader) 37 -> FindRoleByRoleId.read(reader) @@ -1451,54 +1453,54 @@ public sealed class QueryBox : ModelEnum { 0 -> FindAllAccounts.write(writer, instance as FindAllAccounts) 1 -> FindAccountById.write(writer, instance as FindAccountById) 2 -> FindAccountKeyValueByIdAndKey.write(writer, instance as FindAccountKeyValueByIdAndKey) - 3 -> FindAccountsByName.write(writer, instance as FindAccountsByName) - 4 -> FindAccountsByDomainId.write(writer, instance as FindAccountsByDomainId) - 5 -> FindAccountsWithAsset.write(writer, instance as FindAccountsWithAsset) - 6 -> FindAllAssets.write(writer, instance as FindAllAssets) - 7 -> FindAllAssetsDefinitions.write(writer, instance as FindAllAssetsDefinitions) - 8 -> FindAssetById.write(writer, instance as FindAssetById) - 9 -> FindAssetDefinitionById.write(writer, instance as FindAssetDefinitionById) - 10 -> FindAssetsByName.write(writer, instance as FindAssetsByName) - 11 -> FindAssetsByAccountId.write(writer, instance as FindAssetsByAccountId) - 12 -> FindAssetsByAssetDefinitionId.write(writer, instance as FindAssetsByAssetDefinitionId) - 13 -> FindAssetsByDomainId.write(writer, instance as FindAssetsByDomainId) - 14 -> FindAssetsByDomainIdAndAssetDefinitionId.write( + 3 -> FindAccountsByDomainId.write(writer, instance as FindAccountsByDomainId) + 4 -> FindAccountsWithAsset.write(writer, instance as FindAccountsWithAsset) + 5 -> FindAllAssets.write(writer, instance as FindAllAssets) + 6 -> FindAllAssetsDefinitions.write(writer, instance as FindAllAssetsDefinitions) + 7 -> FindAssetById.write(writer, instance as FindAssetById) + 8 -> FindAssetDefinitionById.write(writer, instance as FindAssetDefinitionById) + 9 -> FindAssetsByName.write(writer, instance as FindAssetsByName) + 10 -> FindAssetsByAccountId.write(writer, instance as FindAssetsByAccountId) + 11 -> FindAssetsByAssetDefinitionId.write(writer, instance as FindAssetsByAssetDefinitionId) + 12 -> FindAssetsByDomainId.write(writer, instance as FindAssetsByDomainId) + 13 -> FindAssetsByDomainIdAndAssetDefinitionId.write( writer, instance as FindAssetsByDomainIdAndAssetDefinitionId, ) - 15 -> FindAssetQuantityById.write(writer, instance as FindAssetQuantityById) - 16 -> FindTotalAssetQuantityByAssetDefinitionId.write( + 14 -> FindAssetQuantityById.write(writer, instance as FindAssetQuantityById) + 15 -> FindTotalAssetQuantityByAssetDefinitionId.write( writer, instance as FindTotalAssetQuantityByAssetDefinitionId, ) - 17 -> FindAssetKeyValueByIdAndKey.write(writer, instance as FindAssetKeyValueByIdAndKey) - 18 -> FindAssetDefinitionKeyValueByIdAndKey.write( + 16 -> FindAssetKeyValueByIdAndKey.write(writer, instance as FindAssetKeyValueByIdAndKey) + 17 -> FindAssetDefinitionKeyValueByIdAndKey.write( writer, instance as FindAssetDefinitionKeyValueByIdAndKey, ) - 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( + 18 -> FindAllDomains.write(writer, instance as FindAllDomains) + 19 -> FindDomainById.write(writer, instance as FindDomainById) + 20 -> FindDomainKeyValueByIdAndKey.write(writer, instance as FindDomainKeyValueByIdAndKey) + 21 -> FindAllPeers.write(writer, instance as FindAllPeers) + 22 -> FindAllBlocks.write(writer, instance as FindAllBlocks) + 23 -> FindAllBlockHeaders.write(writer, instance as FindAllBlockHeaders) + 24 -> FindBlockHeaderByHash.write(writer, instance as FindBlockHeaderByHash) + 25 -> FindAllTransactions.write(writer, instance as FindAllTransactions) + 26 -> FindTransactionsByAccountId.write(writer, instance as FindTransactionsByAccountId) + 27 -> FindTransactionByHash.write(writer, instance as FindTransactionByHash) + 28 -> FindPermissionsByAccountId.write(writer, instance as FindPermissionsByAccountId) + 29 -> FindExecutorDataModel.write(writer, instance as FindExecutorDataModel) + 30 -> FindAllActiveTriggerIds.write(writer, instance as FindAllActiveTriggerIds) + 31 -> FindTriggerById.write(writer, instance as FindTriggerById) + 32 -> FindTriggerKeyValueByIdAndKey.write(writer, instance as FindTriggerKeyValueByIdAndKey) + 33 -> FindTriggersByAuthorityId.write(writer, instance as FindTriggersByAuthorityId) + 34 -> FindTriggersByAuthorityDomainId.write( writer, instance as - FindPermissionTokensByAccountId, + FindTriggersByAuthorityDomainId, ) - 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) 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 569f3815c..95ae72765 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,6 +9,8 @@ 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 @@ -24,22 +26,36 @@ public sealed class QueryExecutionFail : ModelEnum { */ public abstract fun discriminant(): Int + override fun equals(other: Any?): Boolean = when (this) { + is UnknownCursor -> UnknownCursor.equals(this, other) + is FetchSizeTooBig -> FetchSizeTooBig.equals(this, other) + is InvalidSingularParameters -> InvalidSingularParameters.equals(this, other) + is CapacityLimit -> CapacityLimit.equals(this, other) + else -> super.equals(other) } + + override fun hashCode(): Int = when (this) { + is UnknownCursor -> UnknownCursor.hashCode() + is FetchSizeTooBig -> FetchSizeTooBig.hashCode() + is InvalidSingularParameters -> InvalidSingularParameters.hashCode() + is CapacityLimit -> CapacityLimit.hashCode() + else -> super.hashCode() } + /** - * 'Signature' variant + * 'Find' variant */ - public data class Signature( - public val string: String, + public data class Find( + public val findError: FindError, ) : QueryExecutionFail() { 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.QueryExecutionFail.Signature = try { - Signature( - reader.readString(), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Find = try { + Find( + FindError.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -47,9 +63,9 @@ public sealed class QueryExecutionFail : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Signature, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Find, ): Unit = try { - writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) + FindError.write(writer, instance.findError) } catch (ex: Exception) { throw wrapException(ex) } @@ -57,20 +73,20 @@ public sealed class QueryExecutionFail : ModelEnum { } /** - * 'Evaluate' variant + * 'Conversion' variant */ - public data class Evaluate( + public data class Conversion( public val string: String, ) : QueryExecutionFail() { 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.QueryExecutionFail.Evaluate = try { - Evaluate( + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Conversion = try { + Conversion( reader.readString(), ) } catch (ex: Exception) { @@ -79,7 +95,7 @@ public sealed class QueryExecutionFail : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Evaluate, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Conversion, ): Unit = try { writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { @@ -89,66 +105,150 @@ public sealed class QueryExecutionFail : ModelEnum { } /** - * 'Find' variant + * 'UnknownCursor' variant */ - public data class Find( - public val findError: FindError, - ) : QueryExecutionFail() { + public class UnknownCursor : QueryExecutionFail() { 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.QueryExecutionFail.Find = try { - Find( - FindError.read(reader), - ) + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryExecutionFail.UnknownCursor = try { + UnknownCursor() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Find, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.UnknownCursor, ): Unit = try { - FindError.write(writer, instance.findError) } catch (ex: Exception) { throw wrapException(ex) } + + public fun equals( + o1: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.UnknownCursor, + o2: Any?, + ): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".QueryExecutionFail.UnknownCursor".hashCode() } } /** - * 'Conversion' variant + * 'FetchSizeTooBig' variant */ - public data class Conversion( - public val string: String, - ) : QueryExecutionFail() { + public class FetchSizeTooBig : QueryExecutionFail() { 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.QueryExecutionFail.Conversion = try { - Conversion( - reader.readString(), - ) + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryExecutionFail.FetchSizeTooBig = try { + FetchSizeTooBig() } catch (ex: Exception) { throw wrapException(ex) } override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.Conversion, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.FetchSizeTooBig, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals( + o1: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.FetchSizeTooBig, + o2: Any?, + ): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".QueryExecutionFail.FetchSizeTooBig".hashCode() + } + } + + /** + * 'InvalidSingularParameters' variant + */ + public class InvalidSingularParameters : 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.InvalidSingularParameters = try { + InvalidSingularParameters() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.InvalidSingularParameters, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals( + o1: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.InvalidSingularParameters, + o2: Any?, + ): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".QueryExecutionFail.InvalidSingularParameters".hashCode() + } + } + + /** + * 'CapacityLimit' variant + */ + public class CapacityLimit : QueryExecutionFail() { + 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.QueryExecutionFail.CapacityLimit = try { + CapacityLimit() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.CapacityLimit, ): Unit = try { - writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } + + public fun equals( + o1: jp.co.soramitsu.iroha2.generated.QueryExecutionFail.CapacityLimit, + o2: Any?, + ): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".QueryExecutionFail.CapacityLimit".hashCode() } } @@ -157,19 +257,23 @@ public sealed class QueryExecutionFail : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> Signature.read(reader) - 1 -> Evaluate.read(reader) - 2 -> Find.read(reader) - 3 -> Conversion.read(reader) + 0 -> Find.read(reader) + 1 -> Conversion.read(reader) + 2 -> UnknownCursor.read(reader) + 3 -> FetchSizeTooBig.read(reader) + 4 -> InvalidSingularParameters.read(reader) + 5 -> CapacityLimit.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: QueryExecutionFail) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Signature.write(writer, instance as Signature) - 1 -> Evaluate.write(writer, instance as Evaluate) - 2 -> Find.write(writer, instance as Find) - 3 -> Conversion.write(writer, instance as Conversion) + 0 -> Find.write(writer, instance as Find) + 1 -> Conversion.write(writer, instance as Conversion) + 2 -> UnknownCursor.write(writer, instance as UnknownCursor) + 3 -> FetchSizeTooBig.write(writer, instance as FetchSizeTooBig) + 4 -> InvalidSingularParameters.write(writer, instance as InvalidSingularParameters) + 5 -> CapacityLimit.write(writer, instance as CapacityLimit) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutput.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutput.kt new file mode 100644 index 000000000..ca2118d63 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutput.kt @@ -0,0 +1,43 @@ +// +// 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 java.math.BigInteger +import kotlin.Unit + +/** + * QueryOutput + * + * Generated from 'QueryOutput' regular structure + */ +public data class QueryOutput( + public val batch: QueryOutputBatchBox, + public val remainingItems: BigInteger, + public val continueCursor: ForwardCursor? = null, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryOutput = try { + QueryOutput( + QueryOutputBatchBox.read(reader), + reader.readUint64(), + reader.readNullable(ForwardCursor) as ForwardCursor?, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: QueryOutput): Unit = try { + QueryOutputBatchBox.write(writer, instance.batch) + writer.writeUint64(instance.remainingItems) + writer.writeNullable(ForwardCursor, instance.continueCursor) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBatchBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBatchBox.kt new file mode 100644 index 000000000..9e42159c6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBatchBox.kt @@ -0,0 +1,559 @@ +// +// 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 + +/** + * QueryOutputBatchBox + * + * Generated from 'QueryOutputBatchBox' enum + */ +public sealed class QueryOutputBatchBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Domain' variant + */ + public data class Domain( + public val vec: List, + ) : QueryOutputBatchBox() { + 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.QueryOutputBatchBox.Domain = try { + Domain( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Domain.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Domain, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Domain.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Account' variant + */ + public data class Account( + public val vec: List, + ) : QueryOutputBatchBox() { + 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.QueryOutputBatchBox.Account = try { + Account( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Account.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Account, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Account.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Asset = try { + Asset( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Asset.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Asset, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Asset.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.AssetDefinition = try { + AssetDefinition( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.AssetDefinition.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.AssetDefinition, + ): Unit = + try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.AssetDefinition.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Role' variant + */ + public data class Role( + public val vec: List, + ) : QueryOutputBatchBox() { + 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.QueryOutputBatchBox.Role = try { + Role( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Role.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Role, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Role.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Parameter' variant + */ + public data class Parameter( + public val vec: List, + ) : QueryOutputBatchBox() { + 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.QueryOutputBatchBox.Parameter = try { + Parameter( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Parameter.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Parameter, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Parameter.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Permission' variant + */ + public data class Permission( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Permission = try { + Permission( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Permission.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Permission, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Permission.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Transaction' variant + */ + public data class Transaction( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 7 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Transaction = try { + Transaction( + reader.readVec(reader.readCompactInt()) { TransactionQueryOutput.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Transaction, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + TransactionQueryOutput.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Peer' variant + */ + public data class Peer( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 8 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Peer = try { + Peer( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Peer.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Peer, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Peer.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'RoleId' variant + */ + public data class RoleId( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 9 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.RoleId = try { + RoleId( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.RoleId.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.RoleId, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.RoleId.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'TriggerId' variant + */ + public data class TriggerId( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 10 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.TriggerId = try { + TriggerId( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.TriggerId.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.TriggerId, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.TriggerId.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 11 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Trigger = try { + Trigger( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.Trigger.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Trigger, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.Trigger.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Block' variant + */ + public data class Block( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 12 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Block = try { + Block( + reader.readVec(reader.readCompactInt()) { SignedBlock.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.Block, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + SignedBlock.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'BlockHeader' variant + */ + public data class BlockHeader( + public val vec: List, + ) : QueryOutputBatchBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 13 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.BlockHeader = try { + BlockHeader( + reader.readVec(reader.readCompactInt()) { jp.co.soramitsu.iroha2.generated.BlockHeader.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBatchBox.BlockHeader, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + jp.co.soramitsu.iroha2.generated.BlockHeader.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryOutputBatchBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Domain.read(reader) + 1 -> Account.read(reader) + 2 -> Asset.read(reader) + 3 -> AssetDefinition.read(reader) + 4 -> Role.read(reader) + 5 -> Parameter.read(reader) + 6 -> Permission.read(reader) + 7 -> Transaction.read(reader) + 8 -> Peer.read(reader) + 9 -> RoleId.read(reader) + 10 -> TriggerId.read(reader) + 11 -> Trigger.read(reader) + 12 -> Block.read(reader) + 13 -> BlockHeader.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: QueryOutputBatchBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Domain.write(writer, instance as Domain) + 1 -> Account.write(writer, instance as Account) + 2 -> Asset.write(writer, instance as Asset) + 3 -> AssetDefinition.write(writer, instance as AssetDefinition) + 4 -> Role.write(writer, instance as Role) + 5 -> Parameter.write(writer, instance as Parameter) + 6 -> Permission.write(writer, instance as Permission) + 7 -> Transaction.write(writer, instance as Transaction) + 8 -> Peer.write(writer, instance as Peer) + 9 -> RoleId.write(writer, instance as RoleId) + 10 -> TriggerId.write(writer, instance as TriggerId) + 11 -> Trigger.write(writer, instance as Trigger) + 12 -> Block.write(writer, instance as Block) + 13 -> BlockHeader.write(writer, instance as BlockHeader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBox.kt new file mode 100644 index 000000000..6417bf9f1 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputBox.kt @@ -0,0 +1,418 @@ +// +// 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.String +import kotlin.Unit +import kotlin.collections.List + +/** + * QueryOutputBox + * + * Generated from 'QueryOutputBox' enum + */ +public sealed class QueryOutputBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val idBox: IdBox, + ) : QueryOutputBox() { + 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.QueryOutputBox.Id = try { + Id( + IdBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Id, + ): Unit = try { + IdBox.write(writer, instance.idBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Identifiable' variant + */ + public data class Identifiable( + public val identifiableBox: IdentifiableBox, + ) : QueryOutputBox() { + 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.QueryOutputBox.Identifiable = try { + Identifiable( + IdentifiableBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Identifiable, + ): Unit = try { + IdentifiableBox.write(writer, instance.identifiableBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Transaction' variant + */ + public data class Transaction( + public val transactionQueryOutput: TransactionQueryOutput, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.Transaction = try { + Transaction( + TransactionQueryOutput.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Transaction, + ): Unit = try { + TransactionQueryOutput.write(writer, instance.transactionQueryOutput) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Permission' variant + */ + public data class Permission( + public val permission: jp.co.soramitsu.iroha2.generated.Permission, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.Permission = try { + Permission( + jp.co.soramitsu.iroha2.generated.Permission.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Permission, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Permission.write(writer, instance.permission) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Parameters' variant + */ + public data class Parameters( + public val parameters: jp.co.soramitsu.iroha2.generated.Parameters, + ) : QueryOutputBox() { + 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.QueryOutputBox.Parameters = try { + Parameters( + jp.co.soramitsu.iroha2.generated.Parameters.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Parameters, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Parameters.write(writer, instance.parameters) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Metadata' variant + */ + public data class Metadata( + public val string: String, + ) : QueryOutputBox() { + 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.QueryOutputBox.Metadata = try { + Metadata( + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Metadata, + ): Unit = try { + writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Numeric' variant + */ + public data class Numeric( + public val numeric: jp.co.soramitsu.iroha2.generated.Numeric, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.Numeric = try { + Numeric( + jp.co.soramitsu.iroha2.generated.Numeric.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Numeric, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Numeric.write(writer, instance.numeric) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'BlockHeader' variant + */ + public data class BlockHeader( + public val blockHeader: jp.co.soramitsu.iroha2.generated.BlockHeader, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 7 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.BlockHeader = try { + BlockHeader( + jp.co.soramitsu.iroha2.generated.BlockHeader.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.BlockHeader, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.BlockHeader.write(writer, instance.blockHeader) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Block' variant + */ + public data class Block( + public val signedBlock: SignedBlock, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 8 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.Block = try { + Block( + SignedBlock.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Block, + ): Unit = try { + SignedBlock.write(writer, instance.signedBlock) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'ExecutorDataModel' variant + */ + public data class ExecutorDataModel( + public val executorDataModel: jp.co.soramitsu.iroha2.generated.ExecutorDataModel, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 9 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.ExecutorDataModel = try { + ExecutorDataModel( + jp.co.soramitsu.iroha2.generated.ExecutorDataModel.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.ExecutorDataModel, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.ExecutorDataModel.write(writer, instance.executorDataModel) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Vec' variant + */ + public data class Vec( + public val vec: List, + ) : QueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 10 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputBox.Vec = try { + Vec( + reader.readVec(reader.readCompactInt()) { QueryOutputBox.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputBox.Vec, + ): Unit = try { + writer.writeCompact(instance.vec.size) + instance.vec.forEach { value -> + QueryOutputBox.write(writer, value) + } + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryOutputBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + 1 -> Identifiable.read(reader) + 2 -> Transaction.read(reader) + 3 -> Permission.read(reader) + 4 -> Parameters.read(reader) + 5 -> Metadata.read(reader) + 6 -> Numeric.read(reader) + 7 -> BlockHeader.read(reader) + 8 -> Block.read(reader) + 9 -> ExecutorDataModel.read(reader) + 10 -> Vec.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: QueryOutputBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + 1 -> Identifiable.write(writer, instance as Identifiable) + 2 -> Transaction.write(writer, instance as Transaction) + 3 -> Permission.write(writer, instance as Permission) + 4 -> Parameters.write(writer, instance as Parameters) + 5 -> Metadata.write(writer, instance as Metadata) + 6 -> Numeric.write(writer, instance as Numeric) + 7 -> BlockHeader.write(writer, instance as BlockHeader) + 8 -> Block.write(writer, instance as Block) + 9 -> ExecutorDataModel.write(writer, instance as ExecutorDataModel) + 10 -> Vec.write(writer, instance as Vec) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValuePredicate.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputPredicate.kt similarity index 56% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValuePredicate.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputPredicate.kt index 07e394c00..a7372b445 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ValuePredicate.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryOutputPredicate.kt @@ -15,11 +15,11 @@ import kotlin.Int import kotlin.Unit /** - * ValuePredicate + * QueryOutputPredicate * - * Generated from 'ValuePredicate' enum + * Generated from 'QueryOutputPredicate' enum */ -public sealed class ValuePredicate : ModelEnum { +public sealed class QueryOutputPredicate : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -38,15 +38,15 @@ public sealed class ValuePredicate : ModelEnum { */ public data class Identifiable( public val stringPredicate: StringPredicate, - ) : ValuePredicate() { + ) : QueryOutputPredicate() { 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.ValuePredicate.Identifiable = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Identifiable = try { Identifiable( StringPredicate.read(reader), ) @@ -56,7 +56,7 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Identifiable, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Identifiable, ): Unit = try { StringPredicate.write(writer, instance.stringPredicate) } catch (ex: Exception) { @@ -70,15 +70,15 @@ public sealed class ValuePredicate : ModelEnum { */ public data class Container( public val container: jp.co.soramitsu.iroha2.generated.Container, - ) : ValuePredicate() { + ) : QueryOutputPredicate() { 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.ValuePredicate.Container = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Container = try { Container( jp.co.soramitsu.iroha2.generated.Container.read(reader), ) @@ -88,7 +88,7 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Container, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Container, ): Unit = try { jp.co.soramitsu.iroha2.generated.Container.write(writer, instance.container) } catch (ex: Exception) { @@ -102,15 +102,15 @@ public sealed class ValuePredicate : ModelEnum { */ public data class Display( public val stringPredicate: StringPredicate, - ) : ValuePredicate() { + ) : QueryOutputPredicate() { 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.ValuePredicate.Display = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Display = try { Display( StringPredicate.read(reader), ) @@ -120,7 +120,7 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Display, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Display, ): Unit = try { StringPredicate.write(writer, instance.stringPredicate) } catch (ex: Exception) { @@ -134,15 +134,15 @@ public sealed class ValuePredicate : ModelEnum { */ public data class Numerical( public val semiRange: SemiRange, - ) : ValuePredicate() { + ) : QueryOutputPredicate() { 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.ValuePredicate.Numerical = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Numerical = try { Numerical( SemiRange.read(reader), ) @@ -152,7 +152,7 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Numerical, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Numerical, ): Unit = try { SemiRange.write(writer, instance.semiRange) } catch (ex: Exception) { @@ -166,15 +166,15 @@ public sealed class ValuePredicate : ModelEnum { */ public data class TimeStamp( public val semiIntervalOfu128: SemiIntervalOfu128, - ) : ValuePredicate() { + ) : QueryOutputPredicate() { 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.ValuePredicate.TimeStamp = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.TimeStamp = try { TimeStamp( SemiIntervalOfu128.read(reader), ) @@ -184,7 +184,7 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.TimeStamp, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.TimeStamp, ): Unit = try { SemiIntervalOfu128.write(writer, instance.semiIntervalOfu128) } catch (ex: Exception) { @@ -193,82 +193,18 @@ public sealed class ValuePredicate : ModelEnum { } } - /** - * 'Ipv4Addr' variant - */ - public data class Ipv4Addr( - public val ipv4Predicate: Ipv4Predicate, - ) : ValuePredicate() { - 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.ValuePredicate.Ipv4Addr = try { - Ipv4Addr( - Ipv4Predicate.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Ipv4Addr, - ): Unit = try { - Ipv4Predicate.write(writer, instance.ipv4Predicate) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Ipv6Addr' variant - */ - public data class Ipv6Addr( - public val ipv6Predicate: Ipv6Predicate, - ) : ValuePredicate() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ValuePredicate.Ipv6Addr = try { - Ipv6Addr( - Ipv6Predicate.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Ipv6Addr, - ): Unit = try { - Ipv6Predicate.write(writer, instance.ipv6Predicate) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - /** * 'Pass' variant */ - public class Pass : ValuePredicate() { + public class Pass : QueryOutputPredicate() { override fun discriminant(): Int = DISCRIMINANT public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 5 - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.ValuePredicate.Pass = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Pass = try { Pass() } catch (ex: Exception) { throw wrapException(ex) @@ -276,23 +212,23 @@ public sealed class ValuePredicate : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ValuePredicate.Pass, + instance: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Pass, ): Unit = try { } catch (ex: Exception) { throw wrapException(ex) } - public fun equals(o1: jp.co.soramitsu.iroha2.generated.ValuePredicate.Pass, o2: Any?): Boolean = when (o2) { + public fun equals(o1: jp.co.soramitsu.iroha2.generated.QueryOutputPredicate.Pass, o2: Any?): Boolean = when (o2) { null -> false else -> o2::class == o1::class } - override fun hashCode(): Int = ".ValuePredicate.Pass".hashCode() + override fun hashCode(): Int = ".QueryOutputPredicate.Pass".hashCode() } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ValuePredicate = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryOutputPredicate = when ( val discriminant = reader.readUByte() ) { @@ -301,12 +237,10 @@ public sealed class ValuePredicate : ModelEnum { 2 -> Display.read(reader) 3 -> Numerical.read(reader) 4 -> TimeStamp.read(reader) - 5 -> Ipv4Addr.read(reader) - 6 -> Ipv6Addr.read(reader) - 7 -> Pass.read(reader) + 5 -> Pass.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: ValuePredicate) { + override fun write(writer: ScaleCodecWriter, instance: QueryOutputPredicate) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Identifiable.write(writer, instance as Identifiable) @@ -314,9 +248,7 @@ public sealed class ValuePredicate : ModelEnum { 2 -> Display.write(writer, instance as Display) 3 -> Numerical.write(writer, instance as Numerical) 4 -> TimeStamp.write(writer, instance as TimeStamp) - 5 -> Ipv4Addr.write(writer, instance as Ipv4Addr) - 6 -> Ipv6Addr.write(writer, instance as Ipv6Addr) - 7 -> Pass.write(writer, instance as Pass) + 5 -> Pass.write(writer, instance as Pass) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryParams.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryParams.kt new file mode 100644 index 000000000..b5c257627 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryParams.kt @@ -0,0 +1,42 @@ +// +// 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 + +/** + * QueryParams + * + * Generated from 'QueryParams' regular structure + */ +public data class QueryParams( + public val pagination: Pagination, + public val sorting: Sorting, + public val fetchSize: FetchSize, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryParams = try { + QueryParams( + Pagination.read(reader), + Sorting.read(reader), + FetchSize.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: QueryParams): Unit = try { + Pagination.write(writer, instance.pagination) + Sorting.write(writer, instance.sorting) + FetchSize.write(writer, instance.fetchSize) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequest.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequest.kt new file mode 100644 index 000000000..ff3cfe367 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequest.kt @@ -0,0 +1,141 @@ +// +// 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 + +/** + * QueryRequest + * + * Generated from 'QueryRequest' enum + */ +public sealed class QueryRequest : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Singular' variant + */ + public data class Singular( + public val singularQueryBox: SingularQueryBox, + ) : QueryRequest() { + 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.QueryRequest.Singular = try { + Singular( + SingularQueryBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryRequest.Singular, + ): Unit = try { + SingularQueryBox.write(writer, instance.singularQueryBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Start' variant + */ + public data class Start( + public val queryWithParams: QueryWithParams, + ) : QueryRequest() { + 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.QueryRequest.Start = try { + Start( + QueryWithParams.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryRequest.Start, + ): Unit = try { + QueryWithParams.write(writer, instance.queryWithParams) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Continue' variant + */ + public data class Continue( + public val forwardCursor: ForwardCursor, + ) : QueryRequest() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.QueryRequest.Continue = try { + Continue( + ForwardCursor.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryRequest.Continue, + ): Unit = try { + ForwardCursor.write(writer, instance.forwardCursor) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryRequest = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Singular.read(reader) + 1 -> Start.read(reader) + 2 -> Continue.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: QueryRequest) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Singular.write(writer, instance as Singular) + 1 -> Start.write(writer, instance as Start) + 2 -> Continue.write(writer, instance as Continue) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequestWithAuthority.kt similarity index 53% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryPayload.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequestWithAuthority.kt index 1e365a33e..d5022d5a4 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryPayload.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryRequestWithAuthority.kt @@ -11,30 +11,29 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * QueryPayload + * QueryRequestWithAuthority * - * Generated from 'QueryPayload' regular structure + * Generated from 'QueryRequestWithAuthority' regular structure */ -public data class QueryPayload( +public data class QueryRequestWithAuthority( public val authority: AccountId, - public val query: QueryBox, - public val filter: GenericPredicateBox, + public val request: QueryRequest, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): QueryPayload = try { - QueryPayload( + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryRequestWithAuthority = try { + QueryRequestWithAuthority( AccountId.read(reader), - QueryBox.read(reader), - GenericPredicateBox.read(reader) as GenericPredicateBox, + QueryRequest.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: QueryPayload): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: QueryRequestWithAuthority): Unit = try { AccountId.write(writer, instance.authority) - QueryBox.write(writer, instance.query) - GenericPredicateBox.write(writer, instance.filter) + QueryRequest.write(writer, instance.request) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryResponse.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryResponse.kt new file mode 100644 index 000000000..2d52787a9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryResponse.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * QueryResponse + * + * Generated from 'QueryResponse' enum + */ +public sealed class QueryResponse : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Singular' variant + */ + public data class Singular( + public val singularQueryOutputBox: SingularQueryOutputBox, + ) : QueryResponse() { + 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.QueryResponse.Singular = try { + Singular( + SingularQueryOutputBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryResponse.Singular, + ): Unit = try { + SingularQueryOutputBox.write(writer, instance.singularQueryOutputBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Iterable' variant + */ + public data class Iterable( + public val queryOutput: QueryOutput, + ) : QueryResponse() { + 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.QueryResponse.Iterable = try { + Iterable( + QueryOutput.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.QueryResponse.Iterable, + ): Unit = try { + QueryOutput.write(writer, instance.queryOutput) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryResponse = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Singular.read(reader) + 1 -> Iterable.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: QueryResponse) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Singular.write(writer, instance as Singular) + 1 -> Iterable.write(writer, instance as Iterable) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QuerySignature.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QuerySignature.kt new file mode 100644 index 000000000..7528943ff --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QuerySignature.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * QuerySignature + * + * Generated from 'QuerySignature' regular structure + */ +public data class QuerySignature( + public val signatureOfOfClientQueryPayload: SignatureOf, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QuerySignature = try { + QuerySignature( + SignatureOf.read(reader) as SignatureOf, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: QuerySignature): Unit = try { + SignatureOf.write(writer, instance.signatureOfOfClientQueryPayload) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsAndAccountPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsAndAccountPredicateBox.kt new file mode 100644 index 000000000..a4a51d0ae --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsAndAccountPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindAccountsAndAccountPredicateBox + * + * Generated from 'QueryWithFilterOfFindAccountsAndAccountPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindAccountsAndAccountPredicateBox( + public val query: FindAccounts, + public val predicate: CompoundPredicateOfAccountPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindAccountsAndAccountPredicateBox = try { + QueryWithFilterOfFindAccountsAndAccountPredicateBox( + FindAccounts.read(reader), + CompoundPredicateOfAccountPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindAccountsAndAccountPredicateBox, + ): Unit = try { + FindAccounts.write(writer, instance.query) + CompoundPredicateOfAccountPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox.kt new file mode 100644 index 000000000..9d646852b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox + * + * Generated from 'QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox( + public val query: FindAccountsWithAsset, + public val predicate: CompoundPredicateOfAccountPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox = try { + QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox( + FindAccountsWithAsset.read(reader), + CompoundPredicateOfAccountPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindAccountsWithAssetAndAccountPredicateBox, + ): Unit = try { + FindAccountsWithAsset.write(writer, instance.query) + CompoundPredicateOfAccountPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox.kt new file mode 100644 index 000000000..920c2eaac --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox + * + * Generated from 'QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox( + public val query: FindActiveTriggerIds, + public val predicate: CompoundPredicateOfTriggerIdPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox = try { + QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox( + FindActiveTriggerIds.read(reader), + CompoundPredicateOfTriggerIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindActiveTriggerIdsAndTriggerIdPredicateBox, + ): Unit = try { + FindActiveTriggerIds.write(writer, instance.query) + CompoundPredicateOfTriggerIdPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsAndAssetPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsAndAssetPredicateBox.kt new file mode 100644 index 000000000..ea622c55d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsAndAssetPredicateBox.kt @@ -0,0 +1,45 @@ +// +// 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 + +/** + * QueryWithFilterOfFindAssetsAndAssetPredicateBox + * + * Generated from 'QueryWithFilterOfFindAssetsAndAssetPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindAssetsAndAssetPredicateBox( + public val query: FindAssets, + public val predicate: CompoundPredicateOfAssetPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindAssetsAndAssetPredicateBox = + try { + QueryWithFilterOfFindAssetsAndAssetPredicateBox( + FindAssets.read(reader), + CompoundPredicateOfAssetPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindAssetsAndAssetPredicateBox, + ): Unit = try { + FindAssets.write(writer, instance.query) + CompoundPredicateOfAssetPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox.kt new file mode 100644 index 000000000..c2ab18e3c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox.kt @@ -0,0 +1,45 @@ +// +// 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 + +/** + * QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox + * + * Generated from 'QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox' regular + * structure + */ +public data class QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox( + public val query: FindAssetsDefinitions, + public val predicate: CompoundPredicateOfAssetDefinitionPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox = try { + QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox( + FindAssetsDefinitions.read(reader), + CompoundPredicateOfAssetDefinitionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindAssetsDefinitionsAndAssetDefinitionPredicateBox, + ): Unit = try { + FindAssetsDefinitions.write(writer, instance.query) + CompoundPredicateOfAssetDefinitionPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox.kt new file mode 100644 index 000000000..443a157b9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox + * + * Generated from 'QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox( + public val query: FindBlockHeaders, + public val predicate: CompoundPredicateOfBlockHeaderPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox = try { + QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox( + FindBlockHeaders.read(reader), + CompoundPredicateOfBlockHeaderPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindBlockHeadersAndBlockHeaderPredicateBox, + ): Unit = try { + FindBlockHeaders.write(writer, instance.query) + CompoundPredicateOfBlockHeaderPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox.kt new file mode 100644 index 000000000..1abc8b831 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox + * + * Generated from 'QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox( + public val query: FindBlocks, + public val predicate: CompoundPredicateOfSignedBlockPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox = try { + QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox( + FindBlocks.read(reader), + CompoundPredicateOfSignedBlockPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindBlocksAndSignedBlockPredicateBox, + ): Unit = try { + FindBlocks.write(writer, instance.query) + CompoundPredicateOfSignedBlockPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindDomainsAndDomainPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindDomainsAndDomainPredicateBox.kt new file mode 100644 index 000000000..c006d5f81 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindDomainsAndDomainPredicateBox.kt @@ -0,0 +1,45 @@ +// +// 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 + +/** + * QueryWithFilterOfFindDomainsAndDomainPredicateBox + * + * Generated from 'QueryWithFilterOfFindDomainsAndDomainPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindDomainsAndDomainPredicateBox( + public val query: FindDomains, + public val predicate: CompoundPredicateOfDomainPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindDomainsAndDomainPredicateBox = + try { + QueryWithFilterOfFindDomainsAndDomainPredicateBox( + FindDomains.read(reader), + CompoundPredicateOfDomainPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindDomainsAndDomainPredicateBox, + ): Unit = try { + FindDomains.write(writer, instance.query) + CompoundPredicateOfDomainPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPeersAndPeerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPeersAndPeerPredicateBox.kt new file mode 100644 index 000000000..4946c4665 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPeersAndPeerPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindPeersAndPeerPredicateBox + * + * Generated from 'QueryWithFilterOfFindPeersAndPeerPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindPeersAndPeerPredicateBox( + public val query: FindPeers, + public val predicate: CompoundPredicateOfPeerPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindPeersAndPeerPredicateBox = try { + QueryWithFilterOfFindPeersAndPeerPredicateBox( + FindPeers.read(reader), + CompoundPredicateOfPeerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindPeersAndPeerPredicateBox, + ): Unit = try { + FindPeers.write(writer, instance.query) + CompoundPredicateOfPeerPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox.kt new file mode 100644 index 000000000..ead92ed58 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox.kt @@ -0,0 +1,45 @@ +// +// 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 + +/** + * QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox + * + * Generated from 'QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox' regular + * structure + */ +public data class QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox( + public val query: FindPermissionsByAccountId, + public val predicate: CompoundPredicateOfPermissionPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox = try { + QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox( + FindPermissionsByAccountId.read(reader), + CompoundPredicateOfPermissionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindPermissionsByAccountIdAndPermissionPredicateBox, + ): Unit = try { + FindPermissionsByAccountId.write(writer, instance.query) + CompoundPredicateOfPermissionPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox.kt new file mode 100644 index 000000000..a4c8c3dd9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox.kt @@ -0,0 +1,45 @@ +// +// 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 + +/** + * QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox + * + * Generated from 'QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox( + public val query: FindRoleIds, + public val predicate: CompoundPredicateOfRoleIdPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox = + try { + QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox( + FindRoleIds.read(reader), + CompoundPredicateOfRoleIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindRoleIdsAndRoleIdPredicateBox, + ): Unit = try { + FindRoleIds.write(writer, instance.query) + CompoundPredicateOfRoleIdPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesAndRolePredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesAndRolePredicateBox.kt new file mode 100644 index 000000000..b4704915c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesAndRolePredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindRolesAndRolePredicateBox + * + * Generated from 'QueryWithFilterOfFindRolesAndRolePredicateBox' regular structure + */ +public data class QueryWithFilterOfFindRolesAndRolePredicateBox( + public val query: FindRoles, + public val predicate: CompoundPredicateOfRolePredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindRolesAndRolePredicateBox = try { + QueryWithFilterOfFindRolesAndRolePredicateBox( + FindRoles.read(reader), + CompoundPredicateOfRolePredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindRolesAndRolePredicateBox, + ): Unit = try { + FindRoles.write(writer, instance.query) + CompoundPredicateOfRolePredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox.kt new file mode 100644 index 000000000..5858cb40b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox + * + * Generated from 'QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox( + public val query: FindRolesByAccountId, + public val predicate: CompoundPredicateOfRoleIdPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox = try { + QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox( + FindRolesByAccountId.read(reader), + CompoundPredicateOfRoleIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindRolesByAccountIdAndRoleIdPredicateBox, + ): Unit = try { + FindRolesByAccountId.write(writer, instance.query) + CompoundPredicateOfRoleIdPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox.kt new file mode 100644 index 000000000..e3981ae9b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox.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.Unit + +/** + * QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox + * + * Generated from 'QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox' regular + * structure + */ +public data class QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox( + public val query: FindTransactions, + public val predicate: CompoundPredicateOfTransactionQueryOutputPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox = try { + QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox( + FindTransactions.read(reader), + CompoundPredicateOfTransactionQueryOutputPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindTransactionsAndTransactionQueryOutputPredicateBox, + ): Unit = + try { + FindTransactions.write(writer, instance.query) + CompoundPredicateOfTransactionQueryOutputPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTriggersAndTriggerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTriggersAndTriggerPredicateBox.kt new file mode 100644 index 000000000..37f3623d4 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithFilterOfFindTriggersAndTriggerPredicateBox.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * QueryWithFilterOfFindTriggersAndTriggerPredicateBox + * + * Generated from 'QueryWithFilterOfFindTriggersAndTriggerPredicateBox' regular structure + */ +public data class QueryWithFilterOfFindTriggersAndTriggerPredicateBox( + public val query: FindTriggers, + public val predicate: CompoundPredicateOfTriggerPredicateBox, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithFilterOfFindTriggersAndTriggerPredicateBox = try { + QueryWithFilterOfFindTriggersAndTriggerPredicateBox( + FindTriggers.read(reader), + CompoundPredicateOfTriggerPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: QueryWithFilterOfFindTriggersAndTriggerPredicateBox, + ): Unit = try { + FindTriggers.write(writer, instance.query) + CompoundPredicateOfTriggerPredicateBox.write(writer, instance.predicate) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithParams.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithParams.kt new file mode 100644 index 000000000..9005e17be --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/QueryWithParams.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 + +/** + * QueryWithParams + * + * Generated from 'QueryWithParams' regular structure + */ +public data class QueryWithParams( + public val query: QueryBox, + public val params: QueryParams, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): QueryWithParams = try { + QueryWithParams( + QueryBox.read(reader), + QueryParams.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: QueryWithParams): Unit = try { + QueryBox.write(writer, instance.query) + QueryParams.write(writer, instance.params) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RaiseTo.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RaiseTo.kt deleted file mode 100644 index a0c9ba0f2..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RaiseTo.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 - -/** - * RaiseTo - * - * Generated from 'RaiseTo' regular structure - */ -public data class RaiseTo( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RaiseTo = try { - RaiseTo( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: RaiseTo): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} 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 deleted file mode 100644 index 6ed1cb2db..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisBlock.kt +++ /dev/null @@ -1,46 +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 -import kotlin.collections.List - -/** - * RawGenesisBlock - * - * Generated from 'RawGenesisBlock' regular structure - */ -public data class RawGenesisBlock( - 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()) { InstructionExpr.read(reader) } }, - ExecutorMode.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: RawGenesisBlock): Unit = try { - writer.writeCompact(instance.transactions.size) - instance.transactions.forEach { value -> - writer.writeCompact(value.size) - value.forEach { value -> - InstructionExpr.write(writer, value) - } - } - ExecutorMode.write(writer, instance.executor) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisTransaction.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisTransaction.kt new file mode 100644 index 000000000..46c194d64 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RawGenesisTransaction.kt @@ -0,0 +1,59 @@ +// +// 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.String +import kotlin.Unit +import kotlin.collections.List + +/** + * RawGenesisTransaction + * + * Generated from 'RawGenesisTransaction' regular structure + */ +public data class RawGenesisTransaction( + public val chain: ChainId, + public val executor: String, + public val parameters: List, + public val instructions: List, + public val topology: List, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RawGenesisTransaction = try { + RawGenesisTransaction( + ChainId.read(reader), + reader.readString(), + reader.readVec(reader.readCompactInt()) { Parameter.read(reader) }, + reader.readVec(reader.readCompactInt()) { InstructionBox.read(reader) }, + reader.readVec(reader.readCompactInt()) { PeerId.read(reader) }, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RawGenesisTransaction): Unit = try { + ChainId.write(writer, instance.chain) + writer.writeAsList(instance.executor.toByteArray(Charsets.UTF_8)) + writer.writeCompact(instance.parameters.size) + instance.parameters.forEach { value -> + Parameter.write(writer, value) + } + writer.writeCompact(instance.instructions.size) + instance.instructions.forEach { value -> + InstructionBox.write(writer, value) + } + writer.writeCompact(instance.topology.size) + instance.topology.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/RegistrableBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterBox.kt similarity index 63% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegistrableBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterBox.kt index acb40bf5a..e7f11559a 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/RegisterBox.kt @@ -13,11 +13,11 @@ import kotlin.Int import kotlin.Unit /** - * RegistrableBox + * RegisterBox * - * Generated from 'RegistrableBox' enum + * Generated from 'RegisterBox' enum */ -public sealed class RegistrableBox : ModelEnum { +public sealed class RegisterBox : ModelEnum { /** * @return Discriminator of variant in enum */ @@ -27,18 +27,18 @@ public sealed class RegistrableBox : ModelEnum { * 'Peer' variant */ public data class Peer( - public val peer: jp.co.soramitsu.iroha2.generated.Peer, - ) : RegistrableBox() { + public val registerOfPeer: RegisterOfPeer, + ) : RegisterBox() { 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.RegistrableBox.Peer = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Peer = try { Peer( - jp.co.soramitsu.iroha2.generated.Peer.read(reader), + RegisterOfPeer.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Peer, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Peer, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Peer.write(writer, instance.peer) + RegisterOfPeer.write(writer, instance.registerOfPeer) } catch (ex: Exception) { throw wrapException(ex) } @@ -59,18 +59,18 @@ public sealed class RegistrableBox : ModelEnum { * 'Domain' variant */ public data class Domain( - public val newDomain: NewDomain, - ) : RegistrableBox() { + public val registerOfDomain: RegisterOfDomain, + ) : RegisterBox() { 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.RegistrableBox.Domain = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Domain = try { Domain( - NewDomain.read(reader), + RegisterOfDomain.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,9 +78,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Domain, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Domain, ): Unit = try { - NewDomain.write(writer, instance.newDomain) + RegisterOfDomain.write(writer, instance.registerOfDomain) } catch (ex: Exception) { throw wrapException(ex) } @@ -91,18 +91,18 @@ public sealed class RegistrableBox : ModelEnum { * 'Account' variant */ public data class Account( - public val newAccount: NewAccount, - ) : RegistrableBox() { + public val registerOfAccount: RegisterOfAccount, + ) : RegisterBox() { 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.RegistrableBox.Account = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Account = try { Account( - NewAccount.read(reader), + RegisterOfAccount.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -110,9 +110,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Account, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Account, ): Unit = try { - NewAccount.write(writer, instance.newAccount) + RegisterOfAccount.write(writer, instance.registerOfAccount) } catch (ex: Exception) { throw wrapException(ex) } @@ -123,18 +123,18 @@ public sealed class RegistrableBox : ModelEnum { * 'AssetDefinition' variant */ public data class AssetDefinition( - public val newAssetDefinition: NewAssetDefinition, - ) : RegistrableBox() { + public val registerOfAssetDefinition: RegisterOfAssetDefinition, + ) : RegisterBox() { 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.RegistrableBox.AssetDefinition = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.AssetDefinition = try { AssetDefinition( - NewAssetDefinition.read(reader), + RegisterOfAssetDefinition.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -142,9 +142,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.AssetDefinition, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.AssetDefinition, ): Unit = try { - NewAssetDefinition.write(writer, instance.newAssetDefinition) + RegisterOfAssetDefinition.write(writer, instance.registerOfAssetDefinition) } catch (ex: Exception) { throw wrapException(ex) } @@ -155,18 +155,18 @@ public sealed class RegistrableBox : ModelEnum { * 'Asset' variant */ public data class Asset( - public val asset: jp.co.soramitsu.iroha2.generated.Asset, - ) : RegistrableBox() { + public val registerOfAsset: RegisterOfAsset, + ) : RegisterBox() { 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.RegistrableBox.Asset = try { + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Asset = try { Asset( - jp.co.soramitsu.iroha2.generated.Asset.read(reader), + RegisterOfAsset.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -174,9 +174,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Asset, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Asset, ): Unit = try { - jp.co.soramitsu.iroha2.generated.Asset.write(writer, instance.asset) + RegisterOfAsset.write(writer, instance.registerOfAsset) } catch (ex: Exception) { throw wrapException(ex) } @@ -184,21 +184,21 @@ public sealed class RegistrableBox : ModelEnum { } /** - * 'Trigger' variant + * 'Role' variant */ - public data class Trigger( - public val triggerOfTriggeringFilterBox: TriggerOfTriggeringFilterBox, - ) : RegistrableBox() { + public data class Role( + public val registerOfRole: RegisterOfRole, + ) : RegisterBox() { 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.RegistrableBox.Trigger = try { - Trigger( - TriggerOfTriggeringFilterBox.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Role = try { + Role( + RegisterOfRole.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -206,9 +206,9 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Trigger, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Role, ): Unit = try { - TriggerOfTriggeringFilterBox.write(writer, instance.triggerOfTriggeringFilterBox) + RegisterOfRole.write(writer, instance.registerOfRole) } catch (ex: Exception) { throw wrapException(ex) } @@ -216,21 +216,21 @@ public sealed class RegistrableBox : ModelEnum { } /** - * 'Role' variant + * 'Trigger' variant */ - public data class Role( - public val newRole: NewRole, - ) : RegistrableBox() { + public data class Trigger( + public val registerOfTrigger: RegisterOfTrigger, + ) : RegisterBox() { 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.RegistrableBox.Role = try { - Role( - NewRole.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RegisterBox.Trigger = try { + Trigger( + RegisterOfTrigger.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -238,17 +238,17 @@ public sealed class RegistrableBox : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RegistrableBox.Role, + instance: jp.co.soramitsu.iroha2.generated.RegisterBox.Trigger, ): Unit = try { - NewRole.write(writer, instance.newRole) + RegisterOfTrigger.write(writer, instance.registerOfTrigger) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RegistrableBox = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterBox = when ( val discriminant = reader.readUByte() ) { @@ -257,11 +257,11 @@ public sealed class RegistrableBox : ModelEnum { 2 -> Account.read(reader) 3 -> AssetDefinition.read(reader) 4 -> Asset.read(reader) - 5 -> Trigger.read(reader) - 6 -> Role.read(reader) + 5 -> Role.read(reader) + 6 -> Trigger.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: RegistrableBox) { + override fun write(writer: ScaleCodecWriter, instance: RegisterBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { 0 -> Peer.write(writer, instance as Peer) @@ -269,8 +269,8 @@ public sealed class RegistrableBox : ModelEnum { 2 -> Account.write(writer, instance as Account) 3 -> AssetDefinition.write(writer, instance as AssetDefinition) 4 -> Asset.write(writer, instance as Asset) - 5 -> Trigger.write(writer, instance as Trigger) - 6 -> Role.write(writer, instance as Role) + 5 -> Role.write(writer, instance as Role) + 6 -> Trigger.write(writer, instance as Trigger) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAccount.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAccount.kt index 612db06ce..c363b6de8 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAccount.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * RegisterExpr + * RegisterOfAccount * - * Generated from 'RegisterExpr' regular structure + * Generated from 'RegisterOfAccount' regular structure */ -public data class RegisterExpr( - public val `object`: EvaluatesTo, +public data class RegisterOfAccount( + public val `object`: NewAccount, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RegisterExpr = try { - RegisterExpr( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfAccount = try { + RegisterOfAccount( + NewAccount.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: RegisterExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) + override fun write(writer: ScaleCodecWriter, instance: RegisterOfAccount): Unit = try { + NewAccount.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAsset.kt new file mode 100644 index 000000000..e396d10a5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAsset.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * RegisterOfAsset + * + * Generated from 'RegisterOfAsset' regular structure + */ +public data class RegisterOfAsset( + public val `object`: Asset, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfAsset = try { + RegisterOfAsset( + Asset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RegisterOfAsset): Unit = try { + Asset.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAssetDefinition.kt new file mode 100644 index 000000000..b10f8253d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfAssetDefinition.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * RegisterOfAssetDefinition + * + * Generated from 'RegisterOfAssetDefinition' regular structure + */ +public data class RegisterOfAssetDefinition( + public val `object`: NewAssetDefinition, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfAssetDefinition = try { + RegisterOfAssetDefinition( + NewAssetDefinition.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RegisterOfAssetDefinition): Unit = try { + NewAssetDefinition.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfDomain.kt new file mode 100644 index 000000000..0ac22fac3 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfDomain.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * RegisterOfDomain + * + * Generated from 'RegisterOfDomain' regular structure + */ +public data class RegisterOfDomain( + public val `object`: NewDomain, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfDomain = try { + RegisterOfDomain( + NewDomain.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RegisterOfDomain): Unit = try { + NewDomain.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfPeer.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfPeer.kt new file mode 100644 index 000000000..d737b9d71 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfPeer.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * RegisterOfPeer + * + * Generated from 'RegisterOfPeer' regular structure + */ +public data class RegisterOfPeer( + public val `object`: Peer, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfPeer = try { + RegisterOfPeer( + Peer.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RegisterOfPeer): Unit = try { + Peer.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewRole.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfRole.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewRole.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfRole.kt index 65fd641fb..365468328 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/NewRole.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfRole.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * NewRole + * RegisterOfRole * - * Generated from 'NewRole' regular structure + * Generated from 'RegisterOfRole' regular structure */ -public data class NewRole( - public val `inner`: Role, +public data class RegisterOfRole( + public val `object`: Role, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): NewRole = try { - NewRole( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfRole = try { + RegisterOfRole( Role.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: NewRole): Unit = try { - Role.write(writer, instance.`inner`) + override fun write(writer: ScaleCodecWriter, instance: RegisterOfRole): Unit = try { + Role.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfTrigger.kt new file mode 100644 index 000000000..df06f66b7 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RegisterOfTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * RegisterOfTrigger + * + * Generated from 'RegisterOfTrigger' regular structure + */ +public data class RegisterOfTrigger( + public val `object`: Trigger, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RegisterOfTrigger = try { + RegisterOfTrigger( + Trigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RegisterOfTrigger): Unit = try { + Trigger.write(writer, instance.`object`) + } 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/RemoveKeyValueBox.kt new file mode 100644 index 000000000..79c343373 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueBox.kt @@ -0,0 +1,209 @@ +// +// 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 + +/** + * RemoveKeyValueBox + * + * Generated from 'RemoveKeyValueBox' enum + */ +public sealed class RemoveKeyValueBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Domain' variant + */ + public data class Domain( + public val removeKeyValueOfDomain: RemoveKeyValueOfDomain, + ) : RemoveKeyValueBox() { + 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.RemoveKeyValueBox.Domain = try { + Domain( + RemoveKeyValueOfDomain.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.Domain, + ): Unit = try { + RemoveKeyValueOfDomain.write(writer, instance.removeKeyValueOfDomain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Account' variant + */ + public data class Account( + public val removeKeyValueOfAccount: RemoveKeyValueOfAccount, + ) : RemoveKeyValueBox() { + 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.RemoveKeyValueBox.Account = try { + Account( + RemoveKeyValueOfAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.Account, + ): Unit = try { + RemoveKeyValueOfAccount.write(writer, instance.removeKeyValueOfAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val removeKeyValueOfAssetDefinition: RemoveKeyValueOfAssetDefinition, + ) : RemoveKeyValueBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.AssetDefinition = try { + AssetDefinition( + RemoveKeyValueOfAssetDefinition.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.AssetDefinition, + ): Unit = try { + RemoveKeyValueOfAssetDefinition.write(writer, instance.removeKeyValueOfAssetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val removeKeyValueOfAsset: RemoveKeyValueOfAsset, + ) : RemoveKeyValueBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.Asset = try { + Asset( + RemoveKeyValueOfAsset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.Asset, + ): Unit = try { + RemoveKeyValueOfAsset.write(writer, instance.removeKeyValueOfAsset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val removeKeyValueOfTrigger: RemoveKeyValueOfTrigger, + ) : RemoveKeyValueBox() { + 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.RemoveKeyValueBox.Trigger = try { + Trigger( + RemoveKeyValueOfTrigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RemoveKeyValueBox.Trigger, + ): Unit = try { + RemoveKeyValueOfTrigger.write(writer, instance.removeKeyValueOfTrigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Domain.read(reader) + 1 -> Account.read(reader) + 2 -> AssetDefinition.read(reader) + 3 -> Asset.read(reader) + 4 -> Trigger.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Domain.write(writer, instance as Domain) + 1 -> Account.write(writer, instance as Account) + 2 -> AssetDefinition.write(writer, instance as AssetDefinition) + 3 -> Asset.write(writer, instance as Asset) + 4 -> Trigger.write(writer, instance as Trigger) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAccount.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAccount.kt index d15252320..0dd32975f 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAccount.kt @@ -11,27 +11,29 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * RemoveKeyValueExpr + * RemoveKeyValueOfAccount * - * Generated from 'RemoveKeyValueExpr' regular structure + * Generated from 'RemoveKeyValueOfAccount' regular structure */ -public data class RemoveKeyValueExpr( - public val objectId: EvaluatesTo, - public val key: EvaluatesTo, +public data class RemoveKeyValueOfAccount( + public val `object`: AccountId, + public val key: Name, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RemoveKeyValueExpr = try { - RemoveKeyValueExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueOfAccount = try { + RemoveKeyValueOfAccount( + AccountId.read(reader), + Name.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueExpr): Unit = try { - EvaluatesTo.write(writer, instance.objectId) - EvaluatesTo.write(writer, instance.key) + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueOfAccount): Unit = try { + AccountId.write(writer, instance.`object`) + Name.write(writer, instance.key) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAsset.kt new file mode 100644 index 000000000..40b180b03 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAsset.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 + +/** + * RemoveKeyValueOfAsset + * + * Generated from 'RemoveKeyValueOfAsset' regular structure + */ +public data class RemoveKeyValueOfAsset( + public val `object`: AssetId, + public val key: Name, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueOfAsset = try { + RemoveKeyValueOfAsset( + AssetId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueOfAsset): Unit = try { + AssetId.write(writer, instance.`object`) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAssetDefinition.kt new file mode 100644 index 000000000..29112f1e2 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfAssetDefinition.kt @@ -0,0 +1,42 @@ +// +// 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 + +/** + * RemoveKeyValueOfAssetDefinition + * + * Generated from 'RemoveKeyValueOfAssetDefinition' regular structure + */ +public data class RemoveKeyValueOfAssetDefinition( + public val `object`: AssetDefinitionId, + public val key: Name, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueOfAssetDefinition = try { + RemoveKeyValueOfAssetDefinition( + AssetDefinitionId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueOfAssetDefinition): Unit = + try { + AssetDefinitionId.write(writer, instance.`object`) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfDomain.kt new file mode 100644 index 000000000..ff8e6d616 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfDomain.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 + +/** + * RemoveKeyValueOfDomain + * + * Generated from 'RemoveKeyValueOfDomain' regular structure + */ +public data class RemoveKeyValueOfDomain( + public val `object`: DomainId, + public val key: Name, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueOfDomain = try { + RemoveKeyValueOfDomain( + DomainId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueOfDomain): Unit = try { + DomainId.write(writer, instance.`object`) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfTrigger.kt new file mode 100644 index 000000000..a56c4aef6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RemoveKeyValueOfTrigger.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 + +/** + * RemoveKeyValueOfTrigger + * + * Generated from 'RemoveKeyValueOfTrigger' regular structure + */ +public data class RemoveKeyValueOfTrigger( + public val `object`: TriggerId, + public val key: Name, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RemoveKeyValueOfTrigger = try { + RemoveKeyValueOfTrigger( + TriggerId.read(reader), + Name.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RemoveKeyValueOfTrigger): Unit = try { + TriggerId.write(writer, instance.`object`) + Name.write(writer, instance.key) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RepetitionError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RepetitionError.kt index fe4b31479..a06f9d5fb 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RepetitionError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RepetitionError.kt @@ -16,7 +16,7 @@ import kotlin.Unit * Generated from 'RepetitionError' regular structure */ public data class RepetitionError( - public val instructionType: InstructionType, + public val instruction: InstructionType, public val id: IdBox, ) { public companion object : ScaleReader, ScaleWriter { @@ -30,7 +30,7 @@ public data class RepetitionError( } override fun write(writer: ScaleCodecWriter, instance: RepetitionError): Unit = try { - InstructionType.write(writer, instance.instructionType) + InstructionType.write(writer, instance.instruction) IdBox.write(writer, instance.id) } catch (ex: Exception) { throw wrapException(ex) 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/RevokeBox.kt new file mode 100644 index 000000000..d33a4d908 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeBox.kt @@ -0,0 +1,142 @@ +// +// 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 + +/** + * RevokeBox + * + * Generated from 'RevokeBox' enum + */ +public sealed class RevokeBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Permission' variant + */ + public data class Permission( + public val revokeOfPermissionAndAccount: RevokeOfPermissionAndAccount, + ) : RevokeBox() { + 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.RevokeBox.Permission = try { + Permission( + RevokeOfPermissionAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RevokeBox.Permission, + ): Unit = try { + RevokeOfPermissionAndAccount.write(writer, instance.revokeOfPermissionAndAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Role' variant + */ + public data class Role( + public val revokeOfRoleIdAndAccount: RevokeOfRoleIdAndAccount, + ) : RevokeBox() { + 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.RevokeBox.Role = + try { + Role( + RevokeOfRoleIdAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RevokeBox.Role, + ): Unit = try { + RevokeOfRoleIdAndAccount.write(writer, instance.revokeOfRoleIdAndAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'RolePermission' variant + */ + public data class RolePermission( + public val revokeOfPermissionAndRole: RevokeOfPermissionAndRole, + ) : RevokeBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RevokeBox.RolePermission = try { + RolePermission( + RevokeOfPermissionAndRole.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RevokeBox.RolePermission, + ): Unit = try { + RevokeOfPermissionAndRole.write(writer, instance.revokeOfPermissionAndRole) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RevokeBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Permission.read(reader) + 1 -> Role.read(reader) + 2 -> RolePermission.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: RevokeBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Permission.write(writer, instance as Permission) + 1 -> Role.write(writer, instance as Role) + 2 -> RolePermission.write(writer, instance as RolePermission) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.kt deleted file mode 100644 index fff39018f..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeExpr.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 - -/** - * RevokeExpr - * - * Generated from 'RevokeExpr' regular structure - */ -public data class RevokeExpr( - public val `object`: EvaluatesTo, - public val destinationId: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RevokeExpr = try { - RevokeExpr( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: RevokeExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) - EvaluatesTo.write(writer, instance.destinationId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndAccount.kt new file mode 100644 index 000000000..4c9ad2cb6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndAccount.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 + +/** + * RevokeOfPermissionAndAccount + * + * Generated from 'RevokeOfPermissionAndAccount' regular structure + */ +public data class RevokeOfPermissionAndAccount( + public val `object`: Permission, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RevokeOfPermissionAndAccount = try { + RevokeOfPermissionAndAccount( + Permission.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RevokeOfPermissionAndAccount): Unit = try { + Permission.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndRole.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndRole.kt new file mode 100644 index 000000000..6fe6d70cd --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfPermissionAndRole.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 + +/** + * RevokeOfPermissionAndRole + * + * Generated from 'RevokeOfPermissionAndRole' regular structure + */ +public data class RevokeOfPermissionAndRole( + public val `object`: Permission, + public val destination: RoleId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RevokeOfPermissionAndRole = try { + RevokeOfPermissionAndRole( + Permission.read(reader), + RoleId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RevokeOfPermissionAndRole): Unit = try { + Permission.write(writer, instance.`object`) + RoleId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfRoleIdAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfRoleIdAndAccount.kt new file mode 100644 index 000000000..7387e7dec --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RevokeOfRoleIdAndAccount.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 + +/** + * RevokeOfRoleIdAndAccount + * + * Generated from 'RevokeOfRoleIdAndAccount' regular structure + */ +public data class RevokeOfRoleIdAndAccount( + public val `object`: RoleId, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): RevokeOfRoleIdAndAccount = try { + RevokeOfRoleIdAndAccount( + RoleId.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RevokeOfRoleIdAndAccount): Unit = try { + RoleId.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Role.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Role.kt index fafcaff1a..4356646b9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Role.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Role.kt @@ -19,13 +19,13 @@ import kotlin.collections.List */ public data class Role( public val id: RoleId, - public val permissions: List, + public val permissions: List, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Role = try { Role( RoleId.read(reader), - reader.readVec(reader.readCompactInt()) { PermissionToken.read(reader) }, + reader.readVec(reader.readCompactInt()) { Permission.read(reader) }, ) } catch (ex: Exception) { throw wrapException(ex) @@ -35,9 +35,9 @@ public data class Role( RoleId.write(writer, instance.id) writer.writeCompact(instance.permissions.size) instance.permissions.sortedWith( - PermissionToken.comparator(), + Permission.comparator(), ).forEach { value -> - PermissionToken.write(writer, value) + Permission.write(writer, value) } } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEvent.kt index 5a2bf76f5..aaba5e3b2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEvent.kt @@ -87,22 +87,54 @@ public sealed class RoleEvent : ModelEnum { } } + /** + * 'PermissionAdded' variant + */ + public data class PermissionAdded( + public val rolePermissionChanged: RolePermissionChanged, + ) : RoleEvent() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RoleEvent.PermissionAdded = try { + PermissionAdded( + RolePermissionChanged.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RoleEvent.PermissionAdded, + ): Unit = try { + RolePermissionChanged.write(writer, instance.rolePermissionChanged) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + /** * 'PermissionRemoved' variant */ public data class PermissionRemoved( - public val permissionRemoved: jp.co.soramitsu.iroha2.generated.PermissionRemoved, + public val rolePermissionChanged: RolePermissionChanged, ) : RoleEvent() { override fun discriminant(): Int = DISCRIMINANT public companion object : ScaleReader, ScaleWriter { - public const val DISCRIMINANT: Int = 2 + public const val DISCRIMINANT: Int = 3 override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RoleEvent.PermissionRemoved = try { PermissionRemoved( - jp.co.soramitsu.iroha2.generated.PermissionRemoved.read(reader), + RolePermissionChanged.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -112,7 +144,7 @@ public sealed class RoleEvent : ModelEnum { writer: ScaleCodecWriter, instance: jp.co.soramitsu.iroha2.generated.RoleEvent.PermissionRemoved, ): Unit = try { - jp.co.soramitsu.iroha2.generated.PermissionRemoved.write(writer, instance.permissionRemoved) + RolePermissionChanged.write(writer, instance.rolePermissionChanged) } catch (ex: Exception) { throw wrapException(ex) } @@ -126,7 +158,8 @@ public sealed class RoleEvent : ModelEnum { ) { 0 -> Created.read(reader) 1 -> Deleted.read(reader) - 2 -> PermissionRemoved.read(reader) + 2 -> PermissionAdded.read(reader) + 3 -> PermissionRemoved.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: RoleEvent) { @@ -134,7 +167,8 @@ public sealed class RoleEvent : ModelEnum { when (val discriminant = instance.discriminant()) { 0 -> Created.write(writer, instance as Created) 1 -> Deleted.write(writer, instance as Deleted) - 2 -> PermissionRemoved.write(writer, instance as PermissionRemoved) + 2 -> PermissionAdded.write(writer, instance as PermissionAdded) + 3 -> PermissionRemoved.write(writer, instance as PermissionRemoved) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEventFilter.kt index 3ca09ceab..09e852602 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleEventFilter.kt @@ -3,163 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * RoleEventFilter * - * Generated from 'RoleEventFilter' enum + * Generated from 'RoleEventFilter' regular structure */ -public sealed class RoleEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByPermissionRemoved -> ByPermissionRemoved.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByPermissionRemoved -> ByPermissionRemoved.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : RoleEventFilter() { - 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.RoleEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByCreated, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByCreated, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".RoleEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : RoleEventFilter() { - 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.RoleEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByDeleted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals(o1: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByDeleted, o2: Any?): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".RoleEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByPermissionRemoved' variant - */ - public class ByPermissionRemoved : RoleEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByPermissionRemoved = try { - ByPermissionRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByPermissionRemoved, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.RoleEventFilter.ByPermissionRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".RoleEventFilter.ByPermissionRemoved".hashCode() - } - } - +public data class RoleEventFilter( + public val idMatcher: RoleId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RoleEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByDeleted.read(reader) - 2 -> ByPermissionRemoved.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): RoleEventFilter = try { + RoleEventFilter( + reader.readNullable(RoleId) as RoleId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } - override fun write(writer: ScaleCodecWriter, instance: RoleEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByDeleted.write(writer, instance as ByDeleted) - 2 -> ByPermissionRemoved.write(writer, instance as ByPermissionRemoved) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun write(writer: ScaleCodecWriter, instance: RoleEventFilter): Unit = try { + writer.writeNullable(RoleId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleFilter.kt deleted file mode 100644 index 16c291093..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleFilter.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 - -/** - * RoleFilter - * - * Generated from 'RoleFilter' regular structure - */ -public data class RoleFilter( - public val originFilter: FilterOptOfOriginFilterOfRoleEvent, - public val eventFilter: FilterOptOfRoleEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): RoleFilter = try { - RoleFilter( - FilterOptOfOriginFilterOfRoleEvent.read(reader), - FilterOptOfRoleEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: RoleFilter): Unit = try { - FilterOptOfOriginFilterOfRoleEvent.write(writer, instance.originFilter) - FilterOptOfRoleEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleIdPredicateBox.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleIdPredicateBox.kt index ec7d70d66..b135134c4 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/ExecutorMode.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RoleIdPredicateBox.kt @@ -10,36 +10,35 @@ 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.String import kotlin.Unit /** - * ExecutorMode + * RoleIdPredicateBox * - * Generated from 'ExecutorMode' enum + * Generated from 'RoleIdPredicateBox' enum */ -public sealed class ExecutorMode : ModelEnum { +public sealed class RoleIdPredicateBox : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'Path' variant + * 'Equals' variant */ - public data class Path( - public val string: String, - ) : ExecutorMode() { + public data class Equals( + public val roleId: RoleId, + ) : RoleIdPredicateBox() { 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.ExecutorMode.Path = try { - Path( - reader.readString(), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RoleIdPredicateBox.Equals = try { + Equals( + RoleId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -47,9 +46,9 @@ public sealed class ExecutorMode : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ExecutorMode.Path, + instance: jp.co.soramitsu.iroha2.generated.RoleIdPredicateBox.Equals, ): Unit = try { - writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) + RoleId.write(writer, instance.roleId) } catch (ex: Exception) { throw wrapException(ex) } @@ -57,21 +56,21 @@ public sealed class ExecutorMode : ModelEnum { } /** - * 'Inline' variant + * 'Name' variant */ - public data class Inline( - public val executor: Executor, - ) : ExecutorMode() { + public data class Name( + public val stringPredicateBox: StringPredicateBox, + ) : RoleIdPredicateBox() { 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.ExecutorMode.Inline = try { - Inline( - Executor.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.RoleIdPredicateBox.Name = try { + Name( + StringPredicateBox.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -79,29 +78,29 @@ public sealed class ExecutorMode : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.ExecutorMode.Inline, + instance: jp.co.soramitsu.iroha2.generated.RoleIdPredicateBox.Name, ): Unit = try { - Executor.write(writer, instance.executor) + StringPredicateBox.write(writer, instance.stringPredicateBox) } catch (ex: Exception) { throw wrapException(ex) } } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): ExecutorMode = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RoleIdPredicateBox = when ( val discriminant = reader.readUByte() ) { - 0 -> Path.read(reader) - 1 -> Inline.read(reader) + 0 -> Equals.read(reader) + 1 -> Name.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: ExecutorMode) { + override fun write(writer: ScaleCodecWriter, instance: RoleIdPredicateBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Path.write(writer, instance as Path) - 1 -> Inline.write(writer, instance as Inline) + 0 -> Equals.write(writer, instance as Equals) + 1 -> Name.write(writer, instance as Name) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePermissionChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePermissionChanged.kt new file mode 100644 index 000000000..035ef8d14 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePermissionChanged.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 + +/** + * RolePermissionChanged + * + * Generated from 'RolePermissionChanged' regular structure + */ +public data class RolePermissionChanged( + public val role: RoleId, + public val permission: Permission, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RolePermissionChanged = try { + RolePermissionChanged( + RoleId.read(reader), + Permission.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: RolePermissionChanged): Unit = try { + RoleId.write(writer, instance.role) + Permission.write(writer, instance.permission) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePredicateBox.kt new file mode 100644 index 000000000..a7cbdd9a5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/RolePredicateBox.kt @@ -0,0 +1,73 @@ +// +// 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 + +/** + * RolePredicateBox + * + * Generated from 'RolePredicateBox' enum + */ +public sealed class RolePredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val roleIdPredicateBox: RoleIdPredicateBox, + ) : RolePredicateBox() { + 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.RolePredicateBox.Id = try { + Id( + RoleIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.RolePredicateBox.Id, + ): Unit = try { + RoleIdPredicateBox.write(writer, instance.roleIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): RolePredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: RolePredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Schedule.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Schedule.kt index e3df3fdc2..32d3d9d0a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Schedule.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Schedule.kt @@ -8,6 +8,7 @@ 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 java.math.BigInteger import kotlin.Unit /** @@ -16,22 +17,22 @@ import kotlin.Unit * Generated from 'Schedule' regular structure */ public data class Schedule( - public val start: Duration, - public val period: Duration? = null, + public val startMs: BigInteger, + public val periodMs: BigInteger? = null, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Schedule = try { Schedule( - Duration.read(reader), - reader.readNullable(Duration) as Duration?, + reader.readUint64(), + reader.readNullable(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: Schedule): Unit = try { - Duration.write(writer, instance.start) - writer.writeNullable(Duration, instance.period) + writer.writeUint64(instance.startMs) + writer.writeNullable(instance.periodMs) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfFixed.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfNumeric.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfFixed.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfNumeric.kt index 288b63e01..1a07dae75 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfFixed.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfNumeric.kt @@ -11,27 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * SemiIntervalOfFixed + * SemiIntervalOfNumeric * - * Generated from 'SemiIntervalOfFixed' regular structure + * Generated from 'SemiIntervalOfNumeric' regular structure */ -public data class SemiIntervalOfFixed( - public val start: Fixed, - public val limit: Fixed, +public data class SemiIntervalOfNumeric( + public val start: Numeric, + public val limit: Numeric, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SemiIntervalOfFixed = try { - SemiIntervalOfFixed( - Fixed.read(reader), - Fixed.read(reader), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SemiIntervalOfNumeric = try { + SemiIntervalOfNumeric( + Numeric.read(reader), + Numeric.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SemiIntervalOfFixed): Unit = try { - Fixed.write(writer, instance.start) - Fixed.write(writer, instance.limit) + override fun write(writer: ScaleCodecWriter, instance: SemiIntervalOfNumeric): Unit = try { + Numeric.write(writer, instance.start) + Numeric.write(writer, instance.limit) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfu32.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfu32.kt deleted file mode 100644 index 2cffb5626..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiIntervalOfu32.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.Long -import kotlin.Unit - -/** - * SemiIntervalOfu32 - * - * Generated from 'SemiIntervalOfu32' regular structure - */ -public data class SemiIntervalOfu32( - public val start: Long, - public val limit: Long, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SemiIntervalOfu32 = try { - SemiIntervalOfu32( - reader.readUint32(), - reader.readUint32(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: SemiIntervalOfu32): Unit = try { - writer.writeUint32(instance.start) - writer.writeUint32(instance.limit) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiRange.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiRange.kt index 6783f045d..c562ab382 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiRange.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SemiRange.kt @@ -24,87 +24,21 @@ public sealed class SemiRange : ModelEnum { public abstract fun discriminant(): Int /** - * 'U32' variant + * 'Numeric' variant */ - public data class U32( - public val semiIntervalOfu32: SemiIntervalOfu32, + public data class Numeric( + public val semiIntervalOfNumeric: SemiIntervalOfNumeric, ) : SemiRange() { 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.SemiRange.U32 = - try { - U32( - SemiIntervalOfu32.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.SemiRange.U32, - ): Unit = try { - SemiIntervalOfu32.write(writer, instance.semiIntervalOfu32) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'U128' variant - */ - public data class U128( - public val semiIntervalOfu128: SemiIntervalOfu128, - ) : SemiRange() { - 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.SemiRange.U128 = - try { - U128( - SemiIntervalOfu128.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.SemiRange.U128, - ): Unit = try { - SemiIntervalOfu128.write(writer, instance.semiIntervalOfu128) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Fixed' variant - */ - public data class Fixed( - public val semiIntervalOfFixed: SemiIntervalOfFixed, - ) : SemiRange() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SemiRange.Fixed = try { - Fixed( - SemiIntervalOfFixed.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SemiRange.Numeric = try { + Numeric( + SemiIntervalOfNumeric.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -112,9 +46,9 @@ public sealed class SemiRange : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.SemiRange.Fixed, + instance: jp.co.soramitsu.iroha2.generated.SemiRange.Numeric, ): Unit = try { - SemiIntervalOfFixed.write(writer, instance.semiIntervalOfFixed) + SemiIntervalOfNumeric.write(writer, instance.semiIntervalOfNumeric) } catch (ex: Exception) { throw wrapException(ex) } @@ -126,17 +60,13 @@ public sealed class SemiRange : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> U32.read(reader) - 1 -> U128.read(reader) - 2 -> Fixed.read(reader) + 0 -> Numeric.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: SemiRange) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> U32.write(writer, instance as U32) - 1 -> U128.write(writer, instance as U128) - 2 -> Fixed.write(writer, instance as Fixed) + 0 -> Numeric.write(writer, instance as Numeric) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.kt deleted file mode 100644 index 237dec6fb..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SequenceExpr.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.Unit -import kotlin.collections.List - -/** - * SequenceExpr - * - * Generated from 'SequenceExpr' regular structure - */ -public data class SequenceExpr( - public val instructions: List, -) { - 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: SequenceExpr): Unit = try { - writer.writeCompact(instance.instructions.size) - instance.instructions.forEach { 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/SetKeyValueBox.kt new file mode 100644 index 000000000..c19a76f64 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueBox.kt @@ -0,0 +1,209 @@ +// +// 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 + +/** + * SetKeyValueBox + * + * Generated from 'SetKeyValueBox' enum + */ +public sealed class SetKeyValueBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Domain' variant + */ + public data class Domain( + public val setKeyValueOfDomain: SetKeyValueOfDomain, + ) : SetKeyValueBox() { + 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.SetKeyValueBox.Domain = try { + Domain( + SetKeyValueOfDomain.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SetKeyValueBox.Domain, + ): Unit = try { + SetKeyValueOfDomain.write(writer, instance.setKeyValueOfDomain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Account' variant + */ + public data class Account( + public val setKeyValueOfAccount: SetKeyValueOfAccount, + ) : SetKeyValueBox() { + 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.SetKeyValueBox.Account = try { + Account( + SetKeyValueOfAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SetKeyValueBox.Account, + ): Unit = try { + SetKeyValueOfAccount.write(writer, instance.setKeyValueOfAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val setKeyValueOfAssetDefinition: SetKeyValueOfAssetDefinition, + ) : SetKeyValueBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SetKeyValueBox.AssetDefinition = try { + AssetDefinition( + SetKeyValueOfAssetDefinition.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SetKeyValueBox.AssetDefinition, + ): Unit = try { + SetKeyValueOfAssetDefinition.write(writer, instance.setKeyValueOfAssetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val setKeyValueOfAsset: SetKeyValueOfAsset, + ) : SetKeyValueBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SetKeyValueBox.Asset = try { + Asset( + SetKeyValueOfAsset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SetKeyValueBox.Asset, + ): Unit = try { + SetKeyValueOfAsset.write(writer, instance.setKeyValueOfAsset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val setKeyValueOfTrigger: SetKeyValueOfTrigger, + ) : SetKeyValueBox() { + 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.SetKeyValueBox.Trigger = try { + Trigger( + SetKeyValueOfTrigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SetKeyValueBox.Trigger, + ): Unit = try { + SetKeyValueOfTrigger.write(writer, instance.setKeyValueOfTrigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Domain.read(reader) + 1 -> Account.read(reader) + 2 -> AssetDefinition.read(reader) + 3 -> Asset.read(reader) + 4 -> Trigger.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Domain.write(writer, instance as Domain) + 1 -> Account.write(writer, instance as Account) + 2 -> AssetDefinition.write(writer, instance as AssetDefinition) + 3 -> Asset.write(writer, instance as Asset) + 4 -> Trigger.write(writer, instance as Trigger) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.kt deleted file mode 100644 index 85424f801..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueExpr.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 - -/** - * SetKeyValueExpr - * - * Generated from 'SetKeyValueExpr' regular structure - */ -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): SetKeyValueExpr = try { - SetKeyValueExpr( - 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: SetKeyValueExpr): Unit = try { - EvaluatesTo.write(writer, instance.objectId) - EvaluatesTo.write(writer, instance.key) - EvaluatesTo.write(writer, instance.`value`) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAccount.kt new file mode 100644 index 000000000..efad75449 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAccount.kt @@ -0,0 +1,43 @@ +// +// 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.String +import kotlin.Unit + +/** + * SetKeyValueOfAccount + * + * Generated from 'SetKeyValueOfAccount' regular structure + */ +public data class SetKeyValueOfAccount( + public val `object`: AccountId, + public val key: Name, + public val `value`: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueOfAccount = try { + SetKeyValueOfAccount( + AccountId.read(reader), + Name.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueOfAccount): Unit = try { + AccountId.write(writer, instance.`object`) + Name.write(writer, instance.key) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAsset.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAsset.kt new file mode 100644 index 000000000..2320c7fb3 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAsset.kt @@ -0,0 +1,43 @@ +// +// 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.String +import kotlin.Unit + +/** + * SetKeyValueOfAsset + * + * Generated from 'SetKeyValueOfAsset' regular structure + */ +public data class SetKeyValueOfAsset( + public val `object`: AssetId, + public val key: Name, + public val `value`: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueOfAsset = try { + SetKeyValueOfAsset( + AssetId.read(reader), + Name.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueOfAsset): Unit = try { + AssetId.write(writer, instance.`object`) + Name.write(writer, instance.key) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAssetDefinition.kt new file mode 100644 index 000000000..eb8709d8a --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfAssetDefinition.kt @@ -0,0 +1,45 @@ +// +// 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.String +import kotlin.Unit + +/** + * SetKeyValueOfAssetDefinition + * + * Generated from 'SetKeyValueOfAssetDefinition' regular structure + */ +public data class SetKeyValueOfAssetDefinition( + public val `object`: AssetDefinitionId, + public val key: Name, + public val `value`: String, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueOfAssetDefinition = try { + SetKeyValueOfAssetDefinition( + AssetDefinitionId.read(reader), + Name.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueOfAssetDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.`object`) + Name.write(writer, instance.key) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfDomain.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfDomain.kt new file mode 100644 index 000000000..10db30b74 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfDomain.kt @@ -0,0 +1,43 @@ +// +// 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.String +import kotlin.Unit + +/** + * SetKeyValueOfDomain + * + * Generated from 'SetKeyValueOfDomain' regular structure + */ +public data class SetKeyValueOfDomain( + public val `object`: DomainId, + public val key: Name, + public val `value`: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueOfDomain = try { + SetKeyValueOfDomain( + DomainId.read(reader), + Name.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueOfDomain): Unit = try { + DomainId.write(writer, instance.`object`) + Name.write(writer, instance.key) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfTrigger.kt new file mode 100644 index 000000000..4fdf66491 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetKeyValueOfTrigger.kt @@ -0,0 +1,43 @@ +// +// 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.String +import kotlin.Unit + +/** + * SetKeyValueOfTrigger + * + * Generated from 'SetKeyValueOfTrigger' regular structure + */ +public data class SetKeyValueOfTrigger( + public val `object`: TriggerId, + public val key: Name, + public val `value`: String, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetKeyValueOfTrigger = try { + SetKeyValueOfTrigger( + TriggerId.read(reader), + Name.read(reader), + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SetKeyValueOfTrigger): Unit = try { + TriggerId.write(writer, instance.`object`) + Name.write(writer, instance.key) + writer.writeAsList(instance.`value`.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameter.kt similarity index 59% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameter.kt index 3b8f842a4..6c4bf13ac 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameterExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SetParameter.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * SetParameterExpr + * SetParameter * - * Generated from 'SetParameterExpr' regular structure + * Generated from 'SetParameter' regular structure */ -public data class SetParameterExpr( - public val parameter: EvaluatesTo, +public data class SetParameter( + public val parameter: Parameter, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SetParameterExpr = try { - SetParameterExpr( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SetParameter = try { + SetParameter( + Parameter.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SetParameterExpr): Unit = try { - EvaluatesTo.write(writer, instance.parameter) + override fun write(writer: ScaleCodecWriter, instance: SetParameter): Unit = try { + Parameter.write(writer, instance.parameter) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Signature.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Signature.kt index 9af68061e..0a4d8663c 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Signature.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Signature.kt @@ -8,7 +8,10 @@ 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.ByteArray +import kotlin.Int import kotlin.Unit /** @@ -17,13 +20,20 @@ import kotlin.Unit * Generated from 'Signature' regular structure */ public data class Signature( - public val publicKey: PublicKey, public val payload: ByteArray, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is Signature) return false + if (!payload.contentEquals(other.payload)) return false + return true + } + + override fun hashCode(): Int = payload.contentHashCode() + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): Signature = try { Signature( - PublicKey.read(reader), reader.readByteArray(), ) } catch (ex: Exception) { @@ -31,7 +41,6 @@ public data class Signature( } override fun write(writer: ScaleCodecWriter, instance: Signature): Unit = try { - PublicKey.write(writer, instance.publicKey) writer.writeAsList(instance.payload) } 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 deleted file mode 100644 index 17ee559d8..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignatureCheckCondition.kt +++ /dev/null @@ -1,116 +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 - -/** - * SignatureCheckCondition - * - * Generated from 'SignatureCheckCondition' enum - */ -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 = 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) { - 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/SignaturesOfOfBlockPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfBlockPayload.kt deleted file mode 100644 index 7430296b9..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfBlockPayload.kt +++ /dev/null @@ -1,48 +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.comparator -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit -import kotlin.collections.List - -/** - * SignaturesOfOfBlockPayload - * - * Generated from 'SignaturesOfOfBlockPayload' regular structure - */ -public data class SignaturesOfOfBlockPayload( - public val signatures: List>, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): SignaturesOfOfBlockPayload = try { - SignaturesOfOfBlockPayload( - reader.readVec(reader.readCompactInt()) { - SignatureOf.read(reader) as - SignatureOf - }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: SignaturesOfOfBlockPayload): Unit = try { - writer.writeCompact(instance.signatures.size) - instance.signatures.sortedWith( - SignatureOf.comparator(), - ).forEach { value -> - SignatureOf.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfTransactionPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfTransactionPayload.kt deleted file mode 100644 index 546694b13..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignaturesOfOfTransactionPayload.kt +++ /dev/null @@ -1,49 +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.comparator -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit -import kotlin.collections.List - -/** - * SignaturesOfOfTransactionPayload - * - * Generated from 'SignaturesOfOfTransactionPayload' regular structure - */ -public data class SignaturesOfOfTransactionPayload( - public val signatures: List>, -) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): SignaturesOfOfTransactionPayload = try { - SignaturesOfOfTransactionPayload( - reader.readVec(reader.readCompactInt()) { - SignatureOf.read(reader) as - SignatureOf - }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: SignaturesOfOfTransactionPayload): Unit = - try { - writer.writeCompact(instance.signatures.size) - instance.signatures.sortedWith( - SignatureOf.comparator(), - ).forEach { value -> - SignatureOf.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockPredicateBox.kt new file mode 100644 index 000000000..57b480932 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedBlockPredicateBox.kt @@ -0,0 +1,75 @@ +// +// 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 + +/** + * SignedBlockPredicateBox + * + * Generated from 'SignedBlockPredicateBox' enum + */ +public sealed class SignedBlockPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Header' variant + */ + public data class Header( + public val blockHeaderPredicateBox: BlockHeaderPredicateBox, + ) : SignedBlockPredicateBox() { + 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.SignedBlockPredicateBox.Header = try { + Header( + BlockHeaderPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignedBlockPredicateBox.Header, + ): Unit = try { + BlockHeaderPredicateBox.write(writer, instance.blockHeaderPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedBlockPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Header.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SignedBlockPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Header.write(writer, instance as Header) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} 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 index f09cae599..01a858097 100644 --- 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 @@ -9,6 +9,7 @@ import jp.co.soramitsu.iroha2.codec.ScaleReader import jp.co.soramitsu.iroha2.codec.ScaleWriter import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit +import kotlin.collections.List /** * SignedBlockV1 @@ -16,13 +17,13 @@ import kotlin.Unit * Generated from 'SignedBlockV1' regular structure */ public data class SignedBlockV1( - public val signatures: SignaturesOfOfBlockPayload, + public val signatures: List, public val payload: BlockPayload, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): SignedBlockV1 = try { SignedBlockV1( - SignaturesOfOfBlockPayload.read(reader), + reader.readVec(reader.readCompactInt()) { BlockSignature.read(reader) }, BlockPayload.read(reader), ) } catch (ex: Exception) { @@ -30,7 +31,10 @@ public data class SignedBlockV1( } override fun write(writer: ScaleCodecWriter, instance: SignedBlockV1): Unit = try { - SignaturesOfOfBlockPayload.write(writer, instance.signatures) + writer.writeCompact(instance.signatures.size) + instance.signatures.forEach { value -> + BlockSignature.write(writer, value) + } BlockPayload.write(writer, instance.payload) } catch (ex: Exception) { throw wrapException(ex) 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 index f483dd170..26b05dc30 100644 --- 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 @@ -16,22 +16,22 @@ import kotlin.Unit * Generated from 'SignedQueryV1' regular structure */ public data class SignedQueryV1( - public val signature: SignatureOf, - public val payload: QueryPayload, + public val signature: QuerySignature, + public val payload: ClientQueryPayload, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): SignedQueryV1 = try { SignedQueryV1( - SignatureOf.read(reader) as SignatureOf, - QueryPayload.read(reader), + QuerySignature.read(reader), + ClientQueryPayload.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) + QuerySignature.write(writer, instance.signature) + ClientQueryPayload.write(writer, instance.payload) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionPredicateBox.kt new file mode 100644 index 000000000..14b8caa70 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SignedTransactionPredicateBox.kt @@ -0,0 +1,109 @@ +// +// 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 + +/** + * SignedTransactionPredicateBox + * + * Generated from 'SignedTransactionPredicateBox' enum + */ +public sealed class SignedTransactionPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Hash' variant + */ + public data class Hash( + public val transactionHashPredicateBox: TransactionHashPredicateBox, + ) : SignedTransactionPredicateBox() { + 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.SignedTransactionPredicateBox.Hash = try { + Hash( + TransactionHashPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignedTransactionPredicateBox.Hash, + ): Unit = try { + TransactionHashPredicateBox.write(writer, instance.transactionHashPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Authority' variant + */ + public data class Authority( + public val accountIdPredicateBox: AccountIdPredicateBox, + ) : SignedTransactionPredicateBox() { + 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.SignedTransactionPredicateBox.Authority = try { + Authority( + AccountIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SignedTransactionPredicateBox.Authority, + ): Unit = try { + AccountIdPredicateBox.write(writer, instance.accountIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): SignedTransactionPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Hash.read(reader) + 1 -> Authority.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SignedTransactionPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Hash.write(writer, instance as Hash) + 1 -> Authority.write(writer, instance as Authority) + 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 index 063f577d6..b34eb9e7b 100644 --- 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 @@ -16,13 +16,13 @@ import kotlin.Unit * Generated from 'SignedTransactionV1' regular structure */ public data class SignedTransactionV1( - public val signatures: SignaturesOfOfTransactionPayload, + public val signature: TransactionSignature, public val payload: TransactionPayload, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): SignedTransactionV1 = try { SignedTransactionV1( - SignaturesOfOfTransactionPayload.read(reader), + TransactionSignature.read(reader), TransactionPayload.read(reader), ) } catch (ex: Exception) { @@ -30,7 +30,7 @@ public data class SignedTransactionV1( } override fun write(writer: ScaleCodecWriter, instance: SignedTransactionV1): Unit = try { - SignaturesOfOfTransactionPayload.write(writer, instance.signatures) + TransactionSignature.write(writer, instance.signature) TransactionPayload.write(writer, instance.payload) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryBox.kt new file mode 100644 index 000000000..ec13110e5 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryBox.kt @@ -0,0 +1,335 @@ +// +// 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 + +/** + * SingularQueryBox + * + * Generated from 'SingularQueryBox' enum + */ +public sealed class SingularQueryBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'FindAssetQuantityById' variant + */ + public data class FindAssetQuantityById( + public val findAssetQuantityById: jp.co.soramitsu.iroha2.generated.FindAssetQuantityById, + ) : SingularQueryBox() { + 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.SingularQueryBox.FindAssetQuantityById = try { + FindAssetQuantityById( + jp.co.soramitsu.iroha2.generated.FindAssetQuantityById.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindAssetQuantityById, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindAssetQuantityById.write( + writer, + instance.findAssetQuantityById, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindExecutorDataModel' variant + */ + public data class FindExecutorDataModel( + public val findExecutorDataModel: jp.co.soramitsu.iroha2.generated.FindExecutorDataModel, + ) : SingularQueryBox() { + 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.SingularQueryBox.FindExecutorDataModel = try { + FindExecutorDataModel( + jp.co.soramitsu.iroha2.generated.FindExecutorDataModel.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindExecutorDataModel, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindExecutorDataModel.write( + writer, + instance.findExecutorDataModel, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindParameters' variant + */ + public data class FindParameters( + public val findParameters: jp.co.soramitsu.iroha2.generated.FindParameters, + ) : SingularQueryBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindParameters = try { + FindParameters( + jp.co.soramitsu.iroha2.generated.FindParameters.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindParameters, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.FindParameters.write(writer, instance.findParameters) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindDomainMetadata' variant + */ + public data class FindDomainMetadata( + public val findDomainMetadata: jp.co.soramitsu.iroha2.generated.FindDomainMetadata, + ) : SingularQueryBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindDomainMetadata = try { + FindDomainMetadata( + jp.co.soramitsu.iroha2.generated.FindDomainMetadata.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindDomainMetadata, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindDomainMetadata.write( + writer, + instance.findDomainMetadata, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindAccountMetadata' variant + */ + public data class FindAccountMetadata( + public val findAccountMetadata: jp.co.soramitsu.iroha2.generated.FindAccountMetadata, + ) : SingularQueryBox() { + 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.SingularQueryBox.FindAccountMetadata = try { + FindAccountMetadata( + jp.co.soramitsu.iroha2.generated.FindAccountMetadata.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindAccountMetadata, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindAccountMetadata.write( + writer, + instance.findAccountMetadata, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindAssetMetadata' variant + */ + public data class FindAssetMetadata( + public val findAssetMetadata: jp.co.soramitsu.iroha2.generated.FindAssetMetadata, + ) : SingularQueryBox() { + 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.SingularQueryBox.FindAssetMetadata = try { + FindAssetMetadata( + jp.co.soramitsu.iroha2.generated.FindAssetMetadata.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindAssetMetadata, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.FindAssetMetadata.write(writer, instance.findAssetMetadata) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindAssetDefinitionMetadata' variant + */ + public data class FindAssetDefinitionMetadata( + public val findAssetDefinitionMetadata: + jp.co.soramitsu.iroha2.generated.FindAssetDefinitionMetadata, + ) : SingularQueryBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindAssetDefinitionMetadata = try { + FindAssetDefinitionMetadata( + jp.co.soramitsu.iroha2.generated.FindAssetDefinitionMetadata.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindAssetDefinitionMetadata, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.FindAssetDefinitionMetadata.write( + writer, + instance.findAssetDefinitionMetadata, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'FindTriggerMetadata' variant + */ + public data class FindTriggerMetadata( + public val findTriggerMetadata: jp.co.soramitsu.iroha2.generated.FindTriggerMetadata, + ) : SingularQueryBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 7 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindTriggerMetadata = try { + FindTriggerMetadata( + jp.co.soramitsu.iroha2.generated.FindTriggerMetadata.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryBox.FindTriggerMetadata, + ): Unit = + try { + jp.co.soramitsu.iroha2.generated.FindTriggerMetadata.write( + writer, + instance.findTriggerMetadata, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SingularQueryBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> FindAssetQuantityById.read(reader) + 1 -> FindExecutorDataModel.read(reader) + 2 -> FindParameters.read(reader) + 3 -> FindDomainMetadata.read(reader) + 4 -> FindAccountMetadata.read(reader) + 5 -> FindAssetMetadata.read(reader) + 6 -> FindAssetDefinitionMetadata.read(reader) + 7 -> FindTriggerMetadata.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SingularQueryBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> FindAssetQuantityById.write(writer, instance as FindAssetQuantityById) + 1 -> FindExecutorDataModel.write(writer, instance as FindExecutorDataModel) + 2 -> FindParameters.write(writer, instance as FindParameters) + 3 -> FindDomainMetadata.write(writer, instance as FindDomainMetadata) + 4 -> FindAccountMetadata.write(writer, instance as FindAccountMetadata) + 5 -> FindAssetMetadata.write(writer, instance as FindAssetMetadata) + 6 -> FindAssetDefinitionMetadata.write(writer, instance as FindAssetDefinitionMetadata) + 7 -> FindTriggerMetadata.write(writer, instance as FindTriggerMetadata) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryOutputBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryOutputBox.kt new file mode 100644 index 000000000..8e21942a4 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SingularQueryOutputBox.kt @@ -0,0 +1,278 @@ +// +// 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.String +import kotlin.Unit + +/** + * SingularQueryOutputBox + * + * Generated from 'SingularQueryOutputBox' enum + */ +public sealed class SingularQueryOutputBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Numeric' variant + */ + public data class Numeric( + public val numeric: jp.co.soramitsu.iroha2.generated.Numeric, + ) : SingularQueryOutputBox() { + 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.SingularQueryOutputBox.Numeric = try { + Numeric( + jp.co.soramitsu.iroha2.generated.Numeric.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.Numeric, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Numeric.write(writer, instance.numeric) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'ExecutorDataModel' variant + */ + public data class ExecutorDataModel( + public val executorDataModel: jp.co.soramitsu.iroha2.generated.ExecutorDataModel, + ) : SingularQueryOutputBox() { + 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.SingularQueryOutputBox.ExecutorDataModel = try { + ExecutorDataModel( + jp.co.soramitsu.iroha2.generated.ExecutorDataModel.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.ExecutorDataModel, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.ExecutorDataModel.write(writer, instance.executorDataModel) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'JsonString' variant + */ + public data class JsonString( + public val string: String, + ) : SingularQueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.JsonString = try { + JsonString( + reader.readString(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.JsonString, + ): Unit = try { + writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val trigger: jp.co.soramitsu.iroha2.generated.Trigger, + ) : SingularQueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.Trigger = try { + Trigger( + jp.co.soramitsu.iroha2.generated.Trigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.Trigger, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Trigger.write(writer, instance.trigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Parameters' variant + */ + public data class Parameters( + public val parameters: jp.co.soramitsu.iroha2.generated.Parameters, + ) : SingularQueryOutputBox() { + 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.SingularQueryOutputBox.Parameters = try { + Parameters( + jp.co.soramitsu.iroha2.generated.Parameters.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.Parameters, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.Parameters.write(writer, instance.parameters) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Transaction' variant + */ + public data class Transaction( + public val transactionQueryOutput: TransactionQueryOutput, + ) : SingularQueryOutputBox() { + 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.SingularQueryOutputBox.Transaction = try { + Transaction( + TransactionQueryOutput.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.Transaction, + ): Unit = try { + TransactionQueryOutput.write(writer, instance.transactionQueryOutput) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'BlockHeader' variant + */ + public data class BlockHeader( + public val blockHeader: jp.co.soramitsu.iroha2.generated.BlockHeader, + ) : SingularQueryOutputBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.BlockHeader = try { + BlockHeader( + jp.co.soramitsu.iroha2.generated.BlockHeader.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SingularQueryOutputBox.BlockHeader, + ): Unit = try { + jp.co.soramitsu.iroha2.generated.BlockHeader.write(writer, instance.blockHeader) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SingularQueryOutputBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Numeric.read(reader) + 1 -> ExecutorDataModel.read(reader) + 2 -> JsonString.read(reader) + 3 -> Trigger.read(reader) + 4 -> Parameters.read(reader) + 5 -> Transaction.read(reader) + 6 -> BlockHeader.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SingularQueryOutputBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Numeric.write(writer, instance as Numeric) + 1 -> ExecutorDataModel.write(writer, instance as ExecutorDataModel) + 2 -> JsonString.write(writer, instance as JsonString) + 3 -> Trigger.write(writer, instance as Trigger) + 4 -> Parameters.write(writer, instance as Parameters) + 5 -> Transaction.write(writer, instance as Transaction) + 6 -> BlockHeader.write(writer, instance as BlockHeader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameter.kt new file mode 100644 index 000000000..afc27ff0d --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameter.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * SmartContractParameter + * + * Generated from 'SmartContractParameter' enum + */ +public sealed class SmartContractParameter : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Fuel' variant + */ + public data class Fuel( + public val nonZeroOfu64: NonZeroOfu64, + ) : SmartContractParameter() { + 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.SmartContractParameter.Fuel = try { + Fuel( + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SmartContractParameter.Fuel, + ): Unit = try { + NonZeroOfu64.write(writer, instance.nonZeroOfu64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Memory' variant + */ + public data class Memory( + public val nonZeroOfu64: NonZeroOfu64, + ) : SmartContractParameter() { + 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.SmartContractParameter.Memory = try { + Memory( + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SmartContractParameter.Memory, + ): Unit = try { + NonZeroOfu64.write(writer, instance.nonZeroOfu64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SmartContractParameter = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Fuel.read(reader) + 1 -> Memory.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SmartContractParameter) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Fuel.write(writer, instance as Fuel) + 1 -> Memory.write(writer, instance as Memory) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameters.kt new file mode 100644 index 000000000..a3e22b873 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SmartContractParameters.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 + +/** + * SmartContractParameters + * + * Generated from 'SmartContractParameters' regular structure + */ +public data class SmartContractParameters( + public val fuel: NonZeroOfu64, + public val memory: NonZeroOfu64, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): SmartContractParameters = try { + SmartContractParameters( + NonZeroOfu64.read(reader), + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SmartContractParameters): Unit = try { + NonZeroOfu64.write(writer, instance.fuel) + NonZeroOfu64.write(writer, instance.memory) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SizeError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Sorting.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SizeError.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Sorting.kt index 8e373aaab..288ecf551 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SizeError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Sorting.kt @@ -8,31 +8,27 @@ 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 java.math.BigInteger import kotlin.Unit /** - * SizeError + * Sorting * - * Generated from 'SizeError' regular structure + * Generated from 'Sorting' regular structure */ -public data class SizeError( - public val limits: Limits, - public val `actual`: BigInteger, +public data class Sorting( + public val sortByMetadataKey: Name? = null, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): SizeError = try { - SizeError( - Limits.read(reader), - reader.readUint64(), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Sorting = try { + Sorting( + reader.readNullable(Name) as Name?, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: SizeError): Unit = try { - Limits.write(writer, instance.limits) - writer.writeUint64(instance.`actual`) + override fun write(writer: ScaleCodecWriter, instance: Sorting): Unit = try { + writer.writeNullable(Name, instance.sortByMetadataKey) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluationError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringPredicateBox.kt similarity index 54% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluationError.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringPredicateBox.kt index 1af25deb6..d2e8c6820 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/EvaluationError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/StringPredicateBox.kt @@ -14,32 +14,32 @@ import kotlin.String import kotlin.Unit /** - * EvaluationError + * StringPredicateBox * - * Generated from 'EvaluationError' enum + * Generated from 'StringPredicateBox' enum */ -public sealed class EvaluationError : ModelEnum { +public sealed class StringPredicateBox : ModelEnum { /** * @return Discriminator of variant in enum */ public abstract fun discriminant(): Int /** - * 'Math' variant + * 'Equals' variant */ - public data class Math( - public val mathError: MathError, - ) : EvaluationError() { + public data class Equals( + public val string: String, + ) : StringPredicateBox() { 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.EvaluationError.Math = try { - Math( - MathError.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.StringPredicateBox.Equals = try { + Equals( + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) @@ -47,9 +47,9 @@ public sealed class EvaluationError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.EvaluationError.Math, + instance: jp.co.soramitsu.iroha2.generated.StringPredicateBox.Equals, ): Unit = try { - MathError.write(writer, instance.mathError) + writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } @@ -57,21 +57,21 @@ public sealed class EvaluationError : ModelEnum { } /** - * 'Validation' variant + * 'Contains' variant */ - public data class Validation( - public val validationFail: ValidationFail, - ) : EvaluationError() { + public data class Contains( + public val string: String, + ) : StringPredicateBox() { 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.EvaluationError.Validation = try { - Validation( - ValidationFail.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.StringPredicateBox.Contains = try { + Contains( + reader.readString(), ) } catch (ex: Exception) { throw wrapException(ex) @@ -79,9 +79,9 @@ public sealed class EvaluationError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.EvaluationError.Validation, + instance: jp.co.soramitsu.iroha2.generated.StringPredicateBox.Contains, ): Unit = try { - ValidationFail.write(writer, instance.validationFail) + writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { throw wrapException(ex) } @@ -89,20 +89,20 @@ public sealed class EvaluationError : ModelEnum { } /** - * 'Find' variant + * 'StartsWith' variant */ - public data class Find( + public data class StartsWith( public val string: String, - ) : EvaluationError() { + ) : StringPredicateBox() { 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.EvaluationError.Find = try { - Find( + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.StringPredicateBox.StartsWith = try { + StartsWith( reader.readString(), ) } catch (ex: Exception) { @@ -111,7 +111,7 @@ public sealed class EvaluationError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.EvaluationError.Find, + instance: jp.co.soramitsu.iroha2.generated.StringPredicateBox.StartsWith, ): Unit = try { writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { @@ -121,20 +121,20 @@ public sealed class EvaluationError : ModelEnum { } /** - * 'Conversion' variant + * 'EndsWith' variant */ - public data class Conversion( + public data class EndsWith( public val string: String, - ) : EvaluationError() { + ) : StringPredicateBox() { 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.EvaluationError.Conversion = try { - Conversion( + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.StringPredicateBox.EndsWith = try { + EndsWith( reader.readString(), ) } catch (ex: Exception) { @@ -143,7 +143,7 @@ public sealed class EvaluationError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.EvaluationError.Conversion, + instance: jp.co.soramitsu.iroha2.generated.StringPredicateBox.EndsWith, ): Unit = try { writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) } catch (ex: Exception) { @@ -152,24 +152,24 @@ public sealed class EvaluationError : ModelEnum { } } - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): EvaluationError = when ( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): StringPredicateBox = when ( val discriminant = reader.readUByte() ) { - 0 -> Math.read(reader) - 1 -> Validation.read(reader) - 2 -> Find.read(reader) - 3 -> Conversion.read(reader) + 0 -> Equals.read(reader) + 1 -> Contains.read(reader) + 2 -> StartsWith.read(reader) + 3 -> EndsWith.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - override fun write(writer: ScaleCodecWriter, instance: EvaluationError) { + override fun write(writer: ScaleCodecWriter, instance: StringPredicateBox) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> Math.write(writer, instance as Math) - 1 -> Validation.write(writer, instance as Validation) - 2 -> Find.write(writer, instance as Find) - 3 -> Conversion.write(writer, instance as Conversion) + 0 -> Equals.write(writer, instance as Equals) + 1 -> Contains.write(writer, instance as Contains) + 2 -> StartsWith.write(writer, instance as StartsWith) + 3 -> EndsWith.write(writer, instance as EndsWith) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Subtract.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Subtract.kt deleted file mode 100644 index 02013d9ca..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Subtract.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 - -/** - * Subtract - * - * Generated from 'Subtract' regular structure - */ -public data class Subtract( - public val left: EvaluatesTo, - public val right: EvaluatesTo, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Subtract = try { - Subtract( - EvaluatesTo.read(reader) as EvaluatesTo, - EvaluatesTo.read(reader) as EvaluatesTo, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Subtract): Unit = try { - EvaluatesTo.write(writer, instance.left) - EvaluatesTo.write(writer, instance.right) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameter.kt new file mode 100644 index 000000000..a5dd27fc9 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameter.kt @@ -0,0 +1,142 @@ +// +// 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 java.math.BigInteger +import kotlin.Int +import kotlin.Unit + +/** + * SumeragiParameter + * + * Generated from 'SumeragiParameter' enum + */ +public sealed class SumeragiParameter : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'BlockTimeMs' variant + */ + public data class BlockTimeMs( + public val u64: BigInteger, + ) : SumeragiParameter() { + 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.SumeragiParameter.BlockTimeMs = try { + BlockTimeMs( + reader.readUint64(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SumeragiParameter.BlockTimeMs, + ): Unit = try { + writer.writeUint64(instance.u64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'CommitTimeMs' variant + */ + public data class CommitTimeMs( + public val u64: BigInteger, + ) : SumeragiParameter() { + 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.SumeragiParameter.CommitTimeMs = try { + CommitTimeMs( + reader.readUint64(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SumeragiParameter.CommitTimeMs, + ): Unit = try { + writer.writeUint64(instance.u64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'MaxClockDriftMs' variant + */ + public data class MaxClockDriftMs( + public val u64: BigInteger, + ) : SumeragiParameter() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.SumeragiParameter.MaxClockDriftMs = try { + MaxClockDriftMs( + reader.readUint64(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.SumeragiParameter.MaxClockDriftMs, + ): Unit = try { + writer.writeUint64(instance.u64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SumeragiParameter = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> BlockTimeMs.read(reader) + 1 -> CommitTimeMs.read(reader) + 2 -> MaxClockDriftMs.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: SumeragiParameter) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> BlockTimeMs.write(writer, instance as BlockTimeMs) + 1 -> CommitTimeMs.write(writer, instance as CommitTimeMs) + 2 -> MaxClockDriftMs.write(writer, instance as MaxClockDriftMs) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameters.kt new file mode 100644 index 000000000..3ef3f285f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/SumeragiParameters.kt @@ -0,0 +1,43 @@ +// +// 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 java.math.BigInteger +import kotlin.Unit + +/** + * SumeragiParameters + * + * Generated from 'SumeragiParameters' regular structure + */ +public data class SumeragiParameters( + public val blockTimeMs: BigInteger, + public val commitTimeMs: BigInteger, + public val maxClockDriftMs: BigInteger, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): SumeragiParameters = try { + SumeragiParameters( + reader.readUint64(), + reader.readUint64(), + reader.readUint64(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: SumeragiParameters): Unit = try { + writer.writeUint64(instance.blockTimeMs) + writer.writeUint64(instance.commitTimeMs) + writer.writeUint64(instance.maxClockDriftMs) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TimeInterval.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TimeInterval.kt index 8d4efff8d..a40d795a9 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TimeInterval.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TimeInterval.kt @@ -8,6 +8,7 @@ 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 java.math.BigInteger import kotlin.Unit /** @@ -16,22 +17,22 @@ import kotlin.Unit * Generated from 'TimeInterval' regular structure */ public data class TimeInterval( - public val since: Duration, - public val length: Duration, + public val sinceMs: BigInteger, + public val lengthMs: BigInteger, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TimeInterval = try { TimeInterval( - Duration.read(reader), - Duration.read(reader), + reader.readUint64(), + reader.readUint64(), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: TimeInterval): Unit = try { - Duration.write(writer, instance.since) - Duration.write(writer, instance.length) + writer.writeUint64(instance.sinceMs) + writer.writeUint64(instance.lengthMs) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionErrorPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionErrorPredicateBox.kt new file mode 100644 index 000000000..dba72f60f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionErrorPredicateBox.kt @@ -0,0 +1,91 @@ +// +// 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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * TransactionErrorPredicateBox + * + * Generated from 'TransactionErrorPredicateBox' enum + */ +public sealed class TransactionErrorPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + override fun equals(other: Any?): Boolean = when (this) { + is IsSome -> IsSome.equals(this, other) + else -> super.equals(other) } + + override fun hashCode(): Int = when (this) { + is IsSome -> IsSome.hashCode() + else -> super.hashCode() } + + /** + * 'IsSome' variant + */ + public class IsSome : TransactionErrorPredicateBox() { + 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.TransactionErrorPredicateBox.IsSome = try { + IsSome() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionErrorPredicateBox.IsSome, + ): Unit = + try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals( + o1: jp.co.soramitsu.iroha2.generated.TransactionErrorPredicateBox.IsSome, + o2: Any?, + ): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".TransactionErrorPredicateBox.IsSome".hashCode() + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionErrorPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> IsSome.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransactionErrorPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> IsSome.write(writer, instance as IsSome) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEvent.kt new file mode 100644 index 000000000..7983c2327 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEvent.kt @@ -0,0 +1,42 @@ +// +// 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 + +/** + * TransactionEvent + * + * Generated from 'TransactionEvent' regular structure + */ +public data class TransactionEvent( + public val hash: HashOf, + public val blockHeight: NonZeroOfu64? = null, + public val status: TransactionStatus, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionEvent = try { + TransactionEvent( + HashOf.read(reader) as HashOf, + reader.readNullable(NonZeroOfu64) as NonZeroOfu64?, + TransactionStatus.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransactionEvent): Unit = try { + HashOf.write(writer, instance.hash) + writer.writeNullable(NonZeroOfu64, instance.blockHeight) + TransactionStatus.write(writer, instance.status) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEventFilter.kt new file mode 100644 index 000000000..43bb4990f --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionEventFilter.kt @@ -0,0 +1,42 @@ +// +// 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 + +/** + * TransactionEventFilter + * + * Generated from 'TransactionEventFilter' regular structure + */ +public data class TransactionEventFilter( + public val hash: HashOf? = null, + public val blockHeight: NonZeroOfu64? = null, + public val status: TransactionStatus? = null, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionEventFilter = try { + TransactionEventFilter( + reader.readNullable(HashOf) as HashOf?, + reader.readNullable(NonZeroOfu64) as NonZeroOfu64?, + reader.readNullable(TransactionStatus) as TransactionStatus?, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransactionEventFilter): Unit = try { + writer.writeNullable(HashOf, instance.hash) + writer.writeNullable(NonZeroOfu64, instance.blockHeight) + writer.writeNullable(TransactionStatus, instance.status) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionHashPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionHashPredicateBox.kt new file mode 100644 index 000000000..106954288 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionHashPredicateBox.kt @@ -0,0 +1,75 @@ +// +// 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 + +/** + * TransactionHashPredicateBox + * + * Generated from 'TransactionHashPredicateBox' enum + */ +public sealed class TransactionHashPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val hashOf: HashOf, + ) : TransactionHashPredicateBox() { + 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.TransactionHashPredicateBox.Equals = try { + Equals( + HashOf.read(reader) as HashOf, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionHashPredicateBox.Equals, + ): Unit = try { + HashOf.write(writer, instance.hashOf) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionHashPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransactionHashPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameter.kt new file mode 100644 index 000000000..19acc0134 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameter.kt @@ -0,0 +1,109 @@ +// +// 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 + +/** + * TransactionParameter + * + * Generated from 'TransactionParameter' enum + */ +public sealed class TransactionParameter : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'MaxInstructions' variant + */ + public data class MaxInstructions( + public val nonZeroOfu64: NonZeroOfu64, + ) : TransactionParameter() { + 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.TransactionParameter.MaxInstructions = try { + MaxInstructions( + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionParameter.MaxInstructions, + ): Unit = + try { + NonZeroOfu64.write(writer, instance.nonZeroOfu64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'SmartContractSize' variant + */ + public data class SmartContractSize( + public val nonZeroOfu64: NonZeroOfu64, + ) : TransactionParameter() { + 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.TransactionParameter.SmartContractSize = try { + SmartContractSize( + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionParameter.SmartContractSize, + ): Unit = + try { + NonZeroOfu64.write(writer, instance.nonZeroOfu64) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionParameter = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> MaxInstructions.read(reader) + 1 -> SmartContractSize.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransactionParameter) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> MaxInstructions.write(writer, instance as MaxInstructions) + 1 -> SmartContractSize.write(writer, instance as SmartContractSize) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameters.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameters.kt new file mode 100644 index 000000000..08b4b85b0 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionParameters.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 + +/** + * TransactionParameters + * + * Generated from 'TransactionParameters' regular structure + */ +public data class TransactionParameters( + public val maxInstructions: NonZeroOfu64, + public val smartContractSize: NonZeroOfu64, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionParameters = try { + TransactionParameters( + NonZeroOfu64.read(reader), + NonZeroOfu64.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransactionParameters): Unit = try { + NonZeroOfu64.write(writer, instance.maxInstructions) + NonZeroOfu64.write(writer, instance.smartContractSize) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionPayload.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionPayload.kt index a8017c735..5ec04fa3a 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionPayload.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionPayload.kt @@ -7,11 +7,9 @@ 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.comparator import jp.co.soramitsu.iroha2.wrapException import java.math.BigInteger import kotlin.Unit -import kotlin.collections.Map /** * TransactionPayload @@ -19,40 +17,37 @@ import kotlin.collections.Map * Generated from 'TransactionPayload' regular structure */ public data class TransactionPayload( - public val creationTimeMs: BigInteger, + public val chain: ChainId, public val authority: AccountId, + public val creationTimeMs: BigInteger, public val instructions: Executable, public val timeToLiveMs: NonZeroOfu64? = null, public val nonce: NonZeroOfu32? = null, - public val metadata: Map, + public val metadata: Metadata, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TransactionPayload = try { TransactionPayload( - reader.readUint64(), + ChainId.read(reader), AccountId.read(reader), + reader.readUint64(), Executable.read(reader), reader.readNullable(NonZeroOfu64) as NonZeroOfu64?, reader.readNullable(NonZeroOfu32) as NonZeroOfu32?, - reader.readMap(reader.readCompactInt(), { Name.read(reader) }, { Value.read(reader) }), + Metadata.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } override fun write(writer: ScaleCodecWriter, instance: TransactionPayload): Unit = try { - writer.writeUint64(instance.creationTimeMs) + ChainId.write(writer, instance.chain) AccountId.write(writer, instance.authority) + writer.writeUint64(instance.creationTimeMs) Executable.write(writer, instance.instructions) writer.writeNullable(NonZeroOfu64, instance.timeToLiveMs) writer.writeNullable(NonZeroOfu32, instance.nonce) - writer.writeCompact(instance.metadata.size) - instance.metadata.toSortedMap( - Name.comparator(), - ).forEach { (key, value) -> - Name.write(writer, key) - Value.write(writer, value) - } + Metadata.write(writer, instance.metadata) } 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 d993ec685..4e9d70bf6 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,14 +16,14 @@ 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 val transaction: CommittedTransaction, ) { 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, + CommittedTransaction.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -31,7 +31,7 @@ public data class TransactionQueryOutput( override fun write(writer: ScaleCodecWriter, instance: TransactionQueryOutput): Unit = try { HashOf.write(writer, instance.blockHash) - TransactionValue.write(writer, instance.transaction) + CommittedTransaction.write(writer, instance.transaction) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutputPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutputPredicateBox.kt new file mode 100644 index 000000000..759a9f58c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionQueryOutputPredicateBox.kt @@ -0,0 +1,109 @@ +// +// 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 + +/** + * TransactionQueryOutputPredicateBox + * + * Generated from 'TransactionQueryOutputPredicateBox' enum + */ +public sealed class TransactionQueryOutputPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Transaction' variant + */ + public data class Transaction( + public val committedTransactionPredicateBox: CommittedTransactionPredicateBox, + ) : TransactionQueryOutputPredicateBox() { + 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.TransactionQueryOutputPredicateBox.Transaction = try { + Transaction( + CommittedTransactionPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionQueryOutputPredicateBox.Transaction, + ): Unit = try { + CommittedTransactionPredicateBox.write(writer, instance.committedTransactionPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'BlockHash' variant + */ + public data class BlockHash( + public val blockHashPredicateBox: BlockHashPredicateBox, + ) : TransactionQueryOutputPredicateBox() { + 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.TransactionQueryOutputPredicateBox.BlockHash = try { + BlockHash( + BlockHashPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionQueryOutputPredicateBox.BlockHash, + ): Unit = try { + BlockHashPredicateBox.write(writer, instance.blockHashPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionQueryOutputPredicateBox = when ( + val + discriminant = reader.readUByte() + ) { + 0 -> Transaction.read(reader) + 1 -> BlockHash.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransactionQueryOutputPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Transaction.write(writer, instance as Transaction) + 1 -> BlockHash.write(writer, instance as BlockHash) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} 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 1b0d8b50d..3d0165528 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 @@ -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.Unit @@ -25,14 +23,6 @@ public sealed class TransactionRejectionReason : ModelEnum { */ public abstract fun discriminant(): Int - override fun equals(other: Any?): Boolean = when (this) { - is Expired -> Expired.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is Expired -> Expired.hashCode() - else -> super.hashCode() } - /** * 'AccountDoesNotExist' variant */ @@ -195,43 +185,6 @@ public sealed class TransactionRejectionReason : ModelEnum { } } - /** - * 'Expired' variant - */ - public class Expired : 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.Expired = try { - Expired() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.Expired, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TransactionRejectionReason.Expired, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TransactionRejectionReason.Expired".hashCode() - } - } - public companion object : ScaleReader, ScaleWriter { @@ -244,7 +197,6 @@ public sealed class TransactionRejectionReason : ModelEnum { 2 -> Validation.read(reader) 3 -> InstructionExecution.read(reader) 4 -> WasmExecution.read(reader) - 5 -> Expired.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: TransactionRejectionReason) { @@ -255,7 +207,6 @@ 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 -> 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/TransactionLimits.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionSignature.kt similarity index 52% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionLimits.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionSignature.kt index f2e3c618d..3b0641777 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionLimits.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionSignature.kt @@ -8,31 +8,27 @@ 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 java.math.BigInteger import kotlin.Unit /** - * TransactionLimits + * TransactionSignature * - * Generated from 'TransactionLimits' regular structure + * Generated from 'TransactionSignature' regular structure */ -public data class TransactionLimits( - public val maxInstructionNumber: BigInteger, - public val maxWasmSizeBytes: BigInteger, +public data class TransactionSignature( + public val signatureOfOfTransactionPayload: SignatureOf, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TransactionLimits = try { - TransactionLimits( - reader.readUint64(), - reader.readUint64(), + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionSignature = try { + TransactionSignature( + SignatureOf.read(reader) as SignatureOf, ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: TransactionLimits): Unit = try { - writer.writeUint64(instance.maxInstructionNumber) - writer.writeUint64(instance.maxWasmSizeBytes) + override fun write(writer: ScaleCodecWriter, instance: TransactionSignature): Unit = try { + SignatureOf.write(writer, instance.signatureOfOfTransactionPayload) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionStatus.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionStatus.kt new file mode 100644 index 000000000..edbf679b6 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransactionStatus.kt @@ -0,0 +1,195 @@ +// +// 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.Boolean +import kotlin.Int +import kotlin.Unit + +/** + * TransactionStatus + * + * Generated from 'TransactionStatus' enum + */ +public sealed class TransactionStatus : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + override fun equals(other: Any?): Boolean = when (this) { + is Queued -> Queued.equals(this, other) + is Expired -> Expired.equals(this, other) + is Approved -> Approved.equals(this, other) + else -> super.equals(other) } + + override fun hashCode(): Int = when (this) { + is Queued -> Queued.hashCode() + is Expired -> Expired.hashCode() + is Approved -> Approved.hashCode() + else -> super.hashCode() } + + /** + * 'Queued' variant + */ + public class Queued : TransactionStatus() { + 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.TransactionStatus.Queued = try { + Queued() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionStatus.Queued, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: jp.co.soramitsu.iroha2.generated.TransactionStatus.Queued, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".TransactionStatus.Queued".hashCode() + } + } + + /** + * 'Expired' variant + */ + public class Expired : TransactionStatus() { + 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.TransactionStatus.Expired = try { + Expired() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionStatus.Expired, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: jp.co.soramitsu.iroha2.generated.TransactionStatus.Expired, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".TransactionStatus.Expired".hashCode() + } + } + + /** + * 'Approved' variant + */ + public class Approved : TransactionStatus() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TransactionStatus.Approved = try { + Approved() + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionStatus.Approved, + ): Unit = try { + } catch (ex: Exception) { + throw wrapException(ex) + } + + public fun equals(o1: jp.co.soramitsu.iroha2.generated.TransactionStatus.Approved, o2: Any?): Boolean = when (o2) { + null -> false + else -> o2::class == o1::class + } + + override fun hashCode(): Int = ".TransactionStatus.Approved".hashCode() + } + } + + /** + * 'Rejected' variant + */ + public data class Rejected( + public val transactionRejectionReason: TransactionRejectionReason, + ) : TransactionStatus() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TransactionStatus.Rejected = try { + Rejected( + TransactionRejectionReason.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransactionStatus.Rejected, + ): Unit = try { + TransactionRejectionReason.write(writer, instance.transactionRejectionReason) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransactionStatus = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Queued.read(reader) + 1 -> Expired.read(reader) + 2 -> Approved.read(reader) + 3 -> Rejected.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransactionStatus) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Queued.write(writer, instance as Queued) + 1 -> Expired.write(writer, instance as Expired) + 2 -> Approved.write(writer, instance as Approved) + 3 -> Rejected.write(writer, instance as Rejected) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} 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/TransferBox.kt new file mode 100644 index 000000000..c5ffdca08 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferBox.kt @@ -0,0 +1,148 @@ +// +// 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 + +/** + * TransferBox + * + * Generated from 'TransferBox' enum + */ +public sealed class TransferBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Domain' variant + */ + public data class Domain( + public val transferOfAccountAndDomainIdAndAccount: TransferOfAccountAndDomainIdAndAccount, + ) : TransferBox() { + 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.TransferBox.Domain = try { + Domain( + TransferOfAccountAndDomainIdAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransferBox.Domain, + ): Unit = try { + TransferOfAccountAndDomainIdAndAccount.write( + writer, + instance.transferOfAccountAndDomainIdAndAccount, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val transferOfAccountAndAssetDefinitionIdAndAccount: + TransferOfAccountAndAssetDefinitionIdAndAccount, + ) : TransferBox() { + 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.TransferBox.AssetDefinition = try { + AssetDefinition( + TransferOfAccountAndAssetDefinitionIdAndAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransferBox.AssetDefinition, + ): Unit = try { + TransferOfAccountAndAssetDefinitionIdAndAccount.write( + writer, + instance.transferOfAccountAndAssetDefinitionIdAndAccount, + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val assetTransferBox: AssetTransferBox, + ) : TransferBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TransferBox.Asset = try { + Asset( + AssetTransferBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TransferBox.Asset, + ): Unit = try { + AssetTransferBox.write(writer, instance.assetTransferBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Domain.read(reader) + 1 -> AssetDefinition.read(reader) + 2 -> Asset.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TransferBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Domain.write(writer, instance as Domain) + 1 -> AssetDefinition.write(writer, instance as AssetDefinition) + 2 -> Asset.write(writer, instance as Asset) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.kt deleted file mode 100644 index 405492889..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferExpr.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 - -/** - * TransferExpr - * - * Generated from 'TransferExpr' regular structure - */ -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): TransferExpr = try { - TransferExpr( - 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: TransferExpr): Unit = try { - EvaluatesTo.write(writer, instance.sourceId) - EvaluatesTo.write(writer, instance.`object`) - EvaluatesTo.write(writer, instance.destinationId) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndAssetDefinitionIdAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndAssetDefinitionIdAndAccount.kt new file mode 100644 index 000000000..cc718549b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndAssetDefinitionIdAndAccount.kt @@ -0,0 +1,48 @@ +// +// 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 + +/** + * TransferOfAccountAndAssetDefinitionIdAndAccount + * + * Generated from 'TransferOfAccountAndAssetDefinitionIdAndAccount' regular structure + */ +public data class TransferOfAccountAndAssetDefinitionIdAndAccount( + public val source: AccountId, + public val `object`: AssetDefinitionId, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferOfAccountAndAssetDefinitionIdAndAccount = + try { + TransferOfAccountAndAssetDefinitionIdAndAccount( + AccountId.read(reader), + AssetDefinitionId.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: TransferOfAccountAndAssetDefinitionIdAndAccount, + ): Unit = try { + AccountId.write(writer, instance.source) + AssetDefinitionId.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndDomainIdAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndDomainIdAndAccount.kt new file mode 100644 index 000000000..6161fa14c --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAccountAndDomainIdAndAccount.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * TransferOfAccountAndDomainIdAndAccount + * + * Generated from 'TransferOfAccountAndDomainIdAndAccount' regular structure + */ +public data class TransferOfAccountAndDomainIdAndAccount( + public val source: AccountId, + public val `object`: DomainId, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferOfAccountAndDomainIdAndAccount = try { + TransferOfAccountAndDomainIdAndAccount( + AccountId.read(reader), + DomainId.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransferOfAccountAndDomainIdAndAccount): Unit = try { + AccountId.write(writer, instance.source) + DomainId.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndMetadataAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndMetadataAndAccount.kt new file mode 100644 index 000000000..da8e344a0 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndMetadataAndAccount.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * TransferOfAssetAndMetadataAndAccount + * + * Generated from 'TransferOfAssetAndMetadataAndAccount' regular structure + */ +public data class TransferOfAssetAndMetadataAndAccount( + public val source: AssetId, + public val `object`: Metadata, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferOfAssetAndMetadataAndAccount = try { + TransferOfAssetAndMetadataAndAccount( + AssetId.read(reader), + Metadata.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransferOfAssetAndMetadataAndAccount): Unit = try { + AssetId.write(writer, instance.source) + Metadata.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndNumericAndAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndNumericAndAccount.kt new file mode 100644 index 000000000..2612f94f4 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TransferOfAssetAndNumericAndAccount.kt @@ -0,0 +1,44 @@ +// +// 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 + +/** + * TransferOfAssetAndNumericAndAccount + * + * Generated from 'TransferOfAssetAndNumericAndAccount' regular structure + */ +public data class TransferOfAssetAndNumericAndAccount( + public val source: AssetId, + public val `object`: Numeric, + public val destination: AccountId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): TransferOfAssetAndNumericAndAccount = try { + TransferOfAssetAndNumericAndAccount( + AssetId.read(reader), + Numeric.read(reader), + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: TransferOfAssetAndNumericAndAccount): Unit = try { + AssetId.write(writer, instance.source) + Numeric.write(writer, instance.`object`) + AccountId.write(writer, instance.destination) + } 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/Trigger.kt similarity index 53% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBox.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Trigger.kt index f5d23a373..309e54abf 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerOfTriggeringFilterBox.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Trigger.kt @@ -11,29 +11,27 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * TriggerOfTriggeringFilterBox + * Trigger * - * Generated from 'TriggerOfTriggeringFilterBox' regular structure + * Generated from 'Trigger' regular structure */ -public data class TriggerOfTriggeringFilterBox( +public data class Trigger( public val id: TriggerId, - public val action: ActionOfTriggeringFilterBox, + public val action: Action, ) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerOfTriggeringFilterBox = try { - TriggerOfTriggeringFilterBox( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Trigger = try { + Trigger( TriggerId.read(reader), - ActionOfTriggeringFilterBox.read(reader), + Action.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: TriggerOfTriggeringFilterBox): Unit = try { + override fun write(writer: ScaleCodecWriter, instance: Trigger): Unit = try { TriggerId.write(writer, instance.id) - ActionOfTriggeringFilterBox.write(writer, instance.action) + Action.write(writer, instance.action) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerEventFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerEventFilter.kt index 2d95e7415..239257a3e 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerEventFilter.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerEventFilter.kt @@ -3,293 +3,38 @@ // 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.Boolean -import kotlin.Int +import kotlin.Long import kotlin.Unit /** * TriggerEventFilter * - * Generated from 'TriggerEventFilter' enum + * Generated from 'TriggerEventFilter' regular structure */ -public sealed class TriggerEventFilter : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - override fun equals(other: Any?): Boolean = when (this) { - is ByCreated -> ByCreated.equals(this, other) - is ByDeleted -> ByDeleted.equals(this, other) - is ByExtended -> ByExtended.equals(this, other) - is ByShortened -> ByShortened.equals(this, other) - is ByMetadataInserted -> ByMetadataInserted.equals(this, other) - is ByMetadataRemoved -> ByMetadataRemoved.equals(this, other) - else -> super.equals(other) } - - override fun hashCode(): Int = when (this) { - is ByCreated -> ByCreated.hashCode() - is ByDeleted -> ByDeleted.hashCode() - is ByExtended -> ByExtended.hashCode() - is ByShortened -> ByShortened.hashCode() - is ByMetadataInserted -> ByMetadataInserted.hashCode() - is ByMetadataRemoved -> ByMetadataRemoved.hashCode() - else -> super.hashCode() } - - /** - * 'ByCreated' variant - */ - public class ByCreated : TriggerEventFilter() { - 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.TriggerEventFilter.ByCreated = try { - ByCreated() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByCreated, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByCreated, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByCreated".hashCode() - } - } - - /** - * 'ByDeleted' variant - */ - public class ByDeleted : TriggerEventFilter() { - 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.TriggerEventFilter.ByDeleted = try { - ByDeleted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByDeleted, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByDeleted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByDeleted".hashCode() - } - } - - /** - * 'ByExtended' variant - */ - public class ByExtended : TriggerEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByExtended = try { - ByExtended() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByExtended, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByExtended, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByExtended".hashCode() - } - } - - /** - * 'ByShortened' variant - */ - public class ByShortened : TriggerEventFilter() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByShortened = try { - ByShortened() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByShortened, - ): Unit = try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByShortened, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByShortened".hashCode() - } - } - - /** - * 'ByMetadataInserted' variant - */ - public class ByMetadataInserted : TriggerEventFilter() { - 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.TriggerEventFilter.ByMetadataInserted = try { - ByMetadataInserted() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByMetadataInserted, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByMetadataInserted, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByMetadataInserted".hashCode() - } - } - - /** - * 'ByMetadataRemoved' variant - */ - public class ByMetadataRemoved : TriggerEventFilter() { - 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.TriggerEventFilter.ByMetadataRemoved = try { - ByMetadataRemoved() - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByMetadataRemoved, - ): Unit = - try { - } catch (ex: Exception) { - throw wrapException(ex) - } - - public fun equals( - o1: jp.co.soramitsu.iroha2.generated.TriggerEventFilter.ByMetadataRemoved, - o2: Any?, - ): Boolean = when (o2) { - null -> false - else -> o2::class == o1::class - } - - override fun hashCode(): Int = ".TriggerEventFilter.ByMetadataRemoved".hashCode() - } - } - +public data class TriggerEventFilter( + public val idMatcher: TriggerId? = null, + public val eventSet: Long, +) { public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerEventFilter = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> ByCreated.read(reader) - 1 -> ByDeleted.read(reader) - 2 -> ByExtended.read(reader) - 3 -> ByShortened.read(reader) - 4 -> ByMetadataInserted.read(reader) - 5 -> ByMetadataRemoved.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun read(reader: ScaleCodecReader): TriggerEventFilter = try { + TriggerEventFilter( + reader.readNullable(TriggerId) as TriggerId?, + reader.readUint32(), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } - override fun write(writer: ScaleCodecWriter, instance: TriggerEventFilter) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> ByCreated.write(writer, instance as ByCreated) - 1 -> ByDeleted.write(writer, instance as ByDeleted) - 2 -> ByExtended.write(writer, instance as ByExtended) - 3 -> ByShortened.write(writer, instance as ByShortened) - 4 -> ByMetadataInserted.write(writer, instance as ByMetadataInserted) - 5 -> ByMetadataRemoved.write(writer, instance as ByMetadataRemoved) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + override fun write(writer: ScaleCodecWriter, instance: TriggerEventFilter): Unit = try { + writer.writeNullable(TriggerId, instance.idMatcher) + writer.writeUint32(instance.eventSet) + } catch (ex: Exception) { + throw wrapException(ex) } } } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerFilter.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerFilter.kt deleted file mode 100644 index e8edb1f9b..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerFilter.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 - -/** - * TriggerFilter - * - * Generated from 'TriggerFilter' regular structure - */ -public data class TriggerFilter( - public val originFilter: FilterOptOfOriginFilterOfTriggerEvent, - public val eventFilter: FilterOptOfTriggerEventFilter, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggerFilter = try { - TriggerFilter( - FilterOptOfOriginFilterOfTriggerEvent.read(reader), - FilterOptOfTriggerEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: TriggerFilter): Unit = try { - FilterOptOfOriginFilterOfTriggerEvent.write(writer, instance.originFilter) - FilterOptOfTriggerEventFilter.write(writer, instance.eventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} 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 44d1ddb4f..f023fd8f9 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,13 +16,11 @@ import kotlin.Unit * Generated from 'TriggerId' regular structure */ public data class TriggerId( - public val domainId: DomainId? = null, public val name: Name, ) { public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): TriggerId = try { TriggerId( - reader.readNullable(DomainId) as DomainId?, Name.read(reader), ) } catch (ex: Exception) { @@ -30,7 +28,6 @@ public data class TriggerId( } override fun write(writer: ScaleCodecWriter, instance: TriggerId): Unit = try { - 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/TriggerIdPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerIdPredicateBox.kt new file mode 100644 index 000000000..103be10a3 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerIdPredicateBox.kt @@ -0,0 +1,107 @@ +// +// 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 + +/** + * TriggerIdPredicateBox + * + * Generated from 'TriggerIdPredicateBox' enum + */ +public sealed class TriggerIdPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Equals' variant + */ + public data class Equals( + public val triggerId: TriggerId, + ) : TriggerIdPredicateBox() { + 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.TriggerIdPredicateBox.Equals = try { + Equals( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TriggerIdPredicateBox.Equals, + ): Unit = try { + TriggerId.write(writer, instance.triggerId) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Name' variant + */ + public data class Name( + public val stringPredicateBox: StringPredicateBox, + ) : TriggerIdPredicateBox() { + 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.TriggerIdPredicateBox.Name = try { + Name( + StringPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TriggerIdPredicateBox.Name, + ): Unit = try { + StringPredicateBox.write(writer, instance.stringPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TriggerIdPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Equals.read(reader) + 1 -> Name.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TriggerIdPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Equals.write(writer, instance as Equals) + 1 -> Name.write(writer, instance as Name) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerNumberOfExecutionsChanged.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerNumberOfExecutionsChanged.kt index ee9cc0ad3..f63765280 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerNumberOfExecutionsChanged.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerNumberOfExecutionsChanged.kt @@ -17,7 +17,7 @@ import kotlin.Unit * Generated from 'TriggerNumberOfExecutionsChanged' regular structure */ public data class TriggerNumberOfExecutionsChanged( - public val triggerId: TriggerId, + public val trigger: TriggerId, public val `by`: Long, ) { public companion object : @@ -34,7 +34,7 @@ public data class TriggerNumberOfExecutionsChanged( override fun write(writer: ScaleCodecWriter, instance: TriggerNumberOfExecutionsChanged): Unit = try { - TriggerId.write(writer, instance.triggerId) + TriggerId.write(writer, instance.trigger) writer.writeUint32(instance.`by`) } catch (ex: Exception) { throw wrapException(ex) diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerPredicateBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerPredicateBox.kt new file mode 100644 index 000000000..018dfee8b --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggerPredicateBox.kt @@ -0,0 +1,73 @@ +// +// 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 + +/** + * TriggerPredicateBox + * + * Generated from 'TriggerPredicateBox' enum + */ +public sealed class TriggerPredicateBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Id' variant + */ + public data class Id( + public val triggerIdPredicateBox: TriggerIdPredicateBox, + ) : TriggerPredicateBox() { + 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.TriggerPredicateBox.Id = try { + Id( + TriggerIdPredicateBox.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.TriggerPredicateBox.Id, + ): Unit = try { + TriggerIdPredicateBox.write(writer, instance.triggerIdPredicateBox) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): TriggerPredicateBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Id.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: TriggerPredicateBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Id.write(writer, instance as Id) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggeringFilterBox.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggeringFilterBox.kt deleted file mode 100644 index 717ee20f5..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TriggeringFilterBox.kt +++ /dev/null @@ -1,175 +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 - -/** - * TriggeringFilterBox - * - * Generated from 'TriggeringFilterBox' enum - */ -public sealed class TriggeringFilterBox : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'Pipeline' variant - */ - public data class Pipeline( - public val pipelineEventFilter: PipelineEventFilter, - ) : TriggeringFilterBox() { - 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.TriggeringFilterBox.Pipeline = try { - Pipeline( - PipelineEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.Pipeline, - ): Unit = try { - PipelineEventFilter.write(writer, instance.pipelineEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Data' variant - */ - public data class Data( - public val filterOptOfDataEntityFilter: FilterOptOfDataEntityFilter, - ) : TriggeringFilterBox() { - 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.TriggeringFilterBox.Data = try { - Data( - FilterOptOfDataEntityFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.Data, - ): Unit = try { - FilterOptOfDataEntityFilter.write(writer, instance.filterOptOfDataEntityFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Time' variant - */ - public data class Time( - public val timeEventFilter: TimeEventFilter, - ) : TriggeringFilterBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.Time = try { - Time( - TimeEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.Time, - ): Unit = try { - TimeEventFilter.write(writer, instance.timeEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'ExecuteTrigger' variant - */ - public data class ExecuteTrigger( - public val executeTriggerEventFilter: ExecuteTriggerEventFilter, - ) : TriggeringFilterBox() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.ExecuteTrigger = try { - ExecuteTrigger( - ExecuteTriggerEventFilter.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TriggeringFilterBox.ExecuteTrigger, - ): Unit = try { - ExecuteTriggerEventFilter.write(writer, instance.executeTriggerEventFilter) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): TriggeringFilterBox = when ( - val discriminant = - reader.readUByte() - ) { - 0 -> Pipeline.read(reader) - 1 -> Data.read(reader) - 2 -> Time.read(reader) - 3 -> ExecuteTrigger.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: TriggeringFilterBox) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Pipeline.write(writer, instance as Pipeline) - 1 -> Data.write(writer, instance as Data) - 2 -> Time.write(writer, instance as Time) - 3 -> ExecuteTrigger.write(writer, instance as ExecuteTrigger) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - } - } -} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TypeError.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TypeError.kt index 582f60218..ff5c5b8b2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TypeError.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/TypeError.kt @@ -24,21 +24,21 @@ public sealed class TypeError : ModelEnum { public abstract fun discriminant(): Int /** - * 'AssetValueType' variant + * 'AssetType' variant */ - public data class AssetValueType( - public val mismatchOfAssetValueType: MismatchOfAssetValueType, + public data class AssetType( + public val mismatch: Mismatch, ) : TypeError() { 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.TypeError.AssetValueType = try { - AssetValueType( - MismatchOfAssetValueType.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TypeError.AssetType = try { + AssetType( + Mismatch.read(reader) as Mismatch, ) } catch (ex: Exception) { throw wrapException(ex) @@ -46,9 +46,9 @@ public sealed class TypeError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TypeError.AssetValueType, + instance: jp.co.soramitsu.iroha2.generated.TypeError.AssetType, ): Unit = try { - MismatchOfAssetValueType.write(writer, instance.mismatchOfAssetValueType) + Mismatch.write(writer, instance.mismatch) } catch (ex: Exception) { throw wrapException(ex) } @@ -56,21 +56,21 @@ public sealed class TypeError : ModelEnum { } /** - * 'ParameterValueType' variant + * 'NumericAssetTypeExpected' variant */ - public data class ParameterValueType( - public val mismatchOfValue: MismatchOfValue, + public data class NumericAssetTypeExpected( + public val assetType: jp.co.soramitsu.iroha2.generated.AssetType, ) : TypeError() { 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.TypeError.ParameterValueType = try { - ParameterValueType( - MismatchOfValue.read(reader), + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TypeError.NumericAssetTypeExpected = try { + NumericAssetTypeExpected( + jp.co.soramitsu.iroha2.generated.AssetType.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) @@ -78,41 +78,9 @@ public sealed class TypeError : ModelEnum { override fun write( writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TypeError.ParameterValueType, + instance: jp.co.soramitsu.iroha2.generated.TypeError.NumericAssetTypeExpected, ): Unit = try { - MismatchOfValue.write(writer, instance.mismatchOfValue) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'AssetDefinitionId' variant - */ - public data class AssetDefinitionId( - public val mismatchOfAssetDefinitionId: MismatchOfAssetDefinitionId, - ) : TypeError() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.TypeError.AssetDefinitionId = try { - AssetDefinitionId( - MismatchOfAssetDefinitionId.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.TypeError.AssetDefinitionId, - ): Unit = try { - MismatchOfAssetDefinitionId.write(writer, instance.mismatchOfAssetDefinitionId) + jp.co.soramitsu.iroha2.generated.AssetType.write(writer, instance.assetType) } catch (ex: Exception) { throw wrapException(ex) } @@ -124,17 +92,15 @@ public sealed class TypeError : ModelEnum { val discriminant = reader.readUByte() ) { - 0 -> AssetValueType.read(reader) - 1 -> ParameterValueType.read(reader) - 2 -> AssetDefinitionId.read(reader) + 0 -> AssetType.read(reader) + 1 -> NumericAssetTypeExpected.read(reader) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } override fun write(writer: ScaleCodecWriter, instance: TypeError) { writer.directWrite(instance.discriminant()) when (val discriminant = instance.discriminant()) { - 0 -> AssetValueType.write(writer, instance as AssetValueType) - 1 -> ParameterValueType.write(writer, instance as ParameterValueType) - 2 -> AssetDefinitionId.write(writer, instance as AssetDefinitionId) + 0 -> AssetType.write(writer, instance as AssetType) + 1 -> NumericAssetTypeExpected.write(writer, instance as NumericAssetTypeExpected) else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } } } 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 deleted file mode 100644 index c8cc42729..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UniqueVec.kt +++ /dev/null @@ -1,41 +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.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/UnregisterBox.kt new file mode 100644 index 000000000..f173e1122 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterBox.kt @@ -0,0 +1,277 @@ +// +// 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 + +/** + * UnregisterBox + * + * Generated from 'UnregisterBox' enum + */ +public sealed class UnregisterBox : ModelEnum { + /** + * @return Discriminator of variant in enum + */ + public abstract fun discriminant(): Int + + /** + * 'Peer' variant + */ + public data class Peer( + public val unregisterOfPeer: UnregisterOfPeer, + ) : UnregisterBox() { + 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.UnregisterBox.Peer = try { + Peer( + UnregisterOfPeer.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Peer, + ): Unit = try { + UnregisterOfPeer.write(writer, instance.unregisterOfPeer) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Domain' variant + */ + public data class Domain( + public val unregisterOfDomain: UnregisterOfDomain, + ) : UnregisterBox() { + 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.UnregisterBox.Domain = try { + Domain( + UnregisterOfDomain.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Domain, + ): Unit = try { + UnregisterOfDomain.write(writer, instance.unregisterOfDomain) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Account' variant + */ + public data class Account( + public val unregisterOfAccount: UnregisterOfAccount, + ) : UnregisterBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 2 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.UnregisterBox.Account = try { + Account( + UnregisterOfAccount.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Account, + ): Unit = try { + UnregisterOfAccount.write(writer, instance.unregisterOfAccount) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'AssetDefinition' variant + */ + public data class AssetDefinition( + public val unregisterOfAssetDefinition: UnregisterOfAssetDefinition, + ) : UnregisterBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 3 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.UnregisterBox.AssetDefinition = try { + AssetDefinition( + UnregisterOfAssetDefinition.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.AssetDefinition, + ): Unit = try { + UnregisterOfAssetDefinition.write(writer, instance.unregisterOfAssetDefinition) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Asset' variant + */ + public data class Asset( + public val unregisterOfAsset: UnregisterOfAsset, + ) : UnregisterBox() { + 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.UnregisterBox.Asset = try { + Asset( + UnregisterOfAsset.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Asset, + ): Unit = try { + UnregisterOfAsset.write(writer, instance.unregisterOfAsset) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Role' variant + */ + public data class Role( + public val unregisterOfRole: UnregisterOfRole, + ) : UnregisterBox() { + 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.UnregisterBox.Role = try { + Role( + UnregisterOfRole.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Role, + ): Unit = try { + UnregisterOfRole.write(writer, instance.unregisterOfRole) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + /** + * 'Trigger' variant + */ + public data class Trigger( + public val unregisterOfTrigger: UnregisterOfTrigger, + ) : UnregisterBox() { + override fun discriminant(): Int = DISCRIMINANT + + public companion object : + ScaleReader, + ScaleWriter { + public const val DISCRIMINANT: Int = 6 + + override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.UnregisterBox.Trigger = try { + Trigger( + UnregisterOfTrigger.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write( + writer: ScaleCodecWriter, + instance: jp.co.soramitsu.iroha2.generated.UnregisterBox.Trigger, + ): Unit = try { + UnregisterOfTrigger.write(writer, instance.unregisterOfTrigger) + } catch (ex: Exception) { + throw wrapException(ex) + } + } + } + + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterBox = when ( + val discriminant = + reader.readUByte() + ) { + 0 -> Peer.read(reader) + 1 -> Domain.read(reader) + 2 -> Account.read(reader) + 3 -> AssetDefinition.read(reader) + 4 -> Asset.read(reader) + 5 -> Role.read(reader) + 6 -> Trigger.read(reader) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + + override fun write(writer: ScaleCodecWriter, instance: UnregisterBox) { + writer.directWrite(instance.discriminant()) + when (val discriminant = instance.discriminant()) { + 0 -> Peer.write(writer, instance as Peer) + 1 -> Domain.write(writer, instance as Domain) + 2 -> Account.write(writer, instance as Account) + 3 -> AssetDefinition.write(writer, instance as AssetDefinition) + 4 -> Asset.write(writer, instance as Asset) + 5 -> Role.write(writer, instance as Role) + 6 -> Trigger.write(writer, instance as Trigger) + else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAccount.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAccount.kt new file mode 100644 index 000000000..689a7d1fb --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAccount.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * UnregisterOfAccount + * + * Generated from 'UnregisterOfAccount' regular structure + */ +public data class UnregisterOfAccount( + public val `object`: AccountId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfAccount = try { + UnregisterOfAccount( + AccountId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfAccount): Unit = try { + AccountId.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAsset.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAsset.kt index 0847a02ad..3a96a92c2 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UpgradeExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAsset.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * UpgradeExpr + * UnregisterOfAsset * - * Generated from 'UpgradeExpr' regular structure + * Generated from 'UnregisterOfAsset' regular structure */ -public data class UpgradeExpr( - public val `object`: EvaluatesTo, +public data class UnregisterOfAsset( + public val `object`: AssetId, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): UpgradeExpr = try { - UpgradeExpr( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfAsset = try { + UnregisterOfAsset( + AssetId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: UpgradeExpr): Unit = try { - EvaluatesTo.write(writer, instance.`object`) + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfAsset): Unit = try { + AssetId.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAssetDefinition.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAssetDefinition.kt new file mode 100644 index 000000000..1dec40c59 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfAssetDefinition.kt @@ -0,0 +1,38 @@ +// +// 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 + +/** + * UnregisterOfAssetDefinition + * + * Generated from 'UnregisterOfAssetDefinition' regular structure + */ +public data class UnregisterOfAssetDefinition( + public val `object`: AssetDefinitionId, +) { + public companion object : + ScaleReader, + ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfAssetDefinition = try { + UnregisterOfAssetDefinition( + AssetDefinitionId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfAssetDefinition): Unit = try { + AssetDefinitionId.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfDomain.kt similarity index 55% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfDomain.kt index a89bc5ac7..a4f9ecb75 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterExpr.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfDomain.kt @@ -11,24 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * UnregisterExpr + * UnregisterOfDomain * - * Generated from 'UnregisterExpr' regular structure + * Generated from 'UnregisterOfDomain' regular structure */ -public data class UnregisterExpr( - public val objectId: EvaluatesTo, +public data class UnregisterOfDomain( + public val `object`: DomainId, ) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): UnregisterExpr = try { - UnregisterExpr( - EvaluatesTo.read(reader) as EvaluatesTo, + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfDomain = try { + UnregisterOfDomain( + DomainId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: UnregisterExpr): Unit = try { - EvaluatesTo.write(writer, instance.objectId) + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfDomain): Unit = try { + DomainId.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfPeerEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfPeer.kt similarity index 51% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfPeerEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfPeer.kt index 38b9c6e4c..712774fe1 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfPeerEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfPeer.kt @@ -11,26 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfPeerEvent + * UnregisterOfPeer * - * Generated from 'OriginFilterOfPeerEvent' regular structure + * Generated from 'UnregisterOfPeer' regular structure */ -public data class OriginFilterOfPeerEvent( - public val peerId: PeerId, +public data class UnregisterOfPeer( + public val `object`: PeerId, ) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfPeerEvent = try { - OriginFilterOfPeerEvent( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfPeer = try { + UnregisterOfPeer( PeerId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfPeerEvent): Unit = try { - PeerId.write(writer, instance.peerId) + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfPeer): Unit = try { + PeerId.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfRoleEvent.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfRole.kt similarity index 51% rename from modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfRoleEvent.kt rename to modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfRole.kt index 576184b9b..72c9846b7 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/OriginFilterOfRoleEvent.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfRole.kt @@ -11,26 +11,24 @@ import jp.co.soramitsu.iroha2.wrapException import kotlin.Unit /** - * OriginFilterOfRoleEvent + * UnregisterOfRole * - * Generated from 'OriginFilterOfRoleEvent' regular structure + * Generated from 'UnregisterOfRole' regular structure */ -public data class OriginFilterOfRoleEvent( - public val roleId: RoleId, +public data class UnregisterOfRole( + public val `object`: RoleId, ) { - public companion object : - ScaleReader, - ScaleWriter { - override fun read(reader: ScaleCodecReader): OriginFilterOfRoleEvent = try { - OriginFilterOfRoleEvent( + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfRole = try { + UnregisterOfRole( RoleId.read(reader), ) } catch (ex: Exception) { throw wrapException(ex) } - override fun write(writer: ScaleCodecWriter, instance: OriginFilterOfRoleEvent): Unit = try { - RoleId.write(writer, instance.roleId) + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfRole): Unit = try { + RoleId.write(writer, instance.`object`) } catch (ex: Exception) { throw wrapException(ex) } diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfTrigger.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfTrigger.kt new file mode 100644 index 000000000..690a7fc84 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/UnregisterOfTrigger.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * UnregisterOfTrigger + * + * Generated from 'UnregisterOfTrigger' regular structure + */ +public data class UnregisterOfTrigger( + public val `object`: TriggerId, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): UnregisterOfTrigger = try { + UnregisterOfTrigger( + TriggerId.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: UnregisterOfTrigger): Unit = try { + TriggerId.write(writer, instance.`object`) + } catch (ex: Exception) { + throw wrapException(ex) + } + } +} diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Upgrade.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Upgrade.kt new file mode 100644 index 000000000..ebc064f02 --- /dev/null +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Upgrade.kt @@ -0,0 +1,36 @@ +// +// 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 + +/** + * Upgrade + * + * Generated from 'Upgrade' regular structure + */ +public data class Upgrade( + public val executor: Executor, +) { + public companion object : ScaleReader, ScaleWriter { + override fun read(reader: ScaleCodecReader): Upgrade = try { + Upgrade( + Executor.read(reader), + ) + } catch (ex: Exception) { + throw wrapException(ex) + } + + override fun write(writer: ScaleCodecWriter, instance: Upgrade): Unit = try { + Executor.write(writer, instance.executor) + } 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 deleted file mode 100644 index 5ed881ba1..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Value.kt +++ /dev/null @@ -1,839 +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.Boolean -import kotlin.Int -import kotlin.Unit -import kotlin.collections.List - -/** - * Value - * - * Generated from 'Value' enum - */ -public sealed class Value : ModelEnum { - /** - * @return Discriminator of variant in enum - */ - public abstract fun discriminant(): Int - - /** - * 'Bool' variant - */ - public data class Bool( - public val bool: Boolean, - ) : Value() { - 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.Value.Bool = try { - Bool( - reader.readBoolean(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Bool, - ): Unit = try { - if (instance.bool) { writer.directWrite(1) } else { writer.directWrite(0) } - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'String' variant - */ - public data class String( - public val string: kotlin.String, - ) : Value() { - 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.Value.String = - try { - String( - reader.readString(), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.String, - ): Unit = try { - writer.writeAsList(instance.string.toByteArray(Charsets.UTF_8)) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Name' variant - */ - public data class Name( - public val name: jp.co.soramitsu.iroha2.generated.Name, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 2 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Name = try { - Name( - jp.co.soramitsu.iroha2.generated.Name.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Name, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Name.write(writer, instance.name) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Vec' variant - */ - public data class Vec( - public val vec: List, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 3 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Vec = try { - Vec( - reader.readVec(reader.readCompactInt()) { Value.read(reader) }, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Vec, - ): Unit = try { - writer.writeCompact(instance.vec.size) - instance.vec.forEach { value -> - Value.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'LimitedMetadata' variant - */ - public data class LimitedMetadata( - public val metadata: Metadata, - ) : Value() { - 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.Value.LimitedMetadata = try { - LimitedMetadata( - Metadata.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.LimitedMetadata, - ): Unit = try { - Metadata.write(writer, instance.metadata) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'MetadataLimits' variant - */ - public data class MetadataLimits( - public val limits: Limits, - ) : Value() { - 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.Value.MetadataLimits = try { - MetadataLimits( - Limits.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.MetadataLimits, - ): Unit = try { - Limits.write(writer, instance.limits) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'TransactionLimits' variant - */ - public data class TransactionLimits( - public val transactionLimits: jp.co.soramitsu.iroha2.generated.TransactionLimits, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 6 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.TransactionLimits = try { - TransactionLimits( - jp.co.soramitsu.iroha2.generated.TransactionLimits.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.TransactionLimits, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.TransactionLimits.write(writer, instance.transactionLimits) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'LengthLimits' variant - */ - public data class LengthLimits( - public val lengthLimits: jp.co.soramitsu.iroha2.generated.LengthLimits, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 7 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.LengthLimits = try { - LengthLimits( - jp.co.soramitsu.iroha2.generated.LengthLimits.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.LengthLimits, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.LengthLimits.write(writer, instance.lengthLimits) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Id' variant - */ - public data class Id( - public val idBox: IdBox, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 8 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Id = try { - Id( - IdBox.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Id, - ): Unit = try { - IdBox.write(writer, instance.idBox) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Identifiable' variant - */ - public data class Identifiable( - public val identifiableBox: IdentifiableBox, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 9 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Identifiable = try { - Identifiable( - IdentifiableBox.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Identifiable, - ): Unit = try { - IdentifiableBox.write(writer, instance.identifiableBox) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'PublicKey' variant - */ - public data class PublicKey( - public val publicKey: jp.co.soramitsu.iroha2.generated.PublicKey, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 10 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.PublicKey = try { - PublicKey( - jp.co.soramitsu.iroha2.generated.PublicKey.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.PublicKey, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.PublicKey.write(writer, instance.publicKey) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'SignatureCheckCondition' variant - */ - public data class SignatureCheckCondition( - public val signatureCheckCondition: jp.co.soramitsu.iroha2.generated.SignatureCheckCondition, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 11 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.SignatureCheckCondition = try { - SignatureCheckCondition( - jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.SignatureCheckCondition, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.SignatureCheckCondition.write( - writer, - instance.signatureCheckCondition, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'TransactionQueryOutput' variant - */ - public data class TransactionQueryOutput( - public val transactionQueryOutput: jp.co.soramitsu.iroha2.generated.TransactionQueryOutput, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 12 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.TransactionQueryOutput = try { - TransactionQueryOutput( - jp.co.soramitsu.iroha2.generated.TransactionQueryOutput.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.TransactionQueryOutput, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.TransactionQueryOutput.write( - writer, - instance.transactionQueryOutput, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'PermissionToken' variant - */ - public data class PermissionToken( - public val permissionToken: jp.co.soramitsu.iroha2.generated.PermissionToken, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 13 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.PermissionToken = try { - PermissionToken( - jp.co.soramitsu.iroha2.generated.PermissionToken.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.PermissionToken, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.PermissionToken.write(writer, instance.permissionToken) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'PermissionTokenSchema' variant - */ - public data class PermissionTokenSchema( - public val permissionTokenSchema: jp.co.soramitsu.iroha2.generated.PermissionTokenSchema, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 14 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.PermissionTokenSchema = try { - PermissionTokenSchema( - jp.co.soramitsu.iroha2.generated.PermissionTokenSchema.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.PermissionTokenSchema, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.PermissionTokenSchema.write( - writer, - instance.permissionTokenSchema, - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Hash' variant - */ - public data class Hash( - public val hashValue: HashValue, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 15 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Hash = try { - Hash( - HashValue.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Hash, - ): Unit = try { - HashValue.write(writer, instance.hashValue) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Block' variant - */ - public data class Block( - public val signedBlock: SignedBlock, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 16 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Block = - try { - Block( - SignedBlock.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Block, - ): Unit = try { - SignedBlock.write(writer, instance.signedBlock) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'BlockHeader' variant - */ - public data class BlockHeader( - public val blockHeader: jp.co.soramitsu.iroha2.generated.BlockHeader, - ) : Value() { - 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.Value.BlockHeader = try { - BlockHeader( - jp.co.soramitsu.iroha2.generated.BlockHeader.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.BlockHeader, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.BlockHeader.write(writer, instance.blockHeader) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Ipv4Addr' variant - */ - public data class Ipv4Addr( - public val ipv4Addr: jp.co.soramitsu.iroha2.generated.Ipv4Addr, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 18 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Ipv4Addr = - try { - Ipv4Addr( - jp.co.soramitsu.iroha2.generated.Ipv4Addr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Ipv4Addr, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Ipv4Addr.write(writer, instance.ipv4Addr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Ipv6Addr' variant - */ - public data class Ipv6Addr( - public val ipv6Addr: jp.co.soramitsu.iroha2.generated.Ipv6Addr, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 19 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Ipv6Addr = - try { - Ipv6Addr( - jp.co.soramitsu.iroha2.generated.Ipv6Addr.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Ipv6Addr, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Ipv6Addr.write(writer, instance.ipv6Addr) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Numeric' variant - */ - public data class Numeric( - public val numericValue: NumericValue, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 20 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.Numeric = - try { - Numeric( - NumericValue.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.Numeric, - ): Unit = try { - NumericValue.write(writer, instance.numericValue) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'Executor' variant - */ - public data class Executor( - public val executor: jp.co.soramitsu.iroha2.generated.Executor, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 21 - - 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.Executor, - ): Unit = try { - jp.co.soramitsu.iroha2.generated.Executor.write(writer, instance.executor) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - /** - * 'LogLevel' variant - */ - public data class LogLevel( - public val level: Level, - ) : Value() { - override fun discriminant(): Int = DISCRIMINANT - - public companion object : - ScaleReader, - ScaleWriter { - public const val DISCRIMINANT: Int = 22 - - override fun read(reader: ScaleCodecReader): jp.co.soramitsu.iroha2.generated.Value.LogLevel = - try { - LogLevel( - Level.read(reader), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write( - writer: ScaleCodecWriter, - instance: jp.co.soramitsu.iroha2.generated.Value.LogLevel, - ): Unit = try { - Level.write(writer, instance.level) - } catch (ex: Exception) { - throw wrapException(ex) - } - } - } - - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Value = when (val discriminant = reader.readUByte()) { - 0 -> Bool.read(reader) - 1 -> String.read(reader) - 2 -> Name.read(reader) - 3 -> Vec.read(reader) - 4 -> LimitedMetadata.read(reader) - 5 -> MetadataLimits.read(reader) - 6 -> TransactionLimits.read(reader) - 7 -> LengthLimits.read(reader) - 8 -> Id.read(reader) - 9 -> Identifiable.read(reader) - 10 -> PublicKey.read(reader) - 11 -> SignatureCheckCondition.read(reader) - 12 -> TransactionQueryOutput.read(reader) - 13 -> PermissionToken.read(reader) - 14 -> PermissionTokenSchema.read(reader) - 15 -> Hash.read(reader) - 16 -> Block.read(reader) - 17 -> BlockHeader.read(reader) - 18 -> Ipv4Addr.read(reader) - 19 -> Ipv6Addr.read(reader) - 20 -> Numeric.read(reader) - 21 -> Executor.read(reader) - 22 -> LogLevel.read(reader) - else -> throw RuntimeException("Unresolved discriminant of the enum variant: $discriminant") } - - override fun write(writer: ScaleCodecWriter, instance: Value) { - writer.directWrite(instance.discriminant()) - when (val discriminant = instance.discriminant()) { - 0 -> Bool.write(writer, instance as Bool) - 1 -> String.write(writer, instance as String) - 2 -> Name.write(writer, instance as Name) - 3 -> Vec.write(writer, instance as Vec) - 4 -> LimitedMetadata.write(writer, instance as LimitedMetadata) - 5 -> MetadataLimits.write(writer, instance as MetadataLimits) - 6 -> TransactionLimits.write(writer, instance as TransactionLimits) - 7 -> LengthLimits.write(writer, instance as LengthLimits) - 8 -> Id.write(writer, instance as Id) - 9 -> Identifiable.write(writer, instance as Identifiable) - 10 -> PublicKey.write(writer, instance as PublicKey) - 11 -> SignatureCheckCondition.write(writer, instance as SignatureCheckCondition) - 12 -> TransactionQueryOutput.write(writer, instance as TransactionQueryOutput) - 13 -> PermissionToken.write(writer, instance as PermissionToken) - 14 -> PermissionTokenSchema.write(writer, instance as PermissionTokenSchema) - 15 -> Hash.write(writer, instance as Hash) - 16 -> Block.write(writer, instance as Block) - 17 -> BlockHeader.write(writer, instance as BlockHeader) - 18 -> Ipv4Addr.write(writer, instance as Ipv4Addr) - 19 -> Ipv6Addr.write(writer, instance as Ipv6Addr) - 20 -> Numeric.write(writer, instance as Numeric) - 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/WasmSmartContract.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmSmartContract.kt index 66457f982..d9bde4975 100644 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmSmartContract.kt +++ b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/WasmSmartContract.kt @@ -8,7 +8,10 @@ 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.ByteArray +import kotlin.Int import kotlin.Unit /** @@ -19,6 +22,15 @@ import kotlin.Unit public data class WasmSmartContract( public val vecOfU8: ByteArray, ) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is WasmSmartContract) return false + if (!vecOfU8.contentEquals(other.vecOfU8)) return false + return true + } + + override fun hashCode(): Int = vecOfU8.contentHashCode() + public companion object : ScaleReader, ScaleWriter { override fun read(reader: ScaleCodecReader): WasmSmartContract = try { WasmSmartContract( diff --git a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Where.kt b/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Where.kt deleted file mode 100644 index f39f8976b..000000000 --- a/modules/model/src/main/kotlin/jp/co/soramitsu/iroha2/generated/Where.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.comparator -import jp.co.soramitsu.iroha2.wrapException -import kotlin.Unit -import kotlin.collections.Map - -/** - * Where - * - * Generated from 'Where' regular structure - */ -public data class Where( - public val expression: EvaluatesTo, - public val values: Map>, -) { - public companion object : ScaleReader, ScaleWriter { - override fun read(reader: ScaleCodecReader): Where = try { - Where( - EvaluatesTo.read(reader) as EvaluatesTo, - reader.readMap(reader.readCompactInt(), { Name.read(reader) }, { - EvaluatesTo.read(reader) as - EvaluatesTo - }), - ) - } catch (ex: Exception) { - throw wrapException(ex) - } - - override fun write(writer: ScaleCodecWriter, instance: Where): Unit = try { - EvaluatesTo.write(writer, instance.expression) - writer.writeCompact(instance.values.size) - instance.values.toSortedMap( - Name.comparator(), - ).forEach { (key, value) -> - Name.write(writer, key) - EvaluatesTo.write(writer, value) - } - } catch (ex: Exception) { - throw wrapException(ex) - } - } -} diff --git a/modules/test-tools/README.md b/modules/test-tools/README.md index de6aed796..e50694494 100644 --- a/modules/test-tools/README.md +++ b/modules/test-tools/README.md @@ -5,7 +5,7 @@ You must provide one of Iroha client classes: - `Iroha2Client` - `AdminIroha2Client` - `Iroha2AsyncClient` -- `AdminIroha2AsyncClient` +- `AdminIroha2AsyncClient` - `*AsyncClient` (for usage from Java) You can override `txTimeout` parameter as well. @@ -52,9 +52,8 @@ class Test : IrohaTest() { @Test @WithIrohaManual( apiUrls = ["http://localhost:8080", "http://localhost:8081", "http://localhost:8082", "http://localhost:8083"], - telemetryUrls = ["http://localhost:8180", "http://localhost:8181", "http://localhost:8182", "http://localhost:8183"], peerUrls = ["http://localhost:1337", "http://localhost:1338", "http://localhost:1339", "http://localhost:1340"], - account = "alice@wonderland", + account = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", publicKey = "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", privateKey = "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", ) @@ -63,7 +62,7 @@ class Test : IrohaTest() { @Test @WithIrohaManual( - account = "alice@wonderland", + account = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", publicKey = "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", privateKey = "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", dockerComposeFile = "../../docker-compose/docker-compose.yaml", @@ -84,7 +83,7 @@ In a single peer test, [IrohaRunnerExtension](./src/main/kotlin/jp/co/soramitsu/ ```java @org.junit.jupiter.api.extension.ExtendWith(IrohaRunnerExtension::class) class SinglePeerTest { - + @Test @WithIroha public someTest() { diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaConfig.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaConfig.kt index fe8848dc1..7a0e8ceed 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaConfig.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaConfig.kt @@ -2,12 +2,12 @@ package jp.co.soramitsu.iroha2.testengine import jp.co.soramitsu.iroha2.DEFAULT_API_PORT import jp.co.soramitsu.iroha2.DEFAULT_P2P_PORT -import jp.co.soramitsu.iroha2.DEFAULT_TELEMETRY_PORT import jp.co.soramitsu.iroha2.Genesis import jp.co.soramitsu.iroha2.generateKeyPair import jp.co.soramitsu.iroha2.generated.PeerId import jp.co.soramitsu.iroha2.generated.SocketAddr import jp.co.soramitsu.iroha2.generated.SocketAddrHost +import jp.co.soramitsu.iroha2.keyPairFromHex import jp.co.soramitsu.iroha2.toIrohaPublicKey import org.slf4j.LoggerFactory.getLogger import org.testcontainers.containers.Network @@ -33,11 +33,11 @@ class IrohaConfig( var pullPolicy: ImagePullPolicy = PullPolicy.ageBased(Duration.ofMinutes(10)), var alias: String = IrohaContainer.NETWORK_ALIAS + DEFAULT_P2P_PORT, var keyPair: KeyPair = generateKeyPair(), - var genesisKeyPair: KeyPair = generateKeyPair(), + var genesisKeyPair: KeyPair = keyPairFromHex(GENESIS_ADDRESS, GENESIS_PRIVATE_KEY), var trustedPeers: List = listOf( PeerId(SocketAddr.Host(SocketAddrHost(alias, DEFAULT_P2P_PORT)), keyPair.public.toIrohaPublicKey()), ), - var ports: List = listOf(DEFAULT_P2P_PORT, DEFAULT_API_PORT, DEFAULT_TELEMETRY_PORT), + var ports: List = listOf(DEFAULT_P2P_PORT, DEFAULT_API_PORT), var shouldCloseNetwork: Boolean = true, var waitStrategy: Boolean = true, var submitGenesis: Boolean = true, @@ -48,6 +48,5 @@ class IrohaConfig( companion object { const val P2P_PORT_IDX = 0 const val API_PORT_IDX = 1 - const val TELEMETRY_PORT_IDX = 2 } } 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 2aaafd24a..c7093ce69 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 @@ -8,6 +8,7 @@ import org.testcontainers.containers.GenericContainer import org.testcontainers.containers.wait.strategy.HttpWaitStrategy import org.testcontainers.shaded.com.google.common.io.Resources.getResource import org.testcontainers.utility.DockerImageName +import org.testcontainers.utility.MountableFile import org.testcontainers.utility.MountableFile.forHostPath import java.io.IOException import java.net.URL @@ -31,32 +32,38 @@ open class IrohaContainer : GenericContainer { constructor(config: IrohaConfig) : super(config.getFullImageName()) { val publicKey = config.keyPair.public.bytes().toHex() val privateKey = config.keyPair.private.bytes().toHex() + val containerName = when (config.submitGenesis) { + true -> "MAIN_${config.alias}_${randomUUID().toString().split("-").last()}" + false -> config.alias + } val genesisPublicKey = config.genesisKeyPair.public.bytes().toHex() val genesisPrivateKey = config.genesisKeyPair.private.bytes().toHex() this.p2pPort = config.ports[IrohaConfig.P2P_PORT_IDX] this.apiPort = config.ports[IrohaConfig.API_PORT_IDX] - this.telemetryPort = config.ports[IrohaConfig.TELEMETRY_PORT_IDX] this.config = config this.withNetwork(config.networkToJoin) - .withEnv("SUMERAGI_TRUSTED_PEERS", JSON_SERDE.writeValueAsString(config.trustedPeers)) - .withEnv("IROHA_PUBLIC_KEY", "ed0120$publicKey") - .withEnv("IROHA_PRIVATE_KEY", "{\"digest_function\": \"ed25519\", \"payload\": \"$privateKey$publicKey\"}") - .withEnv("IROHA_GENESIS_ACCOUNT_PUBLIC_KEY", "ed0120$genesisPublicKey") - .withEnv( - "IROHA_GENESIS_ACCOUNT_PRIVATE_KEY", - "{\"digest_function\": \"ed25519\", \"payload\": \"$genesisPrivateKey$genesisPublicKey\"}", - ) - .withEnv("TORII_P2P_ADDR", "${config.alias}:$p2pPort") - .withEnv("TORII_API_URL", "${config.alias}:$apiPort") - .withEnv("TORII_TELEMETRY_URL", "${config.alias}:$telemetryPort") + .withEnv("CHAIN", "00000000-0000-0000-0000-000000000000") + .withEnv("TRUSTED_PEERS", JSON_SERDE.writeValueAsString(config.trustedPeers)) + .withEnv("PUBLIC_KEY", "ed0120$publicKey") + .withEnv("PRIVATE_KEY", "802620$privateKey") + .withEnv("GENESIS_PUBLIC_KEY", "ed0120$genesisPublicKey") + .withEnv("P2P_ADDRESS", "${config.alias}:$p2pPort") + .withEnv("API_ADDRESS", "${config.alias}:$apiPort") .withEnv("TORII_FETCH_SIZE", config.fetchSize.toString()) - .withEnv("WSV_WASM_RUNTIME_CONFIG", "{\"FUEL_LIMIT\":20000000, \"MAX_MEMORY\": 524288000}") + .withCreateContainerCmdModifier { cmd -> cmd.withName(containerName) } + .also { container -> + if (config.submitGenesis) { + container.withEnv("GENESIS_PRIVATE_KEY", "802620$genesisPrivateKey") + container.withEnv("GENESIS", "/tmp/genesis.signed.scale") + container.withEnv("TOPOLOGY", JSON_SERDE.writeValueAsString(config.trustedPeers)) + } + } .also { container -> config.envs.forEach { (k, v) -> container.withEnv(k, v) } } - .withExposedPorts(p2pPort, apiPort, telemetryPort) + .withExposedPorts(p2pPort, apiPort) .withNetworkAliases(config.alias) .withLogConsumer(config.logConsumer) .withCopyToContainer( @@ -80,15 +87,15 @@ open class IrohaContainer : GenericContainer { executorFileLocation.toFile().writeBytes(content) } } - getResource(DEFAULT_CONFIG_FILE_NAME).readBytes().let { content -> - configFileLocation.toFile().writeBytes(content) - } - }.also { container -> - val command = when (config.submitGenesis) { - true -> "$PEER_START_COMMAND --submit-genesis" - false -> PEER_START_COMMAND + } + .also { container -> + if (config.submitGenesis) { + container.withCopyFileToContainer( + MountableFile.forClasspathResource("start.sh"), + "$configDirLocation/start.sh", + ) + container.withCommand("sh", "$configDirLocation/start.sh") } - container.withCommand(command) } .withImagePullPolicy(config.pullPolicy) .also { container -> @@ -110,12 +117,10 @@ open class IrohaContainer : GenericContainer { private val p2pPort: Int private val apiPort: Int - private val telemetryPort: Int private val configDirLocation = createTempDir("$DEFAULT_CONFIG_DIR-", randomUUID().toString()).toPath() private val genesisFileLocation = Path("$configDirLocation/$DEFAULT_GENESIS_FILE_NAME") - private val configFileLocation = Path("$configDirLocation/$DEFAULT_CONFIG_FILE_NAME") private val executorFileLocation = Path("$configDirLocation/$DEFAULT_EXECUTOR_FILE_NAME") override fun start() { @@ -144,8 +149,6 @@ open class IrohaContainer : GenericContainer { fun getApiUrl(): URL = URL("http", host, this.getMappedPort(apiPort), "") - fun getTelemetryUrl(): URL = URL("http", host, this.getMappedPort(telemetryPort), "") - private fun String.readStatusBlocks() = JSON_SERDE.readTree(this).get("blocks")?.doubleValue() companion object { @@ -155,13 +158,11 @@ open class IrohaContainer : GenericContainer { }.let { DockerImageName.parse(it) } const val NETWORK_ALIAS = "iroha" - const val DEFAULT_IMAGE_TAG = "sha256:4dfa7012d79479770e42a9d72ff04436da28cea71863a13907a4f6592e9c0d12" - const val DEFAULT_IMAGE_NAME = "hyperledger/iroha2" + const val DEFAULT_IMAGE_TAG = "2.0.0-pre-rc.22.2" + const val DEFAULT_IMAGE_NAME = "hyperledger/iroha" 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" - const val PEER_START_COMMAND = "iroha" val CONTAINER_STARTUP_TIMEOUT: Duration = Duration.ofSeconds(60) } diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaRunnerExtension.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaRunnerExtension.kt index 5897bd431..579439185 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaRunnerExtension.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaRunnerExtension.kt @@ -4,7 +4,7 @@ import jp.co.soramitsu.iroha2.AdminIroha2AsyncClient import jp.co.soramitsu.iroha2.AdminIroha2Client import jp.co.soramitsu.iroha2.DEFAULT_API_PORT import jp.co.soramitsu.iroha2.DEFAULT_P2P_PORT -import jp.co.soramitsu.iroha2.DEFAULT_TELEMETRY_PORT +import jp.co.soramitsu.iroha2.Genesis import jp.co.soramitsu.iroha2.Genesis.Companion.toSingle import jp.co.soramitsu.iroha2.IrohaSdkException import jp.co.soramitsu.iroha2.asAccountId @@ -12,6 +12,7 @@ import jp.co.soramitsu.iroha2.cast import jp.co.soramitsu.iroha2.client.Iroha2AsyncClient import jp.co.soramitsu.iroha2.client.Iroha2Client import jp.co.soramitsu.iroha2.generateKeyPair +import jp.co.soramitsu.iroha2.generated.ChainId import jp.co.soramitsu.iroha2.generated.PeerId import jp.co.soramitsu.iroha2.generated.SocketAddr import jp.co.soramitsu.iroha2.generated.SocketAddrHost @@ -19,18 +20,22 @@ import jp.co.soramitsu.iroha2.keyPairFromHex import jp.co.soramitsu.iroha2.model.IrohaUrls import jp.co.soramitsu.iroha2.toIrohaPublicKey import kotlinx.coroutines.Deferred +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext import org.junit.jupiter.api.extension.BeforeEachCallback import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.api.extension.InvocationInterceptor import org.junit.jupiter.api.extension.ReflectiveInvocationContext import org.yaml.snakeyaml.Yaml import java.io.File +import java.lang.reflect.Field import java.lang.reflect.Method import java.security.KeyPair import java.util.Collections +import kotlin.reflect.KClass import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty1 import kotlin.reflect.full.createInstance @@ -105,28 +110,32 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { // inject `Iroha2Client` if it is declared in test class setPropertyValue(properties, testInstance) { Iroha2Client( - containers.map { IrohaUrls(it.getApiUrl(), it.getTelemetryUrl(), it.getP2pUrl()) }.toMutableList(), + containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(), + true, ).also { utilizedResources.add(it) } } // inject `AdminIroha2Client` if it is declared in test class setPropertyValue(properties, testInstance) { AdminIroha2Client( - containers.map { IrohaUrls(it.getApiUrl(), it.getTelemetryUrl(), it.getP2pUrl()) }.toMutableList(), + containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(), + true, ).also { utilizedResources.add(it) } } // inject `Iroha2AsyncClient` if it is declared in test class setPropertyValue(properties, testInstance) { Iroha2AsyncClient( - containers.map { IrohaUrls(it.getApiUrl(), it.getTelemetryUrl(), it.getP2pUrl()) }.toMutableList(), + containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(), + true, ).also { utilizedResources.add(it) } } // inject `AdminIroha2AsyncClient` if it is declared in test class setPropertyValue(properties, testInstance) { AdminIroha2AsyncClient( - containers.map { IrohaUrls(it.getApiUrl(), it.getTelemetryUrl(), it.getP2pUrl()) }.toMutableList(), + containers.map { IrohaUrls(it.getApiUrl(), it.getP2pUrl()) }.toMutableList(), + true, ).also { utilizedResources.add(it) } } @@ -138,7 +147,7 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { val properties = testInstance::class.memberProperties val urls = when (this.dockerComposeFile.isEmpty()) { - true -> this.apiUrls.mapIndexed { idx, url -> IrohaUrls(url, telemetryUrls[idx], peerUrls[idx]) } + true -> this.apiUrls.mapIndexed { idx, url -> IrohaUrls(url, peerUrls[idx]) } else -> File(this.dockerComposeFile).readDockerComposeData() } ?: throw IrohaSdkException("Iroha URLs required") @@ -177,7 +186,6 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { return all.map { IrohaUrls( it["TORII_API_URL"].convertUrl(), - it["TORII_TELEMETRY_URL"].convertUrl(), it["TORII_P2P_ADDR"].convertUrl(), ) } @@ -212,9 +220,8 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { repeat(withIroha.amount) { n -> keyPairs.add(generateKeyPair()) - portsList.add(listOf(DEFAULT_P2P_PORT + n, DEFAULT_API_PORT + n, DEFAULT_TELEMETRY_PORT + n)) + portsList.add(listOf(DEFAULT_P2P_PORT + n, DEFAULT_API_PORT + n)) } - val genesisKeyPair = generateKeyPair() val peerIds = keyPairs.mapIndexed { i: Int, kp: KeyPair -> val p2pPort = portsList[i][IrohaConfig.P2P_PORT_IDX] kp.toPeerId(IrohaContainer.NETWORK_ALIAS + p2pPort, p2pPort) @@ -228,14 +235,12 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { this.networkToJoin = testInstance.network when { withIroha.source.isNotEmpty() -> genesisPath = withIroha.source - else -> genesis = withIroha.sources.map { it.createInstance() }.toSingle() + else -> genesis = withIroha.sources.map { genesisInstance(it) }.toSingle() } this.alias = IrohaContainer.NETWORK_ALIAS + p2pPort this.keyPair = keyPairs[n] - this.genesisKeyPair = genesisKeyPair this.trustedPeers = peerIds this.ports = portsList[n] - this.fetchSize = withIroha.fetchSize this.imageName = testInstance.imageName this.imageTag = testInstance.imageTag this.envs = withIroha.configs.associate { config -> @@ -249,12 +254,16 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { this.executorPath = withIroha.executorSource } } - container.start() + withContext(Dispatchers.IO) { + container.start() + } containers.add(container) }.let { deferredSet.add(it) } } - deferredSet.forEach { it.await() } + withContext(Dispatchers.IO) { + deferredSet.forEach { it.await() } + } containers } @@ -265,4 +274,26 @@ class IrohaRunnerExtension : InvocationInterceptor, BeforeEachCallback { ) private fun ExtensionContext.testId() = "${this.testClass.get().name}_${this.testMethod.get().name}" + + private fun genesisInstance(clazz: KClass): Genesis = clazz.createInstance().let { genesis -> + val tx = genesis.transaction.copy( + chain = ChainId("00000000-0000-0000-0000-000000000000"), + ) + val transactionField = findField(clazz.java, "transaction") + transactionField.isAccessible = true + transactionField.set(genesis, tx) + + return genesis + } + + private fun findField(clazz: Class<*>, fieldName: String): Field { + return try { + clazz.getDeclaredField(fieldName) + } catch (e: NoSuchFieldException) { + when (clazz.superclass == null) { + true -> throw e + false -> findField(clazz.superclass, fieldName) + } + } + } } diff --git a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaTest.kt b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaTest.kt index 6f6403a67..bbf6a4a54 100644 --- a/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaTest.kt +++ b/modules/test-tools/src/main/kotlin/jp/co/soramitsu/iroha2/testengine/IrohaTest.kt @@ -31,19 +31,13 @@ abstract class IrohaTest( suspend fun Iroha2Client.tx( account: AccountId? = null, - vararg keyPairs: KeyPair, + keyPair: KeyPair? = null, builder: TransactionBuilder.() -> Unit = {}, - ) { - val finalAccountId = account ?: this@IrohaTest.account - - this.sendTransaction { - account(finalAccountId) - builder(this) - keyPairs.takeIf { it.isNotEmpty() }?.let { - buildSigned(*keyPairs) - } ?: buildSigned(this@IrohaTest.keyPair) - }.also { d -> - withTimeout(txTimeout) { d.await() } - } + ) = this.sendTransaction { + account(account ?: this@IrohaTest.account) + builder(this) + buildSigned(keyPair ?: this@IrohaTest.keyPair) + }.also { d -> + withTimeout(txTimeout) { d.await() } } } 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 a61b1a1fd..c17e8733b 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 @@ -1,49 +1,57 @@ package jp.co.soramitsu.iroha2.testengine -import jp.co.soramitsu.iroha2.ACCOUNT_ID_DELIMITER -import jp.co.soramitsu.iroha2.asAccountId import jp.co.soramitsu.iroha2.asDomainId import jp.co.soramitsu.iroha2.asName -import jp.co.soramitsu.iroha2.generateKeyPair import jp.co.soramitsu.iroha2.generated.AccountId import jp.co.soramitsu.iroha2.generated.AssetDefinitionId import jp.co.soramitsu.iroha2.generated.AssetId +import jp.co.soramitsu.iroha2.keyPairFromHex +import jp.co.soramitsu.iroha2.publicKeyFromHex +import jp.co.soramitsu.iroha2.toIrohaPublicKey const val DEFAULT_DOMAIN = "wonderland" -const val ALICE_ACCOUNT = "alice" -const val BOB_ACCOUNT = "bob" -const val GENESIS = "genesis" -const val ALICE_ACCOUNT_ID_VALUE = "$ALICE_ACCOUNT$ACCOUNT_ID_DELIMITER$DEFAULT_DOMAIN" +const val GENESIS_DOMAIN = "genesis" +const val GENESIS_ADDRESS = "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4" +const val GENESIS_PRIVATE_KEY = "82B3BDE54AEBECA4146257DA0DE8D59D8E46D5FE34887DCD8072866792FCB3AD" + +@JvmField +val GENESIS_ACCOUNT = AccountId(GENESIS_DOMAIN.asDomainId(), publicKeyFromHex(GENESIS_ADDRESS).toIrohaPublicKey()) @JvmField val DEFAULT_DOMAIN_ID = DEFAULT_DOMAIN.asDomainId() @JvmField -val ALICE_ACCOUNT_NAME = ALICE_ACCOUNT.asName() +val ALICE_KEYPAIR = keyPairFromHex( + "CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03", + "CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53", +) @JvmField -val ALICE_ACCOUNT_ID = ALICE_ACCOUNT_ID_VALUE.asAccountId() +val ALICE_PUBLIC_KEY = ALICE_KEYPAIR.public.toIrohaPublicKey() @JvmField -val ALICE_KEYPAIR = generateKeyPair() +val ALICE_ACCOUNT_ID = AccountId(domain = DEFAULT_DOMAIN_ID, signatory = ALICE_PUBLIC_KEY) @JvmField -val BOB_ACCOUNT_NAME = BOB_ACCOUNT.asName() +val BOB_KEYPAIR = keyPairFromHex( + "04FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016", + "AF3F96DEEF44348FEB516C057558972CEC4C75C4DB9C5B3AAC843668854BF828", +) @JvmField -val BOB_ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, BOB_ACCOUNT_NAME) +val BOB_PUBLIC_KEY = BOB_KEYPAIR.public.toIrohaPublicKey() @JvmField -val BOB_KEYPAIR = generateKeyPair() +val BOB_ACCOUNT_ID = AccountId(DEFAULT_DOMAIN_ID, BOB_PUBLIC_KEY) @JvmField -val DEFAULT_ASSET_DEFINITION_ID = AssetDefinitionId("xor".asName(), DEFAULT_DOMAIN_ID) +val DEFAULT_ASSET_DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "xor".asName()) @JvmField -val DEFAULT_ASSET_ID = AssetId(DEFAULT_ASSET_DEFINITION_ID, ALICE_ACCOUNT_ID) +val DEFAULT_ASSET_ID = AssetId(ALICE_ACCOUNT_ID, DEFAULT_ASSET_DEFINITION_ID) @JvmField -val XOR_DEFINITION_ID = AssetDefinitionId("xor".asName(), DEFAULT_DOMAIN_ID) +val XOR_DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "xor".asName()) @JvmField -val VAL_DEFINITION_ID = AssetDefinitionId("val".asName(), DEFAULT_DOMAIN_ID) +val VAL_DEFINITION_ID = AssetDefinitionId(DEFAULT_DOMAIN_ID, "val".asName()) 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 7b488f255..f0aa049d9 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 @@ -1,9 +1,11 @@ package jp.co.soramitsu.iroha2.testengine import jp.co.soramitsu.iroha2.Genesis -import jp.co.soramitsu.iroha2.generated.RawGenesisBlock +import jp.co.soramitsu.iroha2.generated.ChainId +import jp.co.soramitsu.iroha2.generated.RawGenesisTransaction import org.junit.jupiter.api.Test import java.lang.annotation.Inherited +import java.util.UUID import kotlin.reflect.KClass /** @@ -22,7 +24,6 @@ annotation class WithIroha( val configs: Array = [], val source: String = "", val amount: Int = 1, - val fetchSize: Int = 10, val executorSource: String = "", ) @@ -33,7 +34,6 @@ annotation class WithIroha( @Inherited annotation class WithIrohaManual( val apiUrls: Array = [], - val telemetryUrls: Array = [], val peerUrls: Array = [], val account: String = "", val publicKey: String = "", @@ -45,7 +45,7 @@ annotation class WithIrohaManual( * Empty genesis with no instructions */ open class EmptyGenesis : Genesis( - RawGenesisBlock(listOf(emptyList()), executorMode), + RawGenesisTransaction(ChainId(UUID.randomUUID().toString()), EXECUTOR_FILE_NAME, emptyList(), emptyList(), emptyList()), ) const val IROHA_CONFIG_DELIMITER = "=" diff --git a/modules/test-tools/src/main/resources/.cleanup.wip-7 b/modules/test-tools/src/main/resources/.cleanup.wip-7 deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/test-tools/src/main/resources/client.toml b/modules/test-tools/src/main/resources/client.toml new file mode 100644 index 000000000..614a43d3b --- /dev/null +++ b/modules/test-tools/src/main/resources/client.toml @@ -0,0 +1,11 @@ +chain = "00000000-0000-0000-0000-000000000000" +torii_url = "http://127.0.0.1:8080/" + +[basic_auth] +web_login = "mad_hatter" +password = "ilovetea" + +[account] +domain = "wonderland" +public_key = "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03" +private_key = "802620CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53" \ No newline at end of file diff --git a/modules/test-tools/src/main/resources/config.json b/modules/test-tools/src/main/resources/config.json deleted file mode 100644 index 56c747568..000000000 --- a/modules/test-tools/src/main/resources/config.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "PUBLIC_KEY": null, - "PRIVATE_KEY": null, - "DISABLE_PANIC_TERMINAL_COLORS": false, - "KURA": { - "INIT_MODE": "strict", - "BLOCK_STORE_PATH": "./storage", - "BLOCKS_PER_STORAGE_FILE": 1000, - "ACTOR_CHANNEL_CAPACITY": 100, - "DEBUG_OUTPUT_NEW_BLOCKS": false - }, - "SUMERAGI": { - "KEY_PAIR": null, - "PEER_ID": null, - "BLOCK_TIME_MS": 2000, - "TRUSTED_PEERS": null, - "COMMIT_TIME_LIMIT_MS": 4000, - "MAX_TRANSACTIONS_IN_BLOCK": 512, - "ACTOR_CHANNEL_CAPACITY": 100, - "GOSSIP_BATCH_SIZE": 500, - "GOSSIP_PERIOD_MS": 1000 - }, - "TORII": { - "P2P_ADDR": null, - "API_URL": null, - "TELEMETRY_URL": null, - "MAX_TRANSACTION_SIZE": 32768, - "MAX_CONTENT_LEN": 16384000, - "FETCH_SIZE": 10, - "QUERY_IDLE_TIME_MS": 30000 - }, - "BLOCK_SYNC": { - "GOSSIP_PERIOD_MS": 10000, - "BLOCK_BATCH_SIZE": 4, - "ACTOR_CHANNEL_CAPACITY": 100 - }, - "QUEUE": { - "MAX_TRANSACTIONS_IN_QUEUE": 65536, - "MAX_TRANSACTIONS_IN_QUEUE_PER_USER": 65536, - "TRANSACTION_TIME_TO_LIVE_MS": 86400000, - "FUTURE_THRESHOLD_MS": 1000 - }, - "LOGGER": { - "MAX_LOG_LEVEL": "INFO", - "TELEMETRY_CAPACITY": 1000, - "COMPACT_MODE": false, - "LOG_FILE_PATH": null, - "TERMINAL_COLORS": true - }, - "GENESIS": { - "ACCOUNT_PUBLIC_KEY": null, - "ACCOUNT_PRIVATE_KEY": null - }, - "WSV": { - "ASSET_METADATA_LIMITS": { - "max_len": 1048576, - "max_entry_byte_size": 4096 - }, - "ASSET_DEFINITION_METADATA_LIMITS": { - "max_len": 1048576, - "max_entry_byte_size": 4096 - }, - "ACCOUNT_METADATA_LIMITS": { - "max_len": 1048576, - "max_entry_byte_size": 4096 - }, - "DOMAIN_METADATA_LIMITS": { - "max_len": 1048576, - "max_entry_byte_size": 4096 - }, - "IDENT_LENGTH_LIMITS": { - "min": 1, - "max": 128 - }, - "TRANSACTION_LIMITS": { - "max_instruction_number": 4096, - "max_wasm_size_bytes": 4194304 - }, - "WASM_RUNTIME_CONFIG": { - "FUEL_LIMIT": 23000000, - "MAX_MEMORY": 524288000 - } - }, - "NETWORK": { - "ACTOR_CHANNEL_CAPACITY": 100 - }, - "TELEMETRY": { - "NAME": null, - "URL": null, - "MIN_RETRY_PERIOD": 1, - "MAX_RETRY_DELAY_EXPONENT": 4, - "FILE": null - } -} diff --git a/modules/test-tools/src/main/resources/executor.wasm b/modules/test-tools/src/main/resources/executor.wasm old mode 100755 new mode 100644 index 265a5d68b..f51b51123 Binary files a/modules/test-tools/src/main/resources/executor.wasm 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 a49986682..8da79f092 100644 --- a/modules/test-tools/src/main/resources/genesis.json +++ b/modules/test-tools/src/main/resources/genesis.json @@ -1,167 +1,289 @@ { - "transactions": [ - [ - { - "Register": { - "NewDomain": { - "id": "wonderland", - "logo": null, - "metadata": {} + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "./executor.wasm", + "parameters": [ + { + "Sumeragi": { + "BlockTimeMs": 2000 + } + }, + { + "Sumeragi": { + "CommitTimeMs": 4000 + } + }, + { + "Block": { + "MaxTransactions": 512 + } + }, + { + "Transaction": { + "MaxInstructions": 4096 + } + }, + { + "Transaction": { + "SmartContractSize": 4194304 + } + }, + { + "Executor": { + "Fuel": 5500000000 + } + }, + { + "Executor": { + "Memory": 550000000 + } + }, + { + "SmartContract": { + "Fuel": 5500000000 + } + }, + { + "SmartContract": { + "Memory": 550000000 + } + } + ], + "instructions": [ + { + "Register": { + "Domain": { + "id": "wonderland", + "logo": null, + "metadata": { + "key": "value" } } - }, - { - "Register": { - "NewAccount": { - "id": "alice@wonderland", - "signatories": [ - "ed0120719ba8c6bf3f226b1fba2a91cd0136e5e9268cdfc7549389f28e18df8b3ca394" - ], + } + }, + { + "Register": { + "Trigger": { + "id": "name$wonderland", + "action": { + "executable": { + "Instructions": [ + { + "SetKeyValue": { + "Domain": { + "object": "wonderland", + "key": "key", + "value": "value" + } + } + } + ] + }, + "repeats": { + "Exactly": 1 + }, + "authority": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@wonderland", + "filter": { + "ExecuteTrigger": { + "trigger": "name", + "authority": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@wonderland" + } + }, "metadata": {} } } - }, - { - "Register": { - "NewAccount": { - "id": "bob@wonderland", - "signatories": [ - "ed0120a9a0e6b5300e46aaa490d2b01fac1b892be74360e7ce87d9d5d329f1995646db" - ], + } + }, + { + "Register": { + "Trigger": { + "id": "time_trigger", + "action": { + "executable": { + "Instructions": [ + { + "SetKeyValue": { + "Domain": { + "object": "wonderland", + "key": "key", + "value": "value" + } + } + } + ] + }, + "repeats": "Indefinitely", + "authority": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@wonderland", + "filter": { + "Time": { + "Schedule": { + "start_ms": 1790774026000, + "period_ms": 1000 + } + } + }, "metadata": {} } } - }, - { - "Register": { - "NewAssetDefinition": { - "id": "xor#wonderland", - "value_type": "Quantity", - "mintable": "Infinitely", - "logo": null, - "metadata": {} + } + }, + { + "Register": { + "Account": { + "id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "metadata": { + "key": "value" } } - }, - { - "Grant": { - "object": { - "PermissionToken": { - "definition_id": "CanTransferAssetsWithDefinition", - "payload" : { - "asset_definition_id" : "xor#wonderland" - } - } - }, - "destination_id": { - "AccountId": "alice@wonderland" + } + }, + { + "Register": { + "Account": { + "id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland", + "metadata": { + "key": "value" } } - }, - { - "Grant": { - "object": { - "PermissionToken": { - "definition_id": "CanTransferAssetsWithDefinition", - "payload" : { - "asset_definition_id" : "xor#wonderland" - } - } - }, - "destination_id": { - "AccountId": "bob@wonderland" - } + } + }, + { + "Register": { + "AssetDefinition": { + "id": "rose#wonderland", + "type": "Numeric", + "mintable": "Infinitely", + "logo": null, + "metadata": {} } - }, - { - "Mint": { - "object": "100_u32", - "destination_id": { - "AssetId": "xor#wonderland#alice@wonderland" - } + } + }, + { + "Register": { + "Domain": { + "id": "garden_of_live_flowers", + "logo": null, + "metadata": {} } - }, - { - "Mint": { - "object": "100_u32", - "destination_id": { - "AssetId": "xor#wonderland#bob@wonderland" - } + } + }, + { + "Register": { + "Account": { + "id": "ed0120E9F632D3034BAB6BB26D92AC8FD93EF878D9C5E69E01B61B4C47101884EE2F99@garden_of_live_flowers", + "metadata": {} } - }, - { - "Register" : { - "Trigger" : { - "id" : "name$wonderland", - "action" : { - "executable" : { - "Instructions" : [ { - "SetKeyValue" : { - "DomainId" : "wonderland", - "key" : { - "Name" : "key" - }, - "value" : { - "String" : "value" - } - } - } ] - }, - "repeats" : { - "Exactly" : 1 - }, - "authority" : "alice@wonderland", - "filter" : { - "ExecuteTrigger" : { - "trigger_id" : "name$wonderland", - "authority" : "alice@wonderland" - } - }, - "metadata" : { } + } + }, + { + "Register": { + "AssetDefinition": { + "id": "cabbage#garden_of_live_flowers", + "type": "Numeric", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } + } + }, + { + "Mint": { + "Asset": { + "object": "13", + "destination": "rose#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + }, + { + "Mint": { + "Asset": { + "object": "44", + "destination": "cabbage#garden_of_live_flowers#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + }, + { + "Transfer": { + "AssetDefinition": { + "source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", + "object": "rose#wonderland", + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + }, + { + "Transfer": { + "Domain": { + "source": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@genesis", + "object": "wonderland", + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + }, + { + "Grant": { + "Permission": { + "object": { + "name": "CanSetParameters", + "payload": null + }, + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + }, + { + "Register": { + "Role": { + "id": "ALICE_METADATA_ACCESS", + "permissions": [ + { + "name": "CanRemoveKeyValueInAccount", + "payload": { + "account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + }, + { + "name": "CanSetKeyValueInAccount", + "payload": { + "account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } } - } + ] } - }, - { - "Register" : { - "Trigger" : { - "id" : "time_trigger", - "action" : { - "executable" : { - "Instructions" : [ { - "SetKeyValue" : { - "DomainId" : "wonderland", - "key" : { - "Name" : "key" - }, - "value" : { - "String" : "value" - } - } - } ] - }, - "repeats" : "Indefinitely", - "authority" : "alice@wonderland", - "filter" : { - "Time" : { - "Schedule" : { - "start" : { - "secs" : 1715161770, - "nanos" : 0 - }, - "period" : { - "secs" : 1, - "nanos" : 0 + } + }, + { + "Register": { + "Trigger": { + "id": "name2$wonderland", + "action": { + "executable": { + "Instructions": [ + { + "SetKeyValue": { + "Domain": { + "object": "wonderland", + "key": "key", + "value": "value" } } } - }, - "metadata" : { } - } + ] + }, + "repeats": { + "Exactly": 1 + }, + "authority": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "filter": { + "ExecuteTrigger": { + "trigger": "name", + "authority": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + }, + "metadata": {} } } } - ] + } ], - "executor": "./executor.wasm" + "topology": [] } diff --git a/modules/test-tools/src/main/resources/genesis2.json b/modules/test-tools/src/main/resources/genesis2.json index be860aa3d..2221f050f 100644 --- a/modules/test-tools/src/main/resources/genesis2.json +++ b/modules/test-tools/src/main/resources/genesis2.json @@ -1,214 +1,224 @@ { - "transactions" : [ [ { - "Register" : { - "NewDomain" : { - "id" : "wonderland", - "logo" : null, - "metadata" : { } + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "./executor.wasm", + "parameters": [], + "instructions": [ + { + "Register": { + "Domain": { + "id": "wonderland", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewDomain" : { - "id" : "dnalrednow", - "logo" : null, - "metadata" : { } + }, + { + "Register": { + "Domain": { + "id": "dnalrednow", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewDomain" : { - "id" : "test", - "logo" : null, - "metadata" : { } + }, + { + "Register": { + "Domain": { + "id": "test", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewDomain" : { - "id" : "admin", - "logo" : null, - "metadata" : { } + }, + { + "Register": { + "Domain": { + "id": "admin", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "alice@wonderland", - "signatories" : [ "ed01200851a1fa7e3f04a657299263e119975be4ab0d33631ec6ad4bd5b5e77594310e" ], - "metadata" : { } + }, + { + "Register": { + "Account": { + "id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "metadata": {} + } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "admin@wonderland", - "signatories" : [ "ed01203161f2c70db3252505b90c0cce012c4cf4cb098da2a3b1475319ca5b3a1263f5" ], - "metadata" : { } + }, + { + "Register": { + "Account": { + "id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland", + "metadata": {} + } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "admin@dnalrednow", - "signatories" : [ "ed0120d24280aadc7167e002b263620fe936e4103e13d59a02286190a6af6a45c7c2f7" ], - "metadata" : { } + }, + { + "Register": { + "Account": { + "id": "ed0120E9F632D3034BAB6BB26D92AC8FD93EF878D9C5E69E01B61B4C47101884EE2F99@dnalrednow", + "metadata": {} + } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "admin2@wonderland", - "signatories" : [ "ed01202611be069b48f6313d86a4e5c99deedaccc3046b4cb294849e11dadb27a701ca" ], - "metadata" : { } + }, + { + "Register": { + "Account": { + "id": "ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4@wonderland", + "metadata": {} + } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "bob@admin", - "signatories" : [ "ed01207f7137560b2c1fefa36834f609953f8ad78903a7f21d3c84a69949991885ba1c" ], - "metadata" : { - "authentication" : { - "String" : "9321c6560bdbe28df7808e4d03b0ef625c4e8f8e9935907763477ac601421066" + }, + { + "Register": { + "Account": { + "id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@admin", + "metadata": { + "authentication": "9321c6560bdbe28df7808e4d03b0ef625c4e8f8e9935907763477ac601421066" } } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "test_asset#admin", - "value_type" : "Store", - "mintable" : "Once", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "test_asset#admin", + "type": "Store", + "mintable": "Once", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "wonderland_asset#admin", - "value_type" : "Store", - "mintable" : "Once", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "wonderland_asset#admin", + "type": "Store", + "mintable": "Once", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "123#test", - "value_type" : "Store", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "123#test", + "type": "Store", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "Asset" : { - "id" : "wonderland_asset#admin#bob@admin", - "value" : { - "Store" : { } + }, + { + "Register": { + "Asset": { + "id": "wonderland_asset#admin#ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@admin", + "value": { + "Store": {} + } } } - } - }, { - "Register" : { - "Asset" : { - "id" : "test_asset#admin#bob@admin", - "value" : { - "Store" : { } + }, + { + "Register": { + "Asset": { + "id": "test_asset#admin#ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@admin", + "value": { + "Store": {} + } } } - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "id" - }, - "value" : { - "String" : "123_u32" + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "id", + "value": "123" + } } - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "wt" - }, - "value" : "123_u32" - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "fg" - }, - "value" : { - "String" : "test" + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "wt", + "value": "123" + } } - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "ij" - }, - "value" : { - "String" : "test" + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "fg", + "value": "test" + } } - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "gh" - }, - "value" : "123_u32" - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "ef" - }, - "value" : "1234_u32" - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "cd" - }, - "value" : "123_u32" - } - }, { - "SetKeyValue" : { - "AssetId" : "123#test#alice@wonderland", - "key" : { - "Name" : "ab" - }, - "value" : { - "Bool" : false + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "ij", + "value": "test" + } } - } - }, { - "Grant" : { - "object": { - "PermissionToken" : { - "definition_id" : "CanSetKeyValueInUserAssets", - "payload" : { - "asset_id" : "123#test#alice@wonderland" - } + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "ef", + "value": "1234" + } + } + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "ef", + "value": "1234" + } + } + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "cd", + "value": "123" + } + } + }, + { + "SetKeyValue": { + "Asset": { + "object": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "ab", + "value": "false" + } + } + }, + { + "Grant": { + "Permission": { + "object": { + "name": "CanSetKeyValueInUserAssets", + "payload": { + "asset": "123#test#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + }, + "destination": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@admin" } - }, - "destination_id" : { - "AccountId" : "bob@admin" } } - } ] ], - "executor": "./executor.wasm" + ], + "topology": [] } diff --git a/modules/test-tools/src/main/resources/genesis3.json b/modules/test-tools/src/main/resources/genesis3.json index 9de5e5121..b69226262 100644 --- a/modules/test-tools/src/main/resources/genesis3.json +++ b/modules/test-tools/src/main/resources/genesis3.json @@ -1,184 +1,190 @@ { - "transactions" : [ [ { - "Register" : { - "NewDomain" : { - "id" : "wonderland", - "logo" : null, - "metadata" : { - "OhOXbyHMGo" : { - "String" : "OhOXbyHMGo" + "chain": "00000000-0000-0000-0000-000000000000", + "executor": "./executor.wasm", + "parameters": [], + "instructions": [ + { + "Register": { + "Domain": { + "id": "wonderland", + "logo": null, + "metadata": { + "OhOXbyHMGo": "OhOXbyHMGo" } } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "alice@wonderland", - "signatories" : [ "ed01201dd28d2ed1e708998990982007dcf2e1582d73a62fcb40460152ff8114c217e2" ], - "metadata" : { - "xnPrkBHMaF" : { - "String" : "xnPrkBHMaF" + }, + { + "Register": { + "Account": { + "id": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "metadata": { + "xnPrkBHMaF": "xnPrkBHMaF" } } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "bob@wonderland", - "signatories" : [ "ed01206bd8c135e5f490b5f66b79b0e366af1b7560c251e5fffe37e7e5c5b9f5565dc4" ], - "metadata" : { - "kGwJtCQaew" : { - "String" : "kGwJtCQaew" + }, + { + "Register": { + "Account": { + "id": "ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland", + "metadata": { + "kGwJtCQaew": "kGwJtCQaew" } } } - } - }, { - "Register" : { - "NewAccount" : { - "id" : "foo@wonderland", - "signatories" : [ "ed0120d52923932164a87280eda508d321e252b04e9fe5fc82a36adac8ccb5df257338" ], - "metadata" : { - "key" : { - "String" : "value" + }, + { + "Register": { + "Account": { + "id": "ed0120E9F632D3034BAB6BB26D92AC8FD93EF878D9C5E69E01B61B4C47101884EE2F99@wonderland", + "metadata": { + "key": "value" } } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "xor#wonderland", - "value_type" : "Quantity", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "xor#wonderland", + "type": "Numeric", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "test#wonderland", - "value_type" : "Store", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "test#wonderland", + "type": "Store", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "test2#wonderland", - "value_type" : "Store", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "test2#wonderland", + "type": "Store", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "val#wonderland", - "value_type" : "Quantity", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { } + }, + { + "Register": { + "AssetDefinition": { + "id": "val#wonderland", + "type": "Numeric", + "mintable": "Infinitely", + "logo": null, + "metadata": {} + } } - } - }, { - "Register" : { - "NewAssetDefinition" : { - "id" : "foo#wonderland", - "value_type" : "Store", - "mintable" : "Infinitely", - "logo": null, - "metadata" : { - "key" : { - "String" : "sqhghUGohQkHtMWdynXQvcFhzSBCOzDBuXbeIRiZKgxPMLifiJ" + }, + { + "Register": { + "AssetDefinition": { + "id": "foo#wonderland", + "type": "Store", + "mintable": "Infinitely", + "logo": null, + "metadata": { + "key": "sqhghUGohQkHtMWdynXQvcFhzSBCOzDBuXbeIRiZKgxPMLifiJ" } } } - } - }, { - "Register" : { - "NewRole" : { - "id" : "USER_METADATA_ACCESS", - "permissions" : [ { - "definition_id" : "CanSetKeyValueInUserAsset", - "payload" : { - "account_id" : "alice@wonderland" - } - }, { - "definition_id" : "CanRemoveKeyValueInUserAsset", - "payload" : { - "account_id" : "alice@wonderland" - } - } ] + }, + { + "Register": { + "Role": { + "id": "USER_METADATA_ACCESS", + "permissions": [ + { + "name": "CanSetKeyValueInUserAsset", + "payload": { + "account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + }, + { + "name": "CanRemoveKeyValueInUserAsset", + "payload": { + "account": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } + } + ] + } } - } - }, { - "Mint" : { - "object" : "100_u32", - "destination_id" : { - "AssetId" : "xor#wonderland#alice@wonderland" + }, + { + "Mint": { + "Asset": { + "object": "100", + "destination": "xor#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" + } } - } - }, { - "Grant" : { - "object": { - "PermissionToken" : { - "definition_id" : "CanBurnAssetWithDefinition", - "payload" : { - "asset_definition_id" : "xor#wonderland" - } + }, + { + "Grant": { + "Permission": { + "object": { + "name": "CanBurnAssetWithDefinition", + "payload": { + "asset_definition": "xor#wonderland" + } + }, + "destination": "ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } - }, - "destination_id" : { - "AccountId" : "alice@wonderland" } - } - }, { - "SetKeyValue" : { - "AssetId" : "foo#wonderland#alice@wonderland", - "key" : { - "Name" : "key" - }, - "value" : { - "String" : "sqhghUGohQkHtMWdynXQvcFhzSBCOzDBuXbeIRiZKgxPMLifiJ" + }, + { + "SetKeyValue": { + "Asset": { + "object": "foo#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "key", + "value": "sqhghUGohQkHtMWdynXQvcFhzSBCOzDBuXbeIRiZKgxPMLifiJ" + } } - } - }, + }, { - "SetKeyValue" : { - "AssetId" : "foo#wonderland#alice@wonderland", - "key" : { - "Name" : "key2" - }, - "value" : "123_u32" + "SetKeyValue": { + "Asset": { + "object": "foo#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland", + "key": "key2", + "value": "123" + } } - },{ - "Mint" : { - "object" : "100_u32", - "destination_id" : { - "AssetId" : "xor#wonderland#bob@wonderland" + }, + { + "Mint": { + "Asset": { + "object": "100", + "destination": "xor#wonderland#ed012004FF5B81046DDCCF19E2E451C45DFB6F53759D4EB30FA2EFA807284D1CC33016@wonderland" } } - }, { - "Mint" : { - "object" : "1_u32", - "destination_id" : { - "AssetId" : "xor#wonderland#alice@wonderland" + }, + { + "Mint": { + "Asset": { + "object": "1", + "destination": "xor#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } - }, { - "Mint" : { - "object" : "1_u32", - "destination_id" : { - "AssetId" : "val#wonderland#alice@wonderland" + }, + { + "Mint": { + "Asset": { + "object": "1", + "destination": "val#wonderland#ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland" } } - } ] ], - "executor": "./executor.wasm" + } + ], + "topology": [] } diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw b/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw deleted file mode 100644 index 3a2c458b0..000000000 Binary files a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw and /dev/null differ diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw.stats b/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw.stats deleted file mode 100644 index 73ce0b87e..000000000 --- a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/02-jxzYIPEeFfHgyrfKeUrRaWUHW1kLLAWyMDmjTCxw.stats +++ /dev/null @@ -1,2 +0,0 @@ -usages = 1 -optimized-compression = 3 diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4 b/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4 deleted file mode 100644 index a96bd40d4..000000000 Binary files a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4 and /dev/null differ diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4.stats b/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4.stats deleted file mode 100644 index 73ce0b87e..000000000 --- a/modules/test-tools/src/main/resources/modules/wasmtime-11.0.1/XuVAA8BpdcLYAZucwSt97ATU4ibEZb_oX4vKrDdIIf4.stats +++ /dev/null @@ -1,2 +0,0 @@ -usages = 1 -optimized-compression = 3 diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE b/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE deleted file mode 100644 index 44974d3bf..000000000 Binary files a/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE and /dev/null differ diff --git a/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE.stats b/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE.stats deleted file mode 100644 index 73ce0b87e..000000000 --- a/modules/test-tools/src/main/resources/modules/wasmtime-13.0.0/pyfssYVVmJmbdyZIaUWvVvR9JqGjFTV2MhnGX1IMUWE.stats +++ /dev/null @@ -1,2 +0,0 @@ -usages = 1 -optimized-compression = 3 diff --git a/modules/test-tools/src/main/resources/start.sh b/modules/test-tools/src/main/resources/start.sh new file mode 100644 index 000000000..0821ee387 --- /dev/null +++ b/modules/test-tools/src/main/resources/start.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +# Set executor paths +EXECUTOR_RELATIVE_PATH=$(jq -r '.executor' /config/genesis.json) +EXECUTOR_ABSOLUTE_PATH=$(realpath "/config/$EXECUTOR_RELATIVE_PATH") + +# Update genesis.json +jq --arg executor "$EXECUTOR_ABSOLUTE_PATH" --argjson topology "$TOPOLOGY" '.executor = $executor | .topology = $topology' /config/genesis.json > /tmp/genesis.json + +# Sign the genesis +kagami genesis sign /tmp/genesis.json --public-key "$GENESIS_PUBLIC_KEY" --private-key "$GENESIS_PRIVATE_KEY" --out-file "$GENESIS" + +# Start irohad +exec irohad \ No newline at end of file