diff --git a/examples/tutorial/build.gradle.kts b/examples/tutorial/build.gradle.kts new file mode 100644 index 000000000..0260ad346 --- /dev/null +++ b/examples/tutorial/build.gradle.kts @@ -0,0 +1,12 @@ +dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.0") + + implementation("net.i2p.crypto:eddsa:0.3.0") + implementation("org.bouncycastle:bcprov-jdk15on:1.65") + implementation("com.github.multiformats:java-multihash:1.3.0") + + implementation(project(":model")) + implementation(project(":block")) + api(project(":admin-client")) +} 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 new file mode 100644 index 000000000..9ca1d3c54 --- /dev/null +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt @@ -0,0 +1,63 @@ +package jp.co.soramitsu.iroha2 + +import jp.co.soramitsu.iroha2.generated.AccountId +import jp.co.soramitsu.iroha2.generated.AssetValue +import jp.co.soramitsu.iroha2.generated.AssetValueType +import kotlinx.coroutines.runBlocking +import java.net.URL + +fun main(args: Array): Unit = runBlocking { + val peerUrl = "http://127.0.0.1:8080" + val telemetryUrl = "http://127.0.0.1:8180" + val admin = AccountId("bob".asName(), "wonderland".asDomainId()) + val adminKeyPair = keyPairFromHex( + "7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", + "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e", + ) + + val client = AdminIroha2Client(URL(peerUrl), URL(peerUrl), URL(telemetryUrl), log = true) + val query = Query(client, admin, adminKeyPair) + query.findAllDomains() + .also { println("ALL DOMAINS: ${it.map { d -> d.id.asString() }}") } + + val sendTransaction = SendTransaction(client, admin, adminKeyPair) + + 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())) + .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()) + .also { println("ASSET DEFINITION $assetDefinition CREATED") } + + val madHatterAsset = "$assetDefinition$ASSET_ID_DELIMITER$madHatter" + sendTransaction.registerAsset(madHatterAsset, AssetValue.Quantity(100)) + .also { println("ASSET $madHatterAsset CREATED") } + + val whiteRabbit = "whiteRabbit_${System.currentTimeMillis()}$ACCOUNT_ID_DELIMITER$domain" + val whiteRabbitKeyPair = generateKeyPair() + sendTransaction.registerAccount(whiteRabbit, listOf(whiteRabbitKeyPair.public.toIrohaPublicKey())) + .also { println("ACCOUNT $whiteRabbit CREATED") } + + val whiteRabbitAsset = "$assetDefinition$ASSET_ID_DELIMITER$whiteRabbit" + sendTransaction.registerAsset(whiteRabbitAsset, AssetValue.Quantity(0)) + .also { println("ASSET $whiteRabbitAsset CREATED") } + + sendTransaction.transferAsset(madHatterAsset, 10, whiteRabbit, madHatter.asAccountId(), 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") } + + sendTransaction.burnAssets(madHatterAsset, 10, madHatter.asAccountId(), madHatterKeyPair) + .also { println("$madHatterAsset WAS BURN") } + + query.getAccountAmount(madHatter, madHatterAsset) + .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 new file mode 100644 index 000000000..83bcfb284 --- /dev/null +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Query.kt @@ -0,0 +1,46 @@ +package jp.co.soramitsu.iroha2 + +import jp.co.soramitsu.iroha2.generated.AccountId +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.query.QueryBuilder +import java.security.KeyPair + +open class Query( + private val client: AdminIroha2Client, + private val admin: AccountId, + private val keyPair: KeyPair, +) { + + suspend fun findAllDomains(queryFilter: GenericPredicateBox? = null) = QueryBuilder + .findAllDomains(queryFilter) + .account(admin) + .buildSigned(keyPair) + .let { client.sendQuery(it) } + + suspend fun findAllAccounts(queryFilter: GenericPredicateBox? = null) = QueryBuilder + .findAllAccounts(queryFilter) + .account(admin) + .buildSigned(keyPair) + .let { + client.sendQuery(it) + } + + 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 { + return QueryBuilder.findAccountById(accountId.asAccountId()) + .account(admin) + .buildSigned(keyPair) + .let { query -> + client.sendQuery(query).assets[assetId.asAssetId()]?.value + }.let { value -> + value?.cast()?.u32 + } ?: 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 new file mode 100644 index 000000000..b0bb414ef --- /dev/null +++ b/examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/SendTransaction.kt @@ -0,0 +1,114 @@ +package jp.co.soramitsu.iroha2 + +import jp.co.soramitsu.iroha2.generated.AccountId +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 + +class SendTransaction( + private val client: AdminIroha2Client, + private val admin: AccountId, + private val keyPair: KeyPair, + private val timeout: Long = 10000, +) { + + suspend fun registerDomain( + id: String, + metadata: Map = mapOf(), + admin: AccountId = this.admin, + keyPair: KeyPair = this.keyPair, + ) { + client.sendTransaction { + account(admin) + this.registerDomain(id.asDomainId(), metadata) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } + + suspend fun registerAccount( + id: String, + signatories: List, + metadata: Map = mapOf(), + admin: AccountId = this.admin, + keyPair: KeyPair = this.keyPair, + ) { + client.sendTransaction { + account(admin) + this.registerAccount(id.asAccountId(), signatories, Metadata(metadata)) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } + + suspend fun registerAssetDefinition( + id: String, + type: AssetValueType = AssetValueType.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) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } + + suspend fun registerAsset( + id: String, + value: AssetValue, + admin: AccountId = this.admin, + keyPair: KeyPair = this.keyPair, + ) { + client.sendTransaction { + account(admin) + this.registerAsset(id.asAssetId(), value) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } + + suspend fun transferAsset( + from: String, + value: Int, + to: String, + admin: AccountId = this.admin, + keyPair: KeyPair = this.keyPair, + ) { + client.sendTransaction { + account(admin) + this.transferAsset(from.asAssetId(), value, to.asAccountId()) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } + + suspend fun burnAssets( + assetId: String, + value: Int, + admin: AccountId = this.admin, + keyPair: KeyPair = this.keyPair, + ) { + client.sendTransaction { + account(admin) + this.burnAsset(assetId.asAssetId(), value) + buildSigned(keyPair) + }.also { + withTimeout(timeout) { it.await() } + } + } +} diff --git a/sample-app/README.md b/sample-app/README.md deleted file mode 100644 index 6ea3ed082..000000000 --- a/sample-app/README.md +++ /dev/null @@ -1,12 +0,0 @@ -## SAMPLE APPLICATION - -### Usage -You have to run app with some arguments in strict order - -Example: -1. http://127.0.0.1:8080 **(Peer URL)** -2. http://127.0.0.1:8180 **(Telemetry URL)** -3. bob **(Admin name)** -4. wonderland **(Domain name)** -5. 7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0 **(Public key)** -6. 9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e **(Private key)** diff --git a/sample-app/build.gradle.kts b/sample-app/build.gradle.kts deleted file mode 100644 index 8e7e8abad..000000000 --- a/sample-app/build.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - kotlin("jvm") version "1.8.22" - application -} - -group = "jp.co.soramitsu" -version = "1.0-SNAPSHOT" - -repositories { - mavenCentral() - maven(url = "https://jitpack.io") -} - -dependencies { - val iroha2Ver by System.getProperties() - - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.2") - - api("com.github.hyperledger.iroha-java:admin-client:$iroha2Ver") - implementation("com.github.hyperledger.iroha-java:model:$iroha2Ver") - implementation("com.github.hyperledger.iroha-java:block:$iroha2Ver") - - implementation("net.i2p.crypto:eddsa:0.3.0") - implementation("org.bouncycastle:bcprov-jdk15on:1.70") - implementation("com.github.multiformats:java-multihash:1.3.1") -} - -tasks.test { - useJUnitPlatform() -} - -tasks.withType { - kotlinOptions.jvmTarget = "11" -} - -application { - mainClass.set("MainKt") -} diff --git a/sample-app/docker/config/config.json b/sample-app/docker/config/config.json deleted file mode 100644 index 25320c9ce..000000000 --- a/sample-app/docker/config/config.json +++ /dev/null @@ -1,96 +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": 1000, - "TRUSTED_PEERS": null, - "COMMIT_TIME_LIMIT_MS": 2000, - "TX_RECEIPT_TIME_LIMIT_MS": 500, - "TRANSACTION_LIMITS": { - "max_instruction_number": 4096, - "max_wasm_size_bytes": 4194304 - }, - "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 - }, - "BLOCK_SYNC": { - "GOSSIP_PERIOD_MS": 10000, - "BLOCK_BATCH_SIZE": 4, - "ACTOR_CHANNEL_CAPACITY": 100 - }, - "QUEUE": { - "FUTURE_THRESHOLD_MS": 1000, - "MAXIMUM_TRANSACTIONS_IN_BLOCK": 512, - "MAXIMUM_TRANSACTIONS_IN_QUEUE": 65536, - "MAXIMUM_TRANSACTIONS_IN_SIGNATURE_BUFFER": 65536, - "TRANSACTION_TIME_TO_LIVE_MS": 86400000 - }, - "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, - "WAIT_FOR_PEERS_RETRY_COUNT_LIMIT": 100, - "WAIT_FOR_PEERS_RETRY_PERIOD_MS": 500, - "GENESIS_SUBMISSION_DELAY_MS": 1000 - }, - "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 - }, - "WASM_RUNTIME_CONFIG": { - "FUEL_LIMIT": 1000000, - "MAX_MEMORY": 524288000 - } - }, - "NETWORK": { - "ACTOR_CHANNEL_CAPACITY": 100 - }, - "TELEMETRY": { - "NAME": null, - "URL": null, - "MIN_RETRY_PERIOD": 1, - "MAX_RETRY_DELAY_EXPONENT": 4, - "FILE": null - } -} \ No newline at end of file diff --git a/sample-app/docker/config/genesis.json b/sample-app/docker/config/genesis.json deleted file mode 100644 index 8d756cb88..000000000 --- a/sample-app/docker/config/genesis.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "transactions": [ - { - "isi": [ - { - "Register": { - "NewDomain": { - "id": "wonderland", - "logo": null, - "metadata": {} - } - } - }, - { - "Register": { - "NewAccount": { - "id": "alice@wonderland", - "signatories": [ - "ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1" - ], - "metadata": {} - } - } - }, - { - "Register": { - "NewAccount": { - "id": "bob@wonderland", - "signatories": [ - "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" - ], - "metadata": {} - } - } - }, - { - "Register": { - "PermissionTokenDefinition": { - "id": "can_set_key_value_in_user_metadata", - "params": { - "account_id": "Id" - } - } - } - }, - { - "Grant": { - "PermissionToken": { - "definition_id": "can_set_key_value_in_user_metadata", - "params": { - "account_id": { - "AccountId": "alice@wonderland" - } - } - }, - "destination_id": { - "AccountId": "bob@wonderland" - } - } - }, - { - "Register": { - "PermissionTokenDefinition": { - "id": "can_register_domains", - "params": {} - } - } - }, - { - "Grant": { - "PermissionToken": { - "definition_id": "can_register_domains", - "params": {} - }, - "destination_id": { - "AccountId": "bob@wonderland" - } - } - } - ] - } - ] -} \ No newline at end of file diff --git a/sample-app/docker/docker-compose.yaml b/sample-app/docker/docker-compose.yaml deleted file mode 100644 index 27373aff2..000000000 --- a/sample-app/docker/docker-compose.yaml +++ /dev/null @@ -1,75 +0,0 @@ -version: "3.8" - -services: - iroha: - image: hyperledger/iroha2:stable@sha256:5356c8cd8b61ef7c16b18cf9d71808d66bca5fc78118256c5c2a1f92f7dd8fdf - 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}" - ports: - - "8080:8080" - - "8180:8180" - volumes: - - "./config:/config" - command: iroha --submit-genesis - - iroha1: - image: hyperledger/iroha2:stable@sha256:5356c8cd8b61ef7c16b18cf9d71808d66bca5fc78118256c5c2a1f92f7dd8fdf - 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}" - ports: - - "8081:8080" - - "8181:8180" - volumes: - - "./config:/config" - - iroha2: - image: hyperledger/iroha2:stable@sha256:5356c8cd8b61ef7c16b18cf9d71808d66bca5fc78118256c5c2a1f92f7dd8fdf - 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}" - ports: - - "8082:8080" - - "8182:8180" - volumes: - - "./config:/config" - - iroha3: - image: hyperledger/iroha2:stable@sha256:5356c8cd8b61ef7c16b18cf9d71808d66bca5fc78118256c5c2a1f92f7dd8fdf - 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}" - ports: - - "8083:8080" - - "8183:8180" - volumes: - - "./config:/config" diff --git a/sample-app/gradle.properties b/sample-app/gradle.properties deleted file mode 100644 index 95168e59d..000000000 --- a/sample-app/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -kotlin.code.style=official -systemProp.iroha2Ver=1483efbdad diff --git a/sample-app/gradle/wrapper/gradle-wrapper.jar b/sample-app/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2..000000000 Binary files a/sample-app/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/sample-app/gradle/wrapper/gradle-wrapper.properties b/sample-app/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 60c76b340..000000000 --- a/sample-app/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file diff --git a/sample-app/gradlew b/sample-app/gradlew deleted file mode 100755 index 1b6c78733..000000000 --- a/sample-app/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/sample-app/gradlew.bat b/sample-app/gradlew.bat deleted file mode 100644 index 107acd32c..000000000 --- a/sample-app/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/sample-app/settings.gradle.kts b/sample-app/settings.gradle.kts deleted file mode 100644 index eb1e80851..000000000 --- a/sample-app/settings.gradle.kts +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = "sample-app" diff --git a/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Helper.kt b/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Helper.kt deleted file mode 100644 index ece3ac259..000000000 --- a/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Helper.kt +++ /dev/null @@ -1,241 +0,0 @@ -package jp.co.soramitsu.sample - -import jp.co.soramitsu.iroha2.AdminIroha2Client -import jp.co.soramitsu.iroha2.IdKey -import jp.co.soramitsu.iroha2.Permissions -import jp.co.soramitsu.iroha2.asAccountId -import jp.co.soramitsu.iroha2.asAssetDefinitionId -import jp.co.soramitsu.iroha2.asAssetId -import jp.co.soramitsu.iroha2.asDomainId -import jp.co.soramitsu.iroha2.cast -import jp.co.soramitsu.iroha2.generated.crypto.PublicKey -import jp.co.soramitsu.iroha2.generated.datamodel.Value -import jp.co.soramitsu.iroha2.generated.datamodel.account.AccountId -import jp.co.soramitsu.iroha2.generated.datamodel.asset.AssetValue -import jp.co.soramitsu.iroha2.generated.datamodel.asset.AssetValueType -import jp.co.soramitsu.iroha2.generated.datamodel.asset.Mintable -import jp.co.soramitsu.iroha2.generated.datamodel.metadata.Metadata -import jp.co.soramitsu.iroha2.generated.datamodel.name.Name -import jp.co.soramitsu.iroha2.generated.datamodel.predicate.GenericValuePredicateBox -import jp.co.soramitsu.iroha2.generated.datamodel.predicate.value.ValuePredicate -import jp.co.soramitsu.iroha2.query.QueryBuilder -import kotlinx.coroutines.withTimeout -import java.net.URL -import java.security.KeyPair - -class Helper( - peerUrl: String, - telemetryUrl: String, - private val admin: AccountId, - private val keyPair: KeyPair, - private val timeout: Long = 10000, -) { - - private val client = AdminIroha2Client(URL(peerUrl), URL(telemetryUrl), log = true) - - suspend fun registerDomain( - id: String, - metadata: Map = mapOf(), - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - this.registerDomain(id.asDomainId(), metadata) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun registerAccount( - id: String, - signatories: List, - metadata: Map = mapOf(), - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - this.registerAccount(id.asAccountId(), signatories, Metadata(metadata)) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun registerAssetDefinition( - id: String, - type: AssetValueType = AssetValueType.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) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun registerAsset( - id: String, - value: AssetValue, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - this.registerAsset(id.asAssetId(), value) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun transferAsset( - from: String, - value: Int, - to: String, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - this.transferAsset(from.asAssetId(), value, to.asAssetId()) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun unregisterDomain( - id: String, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - unregisterDomain(id.asDomainId()) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun unregisterAccount( - id: String, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - unregisterAccount(id.asAccountId()) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun unregisterAsset( - id: String, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - unregisterAsset(id.asAssetId()) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun grantBurnAssets( - assetId: String, - target: AccountId, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - registerPermissionToken(Permissions.CanBurnUserAssetsToken.type, IdKey.AssetId) - grantBurnAssets(assetId.asAssetId(), target) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun grantTransferUserAsset( - assetId: String, - target: AccountId, - admin: AccountId = this.admin, - keyPair: KeyPair = this.keyPair, - ) { - client.sendTransaction { - account(admin) - registerPermissionToken(Permissions.CanTransferUserAssetsToken.type, IdKey.AssetId) - grantTransferUserAsset(assetId.asAssetId(), target) - buildSigned(keyPair) - }.also { - withTimeout(timeout) { it.await() } - } - } - - suspend fun getAccountAmount(accountId: String, assetId: String): Long { - return QueryBuilder.findAccountById(accountId.asAccountId()) - .account(admin) - .buildSigned(keyPair) - .let { query -> - client.sendQuery(query).assets[assetId.asAssetId()]?.value - }.let { value -> - value?.cast()?.u32 - } ?: throw RuntimeException("NOT FOUND") - } - - suspend fun findAllDomains(queryFilter: GenericValuePredicateBox? = null) = QueryBuilder - .findAllDomains(queryFilter) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findAllAccounts(queryFilter: GenericValuePredicateBox? = null) = QueryBuilder - .findAllAccounts(queryFilter) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findAllAssets(queryFilter: GenericValuePredicateBox? = null) = QueryBuilder - .findAllAssets(queryFilter) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findDomainById(id: String) = QueryBuilder - .findDomainById(id.asDomainId()) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findAccountById(id: String) = QueryBuilder - .findAccountById(id.asAccountId()) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findAssetById(id: String) = QueryBuilder - .findAssetById(id.asAssetId()) - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } - - suspend fun findAllTransactions() = QueryBuilder - .findAllTransactions() - .account(admin) - .buildSigned(keyPair) - .let { client.sendQuery(it) } -} diff --git a/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Main.kt b/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Main.kt deleted file mode 100644 index 7f103b36c..000000000 --- a/sample-app/src/main/kotlin/jp/co/soramitsu/sample/Main.kt +++ /dev/null @@ -1,73 +0,0 @@ -package jp.co.soramitsu.sample - -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.asDomainId -import jp.co.soramitsu.iroha2.asName -import jp.co.soramitsu.iroha2.asString -import jp.co.soramitsu.iroha2.generateKeyPair -import jp.co.soramitsu.iroha2.generated.datamodel.account.AccountId -import jp.co.soramitsu.iroha2.generated.datamodel.asset.AssetValue -import jp.co.soramitsu.iroha2.generated.datamodel.asset.AssetValueType -import jp.co.soramitsu.iroha2.keyPairFromHex -import jp.co.soramitsu.iroha2.toIrohaPublicKey -import kotlinx.coroutines.runBlocking - -fun main(args: Array): Unit = runBlocking { - val peerUrl = args[0] - val telemetryUrl = args[1] - val admin = AccountId(args[2].asName(), args[3].asDomainId()) // transactions send behalf of this account - val adminKeyPair = keyPairFromHex(args[4], args[5]) - - val helper = Helper(peerUrl, telemetryUrl, admin, adminKeyPair) - - val domain = "domain_${System.currentTimeMillis()}" - helper.registerDomain(domain).also { println("DOMAIN $domain CREATED") } - - val assetDefinition = "asset_${System.currentTimeMillis()}$ASSET_ID_DELIMITER$domain" - helper.registerAssetDefinition(assetDefinition, AssetValueType.Quantity()) - .also { println("ASSET DEFINITION $assetDefinition CREATED") } - - val joe = "joe_${System.currentTimeMillis()}$ACCOUNT_ID_DELIMITER$domain" - val joeKeyPair = generateKeyPair() - helper.registerAccount(joe, listOf(joeKeyPair.public.toIrohaPublicKey())) - .also { println("ACCOUNT $joe CREATED") } - - val joeAsset = "$assetDefinition$ASSET_ID_DELIMITER$joe" - helper.registerAsset(joeAsset, AssetValue.Quantity(100)) - .also { println("ASSET $joeAsset CREATED") } - - helper.findAllDomains() - .also { println("ALL DOMAINS: ${it.map { d -> d.id.asString() }}") } - helper.findAllAccounts() - .also { println("ALL ACCOUNTS: ${it.map { a -> a.id.asString() }}") } - helper.findAllAssets() - .also { println("ALL ASSETS: ${it.map { a -> a.id.asString() }}") } - - helper.findDomainById(domain).also { println("DOMAIN $domain exists") } - helper.findAccountById(joe).also { println("ACCOUNT $joe exists") } - helper.findAssetById(joeAsset).also { println("ASSET $joeAsset exists") } - - val carl = "carl_${System.currentTimeMillis()}$ACCOUNT_ID_DELIMITER$domain" - helper.registerAccount(carl, listOf()) - .also { println("ACCOUNT $carl CREATED") } - - val carlAsset = "$assetDefinition$ASSET_ID_DELIMITER$carl" - helper.registerAsset(carlAsset, AssetValue.Quantity(0)) - .also { println("ASSET $carlAsset CREATED") } - - helper.transferAsset(joeAsset, 10, carlAsset, joe.asAccountId(), joeKeyPair) - .also { println("$joe TRANSFERRED FROM $joeAsset TO $carlAsset: 10") } - helper.getAccountAmount(joe, joeAsset).also { println("$joeAsset BALANCE: $it") } - helper.getAccountAmount(carl, carlAsset).also { println("$carlAsset BALANCE: $it") } - - helper.grantTransferUserAsset(joeAsset, admin, joe.asAccountId(), joeKeyPair) - helper.transferAsset(joeAsset, 10, carlAsset, admin, adminKeyPair) - .also { println("${admin.asString()} TRANSFERRED FROM $joeAsset TO $carlAsset: 10") } - - helper.grantBurnAssets(joeAsset, admin, joe.asAccountId(), joeKeyPair) - helper.unregisterAsset(joeAsset).also { println("ASSET $joeAsset UNREGISTERED") } - helper.unregisterAccount(joe).also { println("ACCOUNT $joe UNREGISTERED") } - helper.unregisterDomain(domain).also { println("DOMAIN $domain UNREGISTERED") } -} diff --git a/settings.gradle b/settings.gradle index 99732642e..7e426fb2b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -21,3 +21,6 @@ project(':admin-client').projectDir = 'modules/admin-client' as File include 'test-tools' project(':test-tools').projectDir = 'modules/test-tools' as File + +include 'tutorial' +project(':tutorial').projectDir = 'examples/tutorial' as File