diff --git a/Cargo.lock b/Cargo.lock index 4d5783af..805dab66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,21 +441,6 @@ dependencies = [ "generic-array 0.14.6", ] -[[package]] -name = "color-eyre" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f1885697ee8a177096d42f158922251a41973117f6d8a234cee94b9509157b7" -dependencies = [ - "backtrace", - "color-spantrace 0.1.6", - "eyre", - "indenter", - "once_cell", - "owo-colors 1.3.0", - "tracing-error 0.1.2", -] - [[package]] name = "color-eyre" version = "0.6.2" @@ -463,24 +448,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" dependencies = [ "backtrace", - "color-spantrace 0.2.0", + "color-spantrace", "eyre", "indenter", "once_cell", - "owo-colors 3.5.0", - "tracing-error 0.2.0", -] - -[[package]] -name = "color-spantrace" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6eee477a4a8a72f4addd4de416eb56d54bc307b284d6601bafdee1f4ea462d1" -dependencies = [ - "once_cell", - "owo-colors 1.3.0", - "tracing-core", - "tracing-error 0.1.2", + "owo-colors", + "tracing-error", ] [[package]] @@ -490,9 +463,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" dependencies = [ "once_cell", - "owo-colors 3.5.0", + "owo-colors", "tracing-core", - "tracing-error 0.2.0", + "tracing-error", ] [[package]] @@ -793,6 +766,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "dashmap" version = "5.4.0" @@ -954,6 +962,17 @@ dependencies = [ "syn", ] +[[package]] +name = "enum-kinds" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e40a16955681d469ab3da85aaa6b42ff656b3c67b52e1d8d3dd36afe97fd462" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.9.1" @@ -1055,11 +1074,17 @@ dependencies = [ "log", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fixnum" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7bb4d4380b82ea92dfa6df95e4dae07879d404e0e25aa44040744fe601221df" +checksum = "44b2a966c379dfa6584275025608c73116b3b41cd91715c48bf8087ae035587f" dependencies = [ "derive_more", "itoa", @@ -1205,13 +1230,14 @@ dependencies = [ name = "generate" version = "0.1.0" dependencies = [ - "color-eyre 0.5.11", + "color-eyre", "either", "iroha_data_model", "iroha_schema", "iroha_schema_gen", "serde_json", "syn", + "topological-sort", ] [[package]] @@ -1515,6 +1541,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.3.0" @@ -1592,8 +1624,8 @@ checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" [[package]] name = "iroha_actor" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "async-trait", "dashmap", @@ -1609,8 +1641,8 @@ dependencies = [ [[package]] name = "iroha_actor_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1620,14 +1652,14 @@ dependencies = [ [[package]] name = "iroha_client" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "attohttpc", "base64", - "crossbeam", "derive_more", "eyre", + "futures-util", "http", "iroha_config", "iroha_core", @@ -1642,13 +1674,15 @@ dependencies = [ "serde", "serde_json", "thiserror", + "tokio", + "tokio-tungstenite 0.16.1", "tungstenite 0.16.0", ] [[package]] name = "iroha_config" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "crossbeam", "derive_more", @@ -1661,17 +1695,16 @@ dependencies = [ "serde_json", "thiserror", "tracing", - "tracing-subscriber 0.3.15", + "tracing-subscriber", "url", ] [[package]] name = "iroha_config_base" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "crossbeam", - "derive_more", "iroha_config_derive", "serde", "serde_json", @@ -1680,8 +1713,8 @@ dependencies = [ [[package]] name = "iroha_config_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1691,11 +1724,10 @@ dependencies = [ [[package]] name = "iroha_core" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "anyhow", - "async-stream", "async-trait", "crossbeam-queue", "dashmap", @@ -1715,21 +1747,22 @@ dependencies = [ "iroha_schema", "iroha_telemetry", "iroha_version", + "itertools", "parity-scale-codec", - "pin-project", + "parking_lot", "rand 0.8.5", "serde", "serde_json", + "tempfile", "thiserror", "tokio", - "tokio-stream", "wasmtime", ] [[package]] name = "iroha_crypto" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "derive_more", "getset", @@ -1744,12 +1777,13 @@ dependencies = [ [[package]] name = "iroha_data_model" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "base64", "dashmap", "derive_more", + "enum-kinds", "getset", "iroha_crypto", "iroha_data_model_derive", @@ -1761,6 +1795,7 @@ dependencies = [ "parity-scale-codec", "serde", "serde_json", + "serde_with", "strum", "thiserror", "tokio", @@ -1769,9 +1804,10 @@ dependencies = [ [[package]] name = "iroha_data_model_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ + "proc-macro-error", "proc-macro2", "quote", "syn", @@ -1779,8 +1815,8 @@ dependencies = [ [[package]] name = "iroha_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro2", "quote", @@ -1789,16 +1825,16 @@ dependencies = [ [[package]] name = "iroha_ffi" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "iroha_ffi_derive", ] [[package]] name = "iroha_ffi_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "derive_more", "proc-macro-error", @@ -1809,9 +1845,10 @@ dependencies = [ [[package]] name = "iroha_futures" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ + "iroha_config", "iroha_futures_derive", "iroha_logger", "rand 0.8.5", @@ -1822,8 +1859,8 @@ dependencies = [ [[package]] name = "iroha_futures_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1833,35 +1870,34 @@ dependencies = [ [[package]] name = "iroha_logger" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ - "color-eyre 0.6.2", + "color-eyre", "derive_more", "iroha_config", "once_cell", - "serde", "serde_json", "tokio", "tracing", "tracing-bunyan-formatter", "tracing-core", "tracing-futures", - "tracing-subscriber 0.3.15", + "tracing-subscriber", ] [[package]] name = "iroha_macro" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "iroha_derive", ] [[package]] name = "iroha_p2p" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "aead", "async-stream", @@ -1869,11 +1905,11 @@ dependencies = [ "derive_more", "futures", "iroha_actor", + "iroha_config_base", "iroha_crypto", "iroha_data_model", "iroha_data_model_derive", "iroha_logger", - "iroha_macro", "parity-scale-codec", "rand 0.8.5", "thiserror", @@ -1882,11 +1918,12 @@ dependencies = [ [[package]] name = "iroha_primitives" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "derive_more", "fixnum", + "iroha_ffi", "iroha_macro", "iroha_schema", "parity-scale-codec", @@ -1900,8 +1937,9 @@ dependencies = [ name = "iroha_python" version = "0.1.0" dependencies = [ - "color-eyre 0.6.2", + "color-eyre", "iroha_client", + "iroha_config", "iroha_crypto", "iroha_data_model", "iroha_version", @@ -1914,8 +1952,8 @@ dependencies = [ [[package]] name = "iroha_schema" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "fixnum", "iroha_schema_derive", @@ -1924,8 +1962,8 @@ dependencies = [ [[package]] name = "iroha_schema_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro2", "quote", @@ -1934,8 +1972,8 @@ dependencies = [ [[package]] name = "iroha_schema_gen" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "iroha_core", "iroha_crypto", @@ -1945,8 +1983,8 @@ dependencies = [ [[package]] name = "iroha_telemetry" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "anyhow", "async-trait", @@ -1963,15 +2001,15 @@ dependencies = [ "streaming-stats", "tokio", "tokio-stream", - "tokio-tungstenite", + "tokio-tungstenite 0.17.2", "url", "vergen", ] [[package]] name = "iroha_telemetry_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -1981,8 +2019,8 @@ dependencies = [ [[package]] name = "iroha_version" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "iroha_macro", "iroha_schema", @@ -1996,8 +2034,8 @@ dependencies = [ [[package]] name = "iroha_version_derive" -version = "2.0.0-pre-rc.8" -source = "git+https://github.com/hyperledger/iroha?branch=iroha2-stable#4936869dda441d814b50c09a8995e62640ad4fa5" +version = "2.0.0-pre-rc.9" +source = "git+https://github.com/hyperledger/iroha?branch=iroha2-dev#f08fa3c1ba447a42e2059560daea7cb749ebced1" dependencies = [ "proc-macro-error", "proc-macro2", @@ -2354,12 +2392,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "owo-colors" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55" - [[package]] name = "owo-colors" version = "3.5.0" @@ -2408,10 +2440,13 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ + "backtrace", "cfg-if", "libc", + "petgraph", "redox_syscall", "smallvec", + "thread-id", "windows-sys", ] @@ -2427,6 +2462,16 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -3083,6 +3128,28 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -3249,6 +3316,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.24.1" @@ -3364,6 +3437,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thread-id" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fdfe0627923f7411a43ec9ec9c39c3a9b4151be313e0922042581fb6c9b717f" +dependencies = [ + "libc", + "redox_syscall", + "winapi", +] + [[package]] name = "thread_local" version = "1.1.4" @@ -3439,6 +3523,16 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.10" @@ -3450,6 +3544,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e80b39df6afcc12cdf752398ade96a6b9e99c903dfdc36e53ad10b9c366bca72" +dependencies = [ + "futures-util", + "log", + "native-tls", + "tokio", + "tokio-native-tls", + "tungstenite 0.16.0", +] + [[package]] name = "tokio-tungstenite" version = "0.17.2" @@ -3485,6 +3593,12 @@ dependencies = [ "serde", ] +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "tower-service" version = "0.3.2" @@ -3529,7 +3643,7 @@ dependencies = [ "tracing", "tracing-core", "tracing-log", - "tracing-subscriber 0.3.15", + "tracing-subscriber", ] [[package]] @@ -3542,16 +3656,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-error" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24" -dependencies = [ - "tracing", - "tracing-subscriber 0.2.25", -] - [[package]] name = "tracing-error" version = "0.2.0" @@ -3559,7 +3663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" dependencies = [ "tracing", - "tracing-subscriber 0.3.15", + "tracing-subscriber", ] [[package]] @@ -3583,17 +3687,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-subscriber" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" -dependencies = [ - "sharded-slab", - "thread_local", - "tracing-core", -] - [[package]] name = "tracing-subscriber" version = "0.3.15" diff --git a/Cargo.toml b/Cargo.toml index 54887216..159401ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,14 +14,15 @@ name = "iroha2" crate-type = ["cdylib"] [dependencies] -iroha_client = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } -iroha_crypto = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } -iroha_data_model = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } -iroha_version = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } +iroha_client = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_config = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_crypto = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_data_model = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_version = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } color-eyre = "0.6" parity-scale-codec = "3.1" -pyo3 = { version = "0.16.4", features = ["extension-module", "multiple-pymethods"] } +pyo3 = { version = "0.16.6", features = ["extension-module", "multiple-pymethods"] } pythonize = "0.16.0" serde = "1" serde_json = "1" diff --git a/example/config.json b/example/config.json index 4f8f2d19..426f229a 100644 --- a/example/config.json +++ b/example/config.json @@ -1,19 +1,21 @@ { - "TORII_API_URL": "http://iroha0:8080", - "ACCOUNT_ID": { - "name": "alice", - "domain_id": { - "name": "wonderland" - } + "PUBLIC_KEY": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", + "PRIVATE_KEY": { + "digest_function": "ed25519", + "payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" }, + "ACCOUNT_ID": "alice@wonderland", "BASIC_AUTH": { "web_login": "mad_hatter", "password": "ilovetea" }, - "PUBLIC_KEY": "ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0", - "PRIVATE_KEY": { - "digest_function": "ed25519", - "payload": "9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0" + "TORII_API_URL": "http://127.0.0.1:8080", + "TORII_TELEMETRY_URL": "http://127.0.0.1:8180", + "TRANSACTION_TIME_TO_LIVE_MS": 100000, + "TRANSACTION_STATUS_TIMEOUT_MS": 15000, + "TRANSACTION_LIMITS": { + "max_instruction_number": 4096, + "max_wasm_size_bytes": 4194304 }, - "LOGGER_CONFIGURATION": {} + "ADD_TRANSACTION_NONCE": false } diff --git a/example/test.py b/example/test.py index dff63c1a..29a389a9 100644 --- a/example/test.py +++ b/example/test.py @@ -7,12 +7,12 @@ from iroha2.data_model.domain import Domain from iroha2.data_model.account import Account from iroha2.data_model import asset, account -from iroha2.data_model.events import FilterBox, pipeline +from iroha2.data_model.events import FilterBox, pipeline, Event from iroha2.crypto import KeyPair def wait_for_tx(cl: Client, hash: str): - filter = FilterBox.Pipeline( + filter = FilterBox( pipeline.EventFilter( entity_kind=pipeline.EntityKind.Transaction(), status_kind=None, @@ -22,14 +22,13 @@ def wait_for_tx(cl: Client, hash: str): listener = cl.listen(filter) for event in listener: - if event.variant is event.Type.Pipeline: - if event.value.hash == hash: - if event.value.status.variant is pipeline.Status.Type.Committed: - return - elif event.value.status.variant is pipeline.Status.Type.Validating: - pass - else: - raise RuntimeError(f"Tx rejected: {event.value.status}") + if isinstance(event, Event.Pipeline) and event.hash == hash: + if isinstance(event.status, pipeline.Status.Committed): + return + elif isinstance(event.status, pipeline.Status.Validating): + pass + else: + raise RuntimeError(f"Tx rejected: {event.value.status}") cfg = json.loads(open("./config.json").read()) diff --git a/generate/Cargo.toml b/generate/Cargo.toml index f7d63846..8d840d88 100644 --- a/generate/Cargo.toml +++ b/generate/Cargo.toml @@ -9,11 +9,12 @@ license-file = "../../LICENSE" typing = [] [dependencies] -iroha_schema = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } -iroha_schema_gen = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } -iroha_data_model = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-stable" } +iroha_schema = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_schema_gen = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } +iroha_data_model = { git = "https://github.com/hyperledger/iroha", branch = "iroha2-dev" } -color-eyre = "0.5" +color-eyre = "0.6.2" serde_json = "1" either = "1.6" syn = { version = "1", features = ["full"] } +topological-sort = "0.2.2" diff --git a/generate/src/as_py.rs b/generate/src/as_py.rs index 4ebf904b..93e2afc7 100644 --- a/generate/src/as_py.rs +++ b/generate/src/as_py.rs @@ -246,13 +246,23 @@ impl fmt::Display for UnnamedStructClass { impl fmt::Display for EnumClass { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let typespec = self + .variants + .iter() + .map(|(_, pytype)| format!("get_class({pytype})")) + .collect::>() + .join(", "); let variants = self .variants .iter() - .map(|(name, ty)| format!("(\"{}\", {})", name, ty)) + .map(|(name, pytype)| format!("(\"{name}\", get_class({pytype}))")) .collect::>() .join(", "); - write!(f, "{} = Enum[{}] ", self.name, variants) + writeln!( + f, + "{} = make_enum(\"{}\", [{variants}], typing.Union[{typespec}])", + self.name, self.name + ) } } diff --git a/generate/src/module.rs b/generate/src/module.rs index 8aec1086..d955d1b9 100644 --- a/generate/src/module.rs +++ b/generate/src/module.rs @@ -99,7 +99,10 @@ impl Module { } writeln!( f, - "from .{}rust import Enum, make_struct, make_tuple, Dict", + r#" +from .{}rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + "#, ".".repeat(r#in.mods.len()) )?; @@ -108,6 +111,8 @@ impl Module { Self::write_meta(&mut f, name.clone(), ty.clone()) .wrap_err_with(|| eyre!("Failed to write metadata for type {}", name))?; } + + writeln!(f, "SelfResolvingTypeVar.resolve_all()")?; drop(f); for (name, either_module) in modules { diff --git a/iroha2/__init__.py b/iroha2/__init__.py index 0009bba3..0dda3fcc 100644 --- a/iroha2/__init__.py +++ b/iroha2/__init__.py @@ -22,7 +22,7 @@ def submit_tx(self, tx: list): return self.cl.submit_all_with_metadata(tx, {}) def submit_isi(self, isi): - return self.submit_tx([_Instruction(isi)]) + return self.submit_tx([]) def submit_tx_blocking(self, tx: list): tx = [i.to_rust() for i in tx] diff --git a/iroha2/data_model/domain/__init__.py b/iroha2/data_model/domain/__init__.py index 443b07f8..a1ca8db1 100644 --- a/iroha2/data_model/domain/__init__.py +++ b/iroha2/data_model/domain/__init__.py @@ -20,7 +20,8 @@ def __init__(self, id: Union[Id, str], logo: Optional[str] = None): logo=logo, accounts={}, asset_definitions={}, - metadata={}) + metadata={}, + asset_total_quantities={}) def registrable(self): return _NewDomain(id=self.id, logo=self.logo, metadata={}) diff --git a/iroha2/sys/AtomicU32Wrapper/__init__.py b/iroha2/sys/AtomicU32Wrapper/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/AtomicU32Wrapper/__init__.py +++ b/iroha2/sys/AtomicU32Wrapper/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/Compact/__init__.py b/iroha2/sys/Compact/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/Compact/__init__.py +++ b/iroha2/sys/Compact/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/Duration/__init__.py b/iroha2/sys/Duration/__init__.py index 9553c697..1c2f5af6 100644 --- a/iroha2/sys/Duration/__init__.py +++ b/iroha2/sys/Duration/__init__.py @@ -1,2 +1,6 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Duration = make_tuple("Duration", [int, int]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/FixedPoint/__init__.py b/iroha2/sys/FixedPoint/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/FixedPoint/__init__.py +++ b/iroha2/sys/FixedPoint/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/Map/__init__.py b/iroha2/sys/Map/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/Map/__init__.py +++ b/iroha2/sys/Map/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/Option/__init__.py b/iroha2/sys/Option/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/Option/__init__.py +++ b/iroha2/sys/Option/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/String/__init__.py b/iroha2/sys/String/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/String/__init__.py +++ b/iroha2/sys/String/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/Vec/__init__.py b/iroha2/sys/Vec/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/Vec/__init__.py +++ b/iroha2/sys/Vec/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/__init__.py b/iroha2/sys/__init__.py index ecd53729..53ec2b81 100644 --- a/iroha2/sys/__init__.py +++ b/iroha2/sys/__init__.py @@ -1,2 +1,6 @@ from ..iroha2 import * -from .rust import Enum, make_struct, make_tuple, Dict + +from .rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/bool/__init__.py b/iroha2/sys/bool/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/bool/__init__.py +++ b/iroha2/sys/bool/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/i64/__init__.py b/iroha2/sys/i64/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/i64/__init__.py +++ b/iroha2/sys/i64/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/__init__.py b/iroha2/sys/iroha_core/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/iroha_core/__init__.py +++ b/iroha2/sys/iroha_core/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/block/__init__.py b/iroha2/sys/iroha_core/block/__init__.py index fd944a52..f56acca6 100644 --- a/iroha2/sys/iroha_core/block/__init__.py +++ b/iroha2/sys/iroha_core/block/__init__.py @@ -1,9 +1,15 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -BlockHeader = make_struct("BlockHeader", [("timestamp", int), ("consensus_estimation", int), ("height", int), ("previous_block_hash", "iroha_crypto.hash.HashOf"), ("transactions_hash", "iroha_crypto.hash.HashOf"), ("rejected_transactions_hash", "iroha_crypto.hash.HashOf"), ("view_change_proofs", "iroha_core.sumeragi.view_change.ProofChain"), ("invalidated_blocks_hashes", list), ("genesis_topology", "iroha_core.sumeragi.network_topology.Topology")]) + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +BlockHeader = make_struct("BlockHeader", [("timestamp", int), ("consensus_estimation", int), ("height", int), ("view_change_index", int), ("previous_block_hash", "iroha_crypto.hash.HashOf"), ("transactions_hash", "iroha_crypto.hash.HashOf"), ("rejected_transactions_hash", "iroha_crypto.hash.HashOf"), ("genesis_topology", "iroha_core.sumeragi.network_topology.Topology")]) + +CandidateBlock = make_struct("CandidateBlock", [("header", "iroha_core.block.BlockHeader"), ("rejected_transactions", list), ("transactions", list), ("signatures", "iroha_crypto.signature.SignaturesOf"), ("event_recommendations", list)]) CommittedBlock = make_struct("CommittedBlock", [("header", "iroha_core.block.BlockHeader"), ("rejected_transactions", list), ("transactions", list), ("event_recommendations", list), ("signatures", "iroha_crypto.signature.SignaturesOf")]) -ValidBlock = make_struct("ValidBlock", [("header", "iroha_core.block.BlockHeader"), ("rejected_transactions", list), ("transactions", list), ("signatures", list), ("event_recommendations", list)]) +VersionedCandidateBlock = make_enum("VersionedCandidateBlock", [("V1", get_class("iroha_core.block.CandidateBlock"))], typing.Union[get_class("iroha_core.block.CandidateBlock")]) + +VersionedCommittedBlock = make_enum("VersionedCommittedBlock", [("V1", get_class("iroha_core.block.CommittedBlock"))], typing.Union[get_class("iroha_core.block.CommittedBlock")]) -VersionedCommittedBlock = Enum[("V1", "iroha_core.block.CommittedBlock")] -VersionedValidBlock = Enum[("V1", "iroha_core.block.ValidBlock")] +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/block/stream/__init__.py b/iroha2/sys/iroha_core/block/stream/__init__.py index d4067266..09c694aa 100644 --- a/iroha2/sys/iroha_core/block/stream/__init__.py +++ b/iroha2/sys/iroha_core/block/stream/__init__.py @@ -1,5 +1,11 @@ -from ....rust import Enum, make_struct, make_tuple, Dict -BlockPublisherMessage = Enum[("SubscriptionAccepted", type(None)), ("Block", "iroha_core.block.VersionedCommittedBlock")] -BlockSubscriberMessage = Enum[("SubscriptionRequest", int), ("BlockReceived", type(None))] -VersionedBlockPublisherMessage = Enum[("V1", "iroha_core.block.stream.BlockPublisherMessage")] -VersionedBlockSubscriberMessage = Enum[("V1", "iroha_core.block.stream.BlockSubscriberMessage")] + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +BlockMessage = make_tuple("BlockMessage", ["iroha_core.block.VersionedCommittedBlock"]) +BlockSubscriptionRequest = make_tuple("BlockSubscriptionRequest", [int]) +VersionedBlockMessage = make_enum("VersionedBlockMessage", [("V1", get_class("iroha_core.block.stream.BlockMessage"))], typing.Union[get_class("iroha_core.block.stream.BlockMessage")]) + +VersionedBlockSubscriptionRequest = make_enum("VersionedBlockSubscriptionRequest", [("V1", get_class("iroha_core.block.stream.BlockSubscriptionRequest"))], typing.Union[get_class("iroha_core.block.stream.BlockSubscriptionRequest")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/genesis/__init__.py b/iroha2/sys/iroha_core/genesis/__init__.py index af125552..b3dcface 100644 --- a/iroha2/sys/iroha_core/genesis/__init__.py +++ b/iroha2/sys/iroha_core/genesis/__init__.py @@ -1,5 +1,9 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + GenesisTransaction = make_struct("GenesisTransaction", [("isi", list)]) RawGenesisBlock = make_struct("RawGenesisBlock", [("transactions", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/smartcontracts/__init__.py b/iroha2/sys/iroha_core/smartcontracts/__init__.py index b22ba35d..484bd865 100644 --- a/iroha2/sys/iroha_core/smartcontracts/__init__.py +++ b/iroha2/sys/iroha_core/smartcontracts/__init__.py @@ -1 +1,5 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/smartcontracts/isi/__init__.py b/iroha2/sys/iroha_core/smartcontracts/isi/__init__.py index ef324d17..71581dcd 100644 --- a/iroha2/sys/iroha_core/smartcontracts/isi/__init__.py +++ b/iroha2/sys/iroha_core/smartcontracts/isi/__init__.py @@ -1 +1,5 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/smartcontracts/isi/error/__init__.py b/iroha2/sys/iroha_core/smartcontracts/isi/error/__init__.py index 8e6ab22a..e0a0be93 100644 --- a/iroha2/sys/iroha_core/smartcontracts/isi/error/__init__.py +++ b/iroha2/sys/iroha_core/smartcontracts/isi/error/__init__.py @@ -1,2 +1,7 @@ -from .....rust import Enum, make_struct, make_tuple, Dict -FindError = Enum[("Asset", "iroha_data_model.asset.Id"), ("AssetDefinition", "iroha_data_model.asset.DefinitionId"), ("Account", "iroha_data_model.account.Id"), ("Domain", "iroha_data_model.domain.Id"), ("MetadataKey", "iroha_data_model.name.Name"), ("Block", "iroha_crypto.hash.HashOf"), ("Transaction", "iroha_crypto.hash.HashOf"), ("Context", str), ("Peer", "iroha_data_model.peer.Id"), ("Trigger", "iroha_data_model.trigger.Id"), ("Role", "iroha_data_model.role.Id"), ("PermissionTokenDefinition", "iroha_data_model.permissions.Id")] + +from .....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +FindError = make_enum("FindError", [("Asset", get_class("iroha_data_model.asset.Id")), ("AssetDefinition", get_class("iroha_data_model.asset.DefinitionId")), ("Account", get_class("iroha_data_model.account.Id")), ("Domain", get_class("iroha_data_model.domain.Id")), ("MetadataKey", get_class("iroha_data_model.name.Name")), ("Block", get_class("iroha_crypto.hash.HashOf")), ("Transaction", get_class("iroha_crypto.hash.HashOf")), ("Context", get_class(str)), ("Peer", get_class("iroha_data_model.peer.Id")), ("Trigger", get_class("iroha_data_model.trigger.Id")), ("Role", get_class("iroha_data_model.role.Id")), ("PermissionTokenDefinition", get_class("iroha_data_model.permission.token.Id")), ("Validator", get_class("iroha_data_model.permission.validator.Id"))], typing.Union[get_class("iroha_data_model.asset.Id"), get_class("iroha_data_model.asset.DefinitionId"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.domain.Id"), get_class("iroha_data_model.name.Name"), get_class("iroha_crypto.hash.HashOf"), get_class("iroha_crypto.hash.HashOf"), get_class(str), get_class("iroha_data_model.peer.Id"), get_class("iroha_data_model.trigger.Id"), get_class("iroha_data_model.role.Id"), get_class("iroha_data_model.permission.token.Id"), get_class("iroha_data_model.permission.validator.Id")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/smartcontracts/isi/query/__init__.py b/iroha2/sys/iroha_core/smartcontracts/isi/query/__init__.py index 9df46c6d..a43e5a97 100644 --- a/iroha2/sys/iroha_core/smartcontracts/isi/query/__init__.py +++ b/iroha2/sys/iroha_core/smartcontracts/isi/query/__init__.py @@ -1,2 +1,7 @@ -from .....rust import Enum, make_struct, make_tuple, Dict -Error = Enum[("Decode", "iroha_version.error.Error"), ("Signature", str), ("Permission", str), ("Evaluate", str), ("Find", "iroha_core.smartcontracts.isi.error.FindError"), ("Conversion", str), ("Unauthorized", type(None))] + +from .....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Error = make_enum("Error", [("Decode", get_class("iroha_version.error.Error")), ("Signature", get_class(str)), ("Permission", get_class(str)), ("Evaluate", get_class(str)), ("Find", get_class("iroha_core.smartcontracts.isi.error.FindError")), ("Conversion", get_class(str)), ("Unauthorized", get_class(type(None)))], typing.Union[get_class("iroha_version.error.Error"), get_class(str), get_class(str), get_class(str), get_class("iroha_core.smartcontracts.isi.error.FindError"), get_class(str), get_class(type(None))]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/sumeragi/__init__.py b/iroha2/sys/iroha_core/sumeragi/__init__.py index b22ba35d..484bd865 100644 --- a/iroha2/sys/iroha_core/sumeragi/__init__.py +++ b/iroha2/sys/iroha_core/sumeragi/__init__.py @@ -1 +1,5 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/sumeragi/network_topology/__init__.py b/iroha2/sys/iroha_core/sumeragi/network_topology/__init__.py index 08e5f61b..d23373c9 100644 --- a/iroha2/sys/iroha_core/sumeragi/network_topology/__init__.py +++ b/iroha2/sys/iroha_core/sumeragi/network_topology/__init__.py @@ -1,3 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict -Topology = make_struct("Topology", [("sorted_peers", list), ("at_block", "iroha_crypto.hash.HashOf"), ("view_change_proofs", "iroha_core.sumeragi.view_change.ProofChain")]) +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Topology = make_struct("Topology", [("sorted_peers", list), ("at_block", "iroha_crypto.hash.HashOf")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_core/sumeragi/view_change/__init__.py b/iroha2/sys/iroha_core/sumeragi/view_change/__init__.py index 574e61d0..42259c82 100644 --- a/iroha2/sys/iroha_core/sumeragi/view_change/__init__.py +++ b/iroha2/sys/iroha_core/sumeragi/view_change/__init__.py @@ -1,4 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, Dict, get_class +import typing + BlockCreationTimeout = make_tuple("BlockCreationTimeout") CommitTimeout = make_struct("CommitTimeout", [("hash", "iroha_crypto.hash.HashOf")]) @@ -9,4 +12,4 @@ ProofPayload = make_struct("ProofPayload", [("previous_proof", "iroha_crypto.hash.HashOf"), ("latest_block", "iroha_crypto.hash.HashOf"), ("reason", "iroha_core.sumeragi.view_change.Reason")]) -Reason = Enum[("CommitTimeout", "iroha_core.sumeragi.view_change.CommitTimeout"), ("NoTransactionReceiptReceived", "iroha_core.sumeragi.view_change.NoTransactionReceiptReceived"), ("BlockCreationTimeout", "iroha_core.sumeragi.view_change.BlockCreationTimeout")] +Reason = make_enum("Reason", [("CommitTimeout", get_class("iroha_core.sumeragi.view_change.CommitTimeout")), ("NoTransactionReceiptReceived", get_class("iroha_core.sumeragi.view_change.NoTransactionReceiptReceived")), ("BlockCreationTimeout", get_class("iroha_core.sumeragi.view_change.BlockCreationTimeout"))], typing.Union[get_class("iroha_core.sumeragi.view_change.CommitTimeout"), get_class("iroha_core.sumeragi.view_change.NoTransactionReceiptReceived"), get_class("iroha_core.sumeragi.view_change.BlockCreationTimeout")]) diff --git a/iroha2/sys/iroha_crypto/__init__.py b/iroha2/sys/iroha_crypto/__init__.py index 77f91dad..d9f7d597 100644 --- a/iroha2/sys/iroha_crypto/__init__.py +++ b/iroha2/sys/iroha_crypto/__init__.py @@ -1,3 +1,7 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + PublicKey = make_struct("PublicKey", [("digest_function", str), ("payload", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_crypto/hash/__init__.py b/iroha2/sys/iroha_crypto/hash/__init__.py index e7fcf61a..c58f6fbe 100644 --- a/iroha2/sys/iroha_crypto/hash/__init__.py +++ b/iroha2/sys/iroha_crypto/hash/__init__.py @@ -1,3 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Hash = make_tuple("Hash", [list]) HashOf = make_tuple("HashOf", ["iroha_crypto.hash.Hash"]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_crypto/merkle/__init__.py b/iroha2/sys/iroha_crypto/merkle/__init__.py index b22ba35d..484bd865 100644 --- a/iroha2/sys/iroha_crypto/merkle/__init__.py +++ b/iroha2/sys/iroha_crypto/merkle/__init__.py @@ -1 +1,5 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_crypto/signature/__init__.py b/iroha2/sys/iroha_crypto/signature/__init__.py index 25f96e21..65023982 100644 --- a/iroha2/sys/iroha_crypto/signature/__init__.py +++ b/iroha2/sys/iroha_crypto/signature/__init__.py @@ -1,6 +1,10 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Signature = make_struct("Signature", [("public_key", "iroha_crypto.PublicKey"), ("payload", list)]) SignatureOf = make_tuple("SignatureOf", ["iroha_crypto.signature.Signature"]) -SignaturesOf = make_struct("SignaturesOf", [("signatures", Dict)]) +SignaturesOf = make_struct("SignaturesOf", [("signatures", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/__init__.py b/iroha2/sys/iroha_data_model/__init__.py index 3c99a794..4f380b53 100644 --- a/iroha2/sys/iroha_data_model/__init__.py +++ b/iroha2/sys/iroha_data_model/__init__.py @@ -1,6 +1,19 @@ -from ..rust import Enum, make_struct, make_tuple, Dict -IdBox = Enum[("DomainId", "iroha_data_model.domain.Id"), ("AccountId", "iroha_data_model.account.Id"), ("AssetDefinitionId", "iroha_data_model.asset.DefinitionId"), ("AssetId", "iroha_data_model.asset.Id"), ("PeerId", "iroha_data_model.peer.Id"), ("TriggerId", "iroha_data_model.trigger.Id"), ("RoleId", "iroha_data_model.role.Id"), ("PermissionTokenDefinitionId", "iroha_data_model.permissions.Id")] -IdentifiableBox = Enum[("NewDomain", "iroha_data_model.domain.NewDomain"), ("NewAccount", "iroha_data_model.account.NewAccount"), ("NewAssetDefinition", "iroha_data_model.asset.NewAssetDefinition"), ("NewRole", "iroha_data_model.role.NewRole"), ("Peer", "iroha_data_model.peer.Peer"), ("Domain", "iroha_data_model.domain.Domain"), ("Account", "iroha_data_model.account.Account"), ("AssetDefinition", "iroha_data_model.asset.AssetDefinition"), ("Asset", "iroha_data_model.asset.Asset"), ("Trigger", "iroha_data_model.trigger.Trigger"), ("Role", "iroha_data_model.role.Role"), ("PermissionTokenDefinition", "iroha_data_model.permissions.PermissionTokenDefinition")] -Parameter = Enum[("MaximumFaultyPeersAmount", int), ("BlockTime", int), ("CommitTime", int), ("TransactionReceiptTime", int)] -RegistrableBox = Enum[("Peer", "iroha_data_model.peer.Peer"), ("Domain", "iroha_data_model.domain.NewDomain"), ("Account", "iroha_data_model.account.NewAccount"), ("AssetDefinition", "iroha_data_model.asset.NewAssetDefinition"), ("Asset", "iroha_data_model.asset.Asset"), ("Trigger", "iroha_data_model.trigger.Trigger"), ("Role", "iroha_data_model.role.NewRole"), ("PermissionTokenDefinition", "iroha_data_model.permissions.PermissionTokenDefinition")] -Value = Enum[("U32", int), ("U128", int), ("Bool", bool), ("String", str), ("Name", "iroha_data_model.name.Name"), ("Fixed", "iroha_primitives.fixed.Fixed"), ("Vec", list), ("LimitedMetadata", "iroha_data_model.metadata.Metadata"), ("Id", "iroha_data_model.IdBox"), ("Identifiable", "iroha_data_model.IdentifiableBox"), ("PublicKey", "iroha_crypto.PublicKey"), ("Parameter", "iroha_data_model.Parameter"), ("SignatureCheckCondition", "iroha_data_model.account.SignatureCheckCondition"), ("TransactionValue", "iroha_data_model.transaction.TransactionValue"), ("TransactionQueryResult", "iroha_data_model.transaction.TransactionQueryResult"), ("PermissionToken", "iroha_data_model.permissions.PermissionToken"), ("Hash", "iroha_crypto.hash.Hash"), ("Block", "iroha_data_model.block_value.BlockValue"), ("BlockHeader", "iroha_data_model.block_value.BlockHeaderValue"), ("Ipv4Addr", "iroha_primitives.addr.Ipv4Addr"), ("Ipv6Addr", "iroha_primitives.addr.Ipv6Addr")] + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +IdBox = make_enum("IdBox", [("DomainId", get_class("iroha_data_model.domain.Id")), ("AccountId", get_class("iroha_data_model.account.Id")), ("AssetDefinitionId", get_class("iroha_data_model.asset.DefinitionId")), ("AssetId", get_class("iroha_data_model.asset.Id")), ("PeerId", get_class("iroha_data_model.peer.Id")), ("TriggerId", get_class("iroha_data_model.trigger.Id")), ("RoleId", get_class("iroha_data_model.role.Id")), ("PermissionTokenDefinitionId", get_class("iroha_data_model.permission.token.Id")), ("ValidatorId", get_class("iroha_data_model.permission.validator.Id"))], typing.Union[get_class("iroha_data_model.domain.Id"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.asset.DefinitionId"), get_class("iroha_data_model.asset.Id"), get_class("iroha_data_model.peer.Id"), get_class("iroha_data_model.trigger.Id"), get_class("iroha_data_model.role.Id"), get_class("iroha_data_model.permission.token.Id"), get_class("iroha_data_model.permission.validator.Id")]) + +IdentifiableBox = make_enum("IdentifiableBox", [("NewDomain", get_class("iroha_data_model.domain.NewDomain")), ("NewAccount", get_class("iroha_data_model.account.NewAccount")), ("NewAssetDefinition", get_class("iroha_data_model.asset.NewAssetDefinition")), ("NewRole", get_class("iroha_data_model.role.NewRole")), ("Peer", get_class("iroha_data_model.peer.Peer")), ("Domain", get_class("iroha_data_model.domain.Domain")), ("Account", get_class("iroha_data_model.account.Account")), ("AssetDefinition", get_class("iroha_data_model.asset.AssetDefinition")), ("Asset", get_class("iroha_data_model.asset.Asset")), ("Trigger", get_class("iroha_data_model.trigger.Trigger")), ("Role", get_class("iroha_data_model.role.Role")), ("PermissionTokenDefinition", get_class("iroha_data_model.permission.token.Definition")), ("Validator", get_class("iroha_data_model.permission.validator.Validator"))], typing.Union[get_class("iroha_data_model.domain.NewDomain"), get_class("iroha_data_model.account.NewAccount"), get_class("iroha_data_model.asset.NewAssetDefinition"), get_class("iroha_data_model.role.NewRole"), get_class("iroha_data_model.peer.Peer"), get_class("iroha_data_model.domain.Domain"), get_class("iroha_data_model.account.Account"), get_class("iroha_data_model.asset.AssetDefinition"), get_class("iroha_data_model.asset.Asset"), get_class("iroha_data_model.trigger.Trigger"), get_class("iroha_data_model.role.Role"), get_class("iroha_data_model.permission.token.Definition"), get_class("iroha_data_model.permission.validator.Validator")]) + +NumericValue = make_enum("NumericValue", [("U32", get_class(int)), ("U128", get_class(int)), ("Fixed", get_class("iroha_primitives.fixed.Fixed"))], typing.Union[get_class(int), get_class(int), get_class("iroha_primitives.fixed.Fixed")]) + +Parameter = make_enum("Parameter", [("MaximumFaultyPeersAmount", get_class(int)), ("BlockTime", get_class(int)), ("CommitTime", get_class(int)), ("TransactionReceiptTime", get_class(int))], typing.Union[get_class(int), get_class(int), get_class(int), get_class(int)]) + +RegistrableBox = make_enum("RegistrableBox", [("Peer", get_class("iroha_data_model.peer.Peer")), ("Domain", get_class("iroha_data_model.domain.NewDomain")), ("Account", get_class("iroha_data_model.account.NewAccount")), ("AssetDefinition", get_class("iroha_data_model.asset.NewAssetDefinition")), ("Asset", get_class("iroha_data_model.asset.Asset")), ("Trigger", get_class("iroha_data_model.trigger.Trigger")), ("Role", get_class("iroha_data_model.role.NewRole")), ("PermissionTokenDefinition", get_class("iroha_data_model.permission.token.Definition")), ("Validator", get_class("iroha_data_model.permission.validator.Validator"))], typing.Union[get_class("iroha_data_model.peer.Peer"), get_class("iroha_data_model.domain.NewDomain"), get_class("iroha_data_model.account.NewAccount"), get_class("iroha_data_model.asset.NewAssetDefinition"), get_class("iroha_data_model.asset.Asset"), get_class("iroha_data_model.trigger.Trigger"), get_class("iroha_data_model.role.NewRole"), get_class("iroha_data_model.permission.token.Definition"), get_class("iroha_data_model.permission.validator.Validator")]) + +Value = make_enum("Value", [("Bool", get_class(bool)), ("String", get_class(str)), ("Name", get_class("iroha_data_model.name.Name")), ("Vec", get_class(list)), ("LimitedMetadata", get_class("iroha_data_model.metadata.Metadata")), ("Id", get_class("iroha_data_model.IdBox")), ("Identifiable", get_class("iroha_data_model.IdentifiableBox")), ("PublicKey", get_class("iroha_crypto.PublicKey")), ("Parameter", get_class("iroha_data_model.Parameter")), ("SignatureCheckCondition", get_class("iroha_data_model.account.SignatureCheckCondition")), ("TransactionValue", get_class("iroha_data_model.transaction.TransactionValue")), ("TransactionQueryResult", get_class("iroha_data_model.transaction.TransactionQueryResult")), ("PermissionToken", get_class("iroha_data_model.permission.token.Token")), ("Hash", get_class("iroha_crypto.hash.Hash")), ("Block", get_class("iroha_data_model.block_value.BlockValue")), ("BlockHeader", get_class("iroha_data_model.block_value.BlockHeaderValue")), ("Ipv4Addr", get_class("iroha_primitives.addr.Ipv4Addr")), ("Ipv6Addr", get_class("iroha_primitives.addr.Ipv6Addr")), ("Numeric", get_class("iroha_data_model.NumericValue"))], typing.Union[get_class(bool), get_class(str), get_class("iroha_data_model.name.Name"), get_class(list), get_class("iroha_data_model.metadata.Metadata"), get_class("iroha_data_model.IdBox"), get_class("iroha_data_model.IdentifiableBox"), get_class("iroha_crypto.PublicKey"), get_class("iroha_data_model.Parameter"), get_class("iroha_data_model.account.SignatureCheckCondition"), get_class("iroha_data_model.transaction.TransactionValue"), get_class("iroha_data_model.transaction.TransactionQueryResult"), get_class("iroha_data_model.permission.token.Token"), get_class("iroha_crypto.hash.Hash"), get_class("iroha_data_model.block_value.BlockValue"), get_class("iroha_data_model.block_value.BlockHeaderValue"), get_class("iroha_primitives.addr.Ipv4Addr"), get_class("iroha_primitives.addr.Ipv6Addr"), get_class("iroha_data_model.NumericValue")]) + +ValueKind = make_enum("ValueKind", [("Bool", get_class(type(None))), ("String", get_class(type(None))), ("Name", get_class(type(None))), ("Vec", get_class(type(None))), ("LimitedMetadata", get_class(type(None))), ("Id", get_class(type(None))), ("Identifiable", get_class(type(None))), ("PublicKey", get_class(type(None))), ("Parameter", get_class(type(None))), ("SignatureCheckCondition", get_class(type(None))), ("TransactionValue", get_class(type(None))), ("TransactionQueryResult", get_class(type(None))), ("PermissionToken", get_class(type(None))), ("Hash", get_class(type(None))), ("Block", get_class(type(None))), ("BlockHeader", get_class(type(None))), ("Ipv4Addr", get_class(type(None))), ("Ipv6Addr", get_class(type(None))), ("Numeric", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/account/__init__.py b/iroha2/sys/iroha_data_model/account/__init__.py index ee6fff6a..2fecfb8c 100644 --- a/iroha2/sys/iroha_data_model/account/__init__.py +++ b/iroha2/sys/iroha_data_model/account/__init__.py @@ -1,4 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Account = make_struct("Account", [("id", "iroha_data_model.account.Id"), ("assets", Dict), ("signatories", list), ("signature_check_condition", "iroha_data_model.account.SignatureCheckCondition"), ("metadata", "iroha_data_model.metadata.Metadata"), ("roles", list)]) Id = make_struct("Id", [("name", "iroha_data_model.name.Name"), ("domain_id", "iroha_data_model.domain.Id")]) @@ -6,3 +9,4 @@ NewAccount = make_struct("NewAccount", [("id", "iroha_data_model.account.Id"), ("signatories", list), ("metadata", "iroha_data_model.metadata.Metadata")]) SignatureCheckCondition = make_tuple("SignatureCheckCondition", ["iroha_data_model.expression.EvaluatesTo"]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/asset/__init__.py b/iroha2/sys/iroha_data_model/asset/__init__.py index 31a77054..ea07ba44 100644 --- a/iroha2/sys/iroha_data_model/asset/__init__.py +++ b/iroha2/sys/iroha_data_model/asset/__init__.py @@ -1,16 +1,23 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Asset = make_struct("Asset", [("id", "iroha_data_model.asset.Id"), ("value", "iroha_data_model.asset.AssetValue")]) AssetDefinition = make_struct("AssetDefinition", [("id", "iroha_data_model.asset.DefinitionId"), ("value_type", "iroha_data_model.asset.AssetValueType"), ("mintable", "iroha_data_model.asset.Mintable"), ("metadata", "iroha_data_model.metadata.Metadata")]) AssetDefinitionEntry = make_struct("AssetDefinitionEntry", [("definition", "iroha_data_model.asset.AssetDefinition"), ("registered_by", "iroha_data_model.account.Id")]) -AssetValue = Enum[("Quantity", int), ("BigQuantity", int), ("Fixed", "iroha_primitives.fixed.Fixed"), ("Store", "iroha_data_model.metadata.Metadata")] -AssetValueType = Enum[("Quantity", type(None)), ("BigQuantity", type(None)), ("Fixed", type(None)), ("Store", type(None))] +AssetValue = make_enum("AssetValue", [("Quantity", get_class(int)), ("BigQuantity", get_class(int)), ("Fixed", get_class("iroha_primitives.fixed.Fixed")), ("Store", get_class("iroha_data_model.metadata.Metadata"))], typing.Union[get_class(int), get_class(int), get_class("iroha_primitives.fixed.Fixed"), get_class("iroha_data_model.metadata.Metadata")]) + +AssetValueType = make_enum("AssetValueType", [("Quantity", get_class(type(None))), ("BigQuantity", get_class(type(None))), ("Fixed", get_class(type(None))), ("Store", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + DefinitionId = make_struct("DefinitionId", [("name", "iroha_data_model.name.Name"), ("domain_id", "iroha_data_model.domain.Id")]) Id = make_struct("Id", [("definition_id", "iroha_data_model.asset.DefinitionId"), ("account_id", "iroha_data_model.account.Id")]) -Mintable = Enum[("Infinitely", type(None)), ("Once", type(None)), ("Not", type(None))] +Mintable = make_enum("Mintable", [("Infinitely", get_class(type(None))), ("Once", get_class(type(None))), ("Not", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None))]) + NewAssetDefinition = make_struct("NewAssetDefinition", [("id", "iroha_data_model.asset.DefinitionId"), ("value_type", "iroha_data_model.asset.AssetValueType"), ("mintable", "iroha_data_model.asset.Mintable"), ("metadata", "iroha_data_model.metadata.Metadata")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/block_value/__init__.py b/iroha2/sys/iroha_data_model/block_value/__init__.py index 3a65da63..aa7be1a7 100644 --- a/iroha2/sys/iroha_data_model/block_value/__init__.py +++ b/iroha2/sys/iroha_data_model/block_value/__init__.py @@ -1,5 +1,9 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + BlockHeaderValue = make_struct("BlockHeaderValue", [("timestamp", int), ("height", int), ("previous_block_hash", "iroha_crypto.hash.Hash"), ("transactions_hash", "iroha_crypto.hash.HashOf"), ("rejected_transactions_hash", "iroha_crypto.hash.HashOf"), ("invalidated_blocks_hashes", list), ("current_block_hash", "iroha_crypto.hash.Hash")]) BlockValue = make_struct("BlockValue", [("header", "iroha_data_model.block_value.BlockHeaderValue"), ("transactions", list), ("rejected_transactions", list), ("event_recommendations", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/domain/__init__.py b/iroha2/sys/iroha_data_model/domain/__init__.py index 7d90a9b9..d498f49a 100644 --- a/iroha2/sys/iroha_data_model/domain/__init__.py +++ b/iroha2/sys/iroha_data_model/domain/__init__.py @@ -1,8 +1,12 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -Domain = make_struct("Domain", [("id", "iroha_data_model.domain.Id"), ("accounts", Dict), ("asset_definitions", Dict), ("logo", "iroha_data_model.domain.IpfsPath"), ("metadata", "iroha_data_model.metadata.Metadata")]) + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Domain = make_struct("Domain", [("id", "iroha_data_model.domain.Id"), ("accounts", Dict), ("asset_definitions", Dict), ("asset_total_quantities", Dict), ("logo", "iroha_data_model.domain.IpfsPath"), ("metadata", "iroha_data_model.metadata.Metadata")]) Id = make_struct("Id", [("name", "iroha_data_model.name.Name")]) IpfsPath = make_tuple("IpfsPath", [str]) NewDomain = make_struct("NewDomain", [("id", "iroha_data_model.domain.Id"), ("logo", "iroha_data_model.domain.IpfsPath"), ("metadata", "iroha_data_model.metadata.Metadata")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/__init__.py b/iroha2/sys/iroha_data_model/events/__init__.py index 5cc177e5..a1a2debf 100644 --- a/iroha2/sys/iroha_data_model/events/__init__.py +++ b/iroha2/sys/iroha_data_model/events/__init__.py @@ -1,7 +1,15 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -Event = Enum[("Pipeline", "iroha_data_model.events.pipeline.Event"), ("Data", "iroha_data_model.events.data.events.Event"), ("Time", "iroha_data_model.events.time.Event"), ("ExecuteTrigger", "iroha_data_model.events.execute_trigger.Event")] -EventPublisherMessage = Enum[("SubscriptionAccepted", type(None)), ("Event", "iroha_data_model.events.Event")] -EventSubscriberMessage = Enum[("SubscriptionRequest", "iroha_data_model.events.FilterBox"), ("EventReceived", type(None))] -FilterBox = Enum[("Pipeline", "iroha_data_model.events.pipeline.EventFilter"), ("Data", "iroha_data_model.events.data.filters.FilterOpt"), ("Time", "iroha_data_model.events.time.EventFilter"), ("ExecuteTrigger", "iroha_data_model.events.execute_trigger.EventFilter")] -VersionedEventPublisherMessage = Enum[("V1", "iroha_data_model.events.EventPublisherMessage")] -VersionedEventSubscriberMessage = Enum[("V1", "iroha_data_model.events.EventSubscriberMessage")] + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Event = make_enum("Event", [("Pipeline", get_class("iroha_data_model.events.pipeline.Event")), ("Data", get_class("iroha_data_model.events.data.events.Event")), ("Time", get_class("iroha_data_model.events.time.Event")), ("ExecuteTrigger", get_class("iroha_data_model.events.execute_trigger.Event"))], typing.Union[get_class("iroha_data_model.events.pipeline.Event"), get_class("iroha_data_model.events.data.events.Event"), get_class("iroha_data_model.events.time.Event"), get_class("iroha_data_model.events.execute_trigger.Event")]) + +EventMessage = make_tuple("EventMessage", ["iroha_data_model.events.Event"]) +EventSubscriptionRequest = make_tuple("EventSubscriptionRequest", ["iroha_data_model.events.FilterBox"]) +FilterBox = make_enum("FilterBox", [("Pipeline", get_class("iroha_data_model.events.pipeline.EventFilter")), ("Data", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("Time", get_class("iroha_data_model.events.time.EventFilter")), ("ExecuteTrigger", get_class("iroha_data_model.events.execute_trigger.EventFilter"))], typing.Union[get_class("iroha_data_model.events.pipeline.EventFilter"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.time.EventFilter"), get_class("iroha_data_model.events.execute_trigger.EventFilter")]) + +VersionedEventMessage = make_enum("VersionedEventMessage", [("V1", get_class("iroha_data_model.events.EventMessage"))], typing.Union[get_class("iroha_data_model.events.EventMessage")]) + +VersionedEventSubscriptionRequest = make_enum("VersionedEventSubscriptionRequest", [("V1", get_class("iroha_data_model.events.EventSubscriptionRequest"))], typing.Union[get_class("iroha_data_model.events.EventSubscriptionRequest")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/__init__.py b/iroha2/sys/iroha_data_model/events/data/__init__.py index ef324d17..71581dcd 100644 --- a/iroha2/sys/iroha_data_model/events/data/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/__init__.py @@ -1 +1,5 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/__init__.py index 23e4644c..79cf8b9e 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/__init__.py @@ -1,2 +1,9 @@ -from .....rust import Enum, make_struct, make_tuple, Dict -Event = Enum[("Peer", "iroha_data_model.events.data.events.peer.PeerEvent"), ("Domain", "iroha_data_model.events.data.events.domain.DomainEvent"), ("Account", "iroha_data_model.events.data.events.account.AccountEvent"), ("AssetDefinition", "iroha_data_model.events.data.events.asset.AssetDefinitionEvent"), ("Asset", "iroha_data_model.events.data.events.asset.AssetEvent"), ("Trigger", "iroha_data_model.events.data.events.trigger.TriggerEvent"), ("Role", "iroha_data_model.events.data.events.role.RoleEvent"), ("PermissionToken", "iroha_data_model.events.data.events.permission_token.PermissionTokenEvent")] + +from .....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Event = make_enum("Event", [("Peer", get_class("iroha_data_model.events.data.events.peer.PeerEvent")), ("Domain", get_class("iroha_data_model.events.data.events.domain.DomainEvent")), ("Account", get_class("iroha_data_model.events.data.events.account.AccountEvent")), ("AssetDefinition", get_class("iroha_data_model.events.data.events.asset.AssetDefinitionEvent")), ("Asset", get_class("iroha_data_model.events.data.events.asset.AssetEvent")), ("Trigger", get_class("iroha_data_model.events.data.events.trigger.TriggerEvent")), ("Role", get_class("iroha_data_model.events.data.events.role.RoleEvent")), ("PermissionToken", get_class("iroha_data_model.events.data.events.permission.PermissionTokenEvent")), ("PermissionValidator", get_class("iroha_data_model.events.data.events.permission.PermissionValidatorEvent"))], typing.Union[get_class("iroha_data_model.events.data.events.peer.PeerEvent"), get_class("iroha_data_model.events.data.events.domain.DomainEvent"), get_class("iroha_data_model.events.data.events.account.AccountEvent"), get_class("iroha_data_model.events.data.events.asset.AssetDefinitionEvent"), get_class("iroha_data_model.events.data.events.asset.AssetEvent"), get_class("iroha_data_model.events.data.events.trigger.TriggerEvent"), get_class("iroha_data_model.events.data.events.role.RoleEvent"), get_class("iroha_data_model.events.data.events.permission.PermissionTokenEvent"), get_class("iroha_data_model.events.data.events.permission.PermissionValidatorEvent")]) + +MetadataChanged = make_struct("MetadataChanged", [("target_id", "iroha_data_model.account.Id"), ("key", "iroha_data_model.name.Name"), ("value", "iroha_data_model.Value")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/account/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/account/__init__.py index c59dbc5a..c67c5197 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/account/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/account/__init__.py @@ -1,5 +1,15 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -AccountEvent = Enum[("Asset", "iroha_data_model.events.data.events.asset.AssetEvent"), ("Created", "iroha_data_model.account.Id"), ("Deleted", "iroha_data_model.account.Id"), ("AuthenticationAdded", "iroha_data_model.account.Id"), ("AuthenticationRemoved", "iroha_data_model.account.Id"), ("PermissionAdded", "iroha_data_model.account.Id"), ("PermissionRemoved", "iroha_data_model.account.Id"), ("RoleRevoked", "iroha_data_model.account.Id"), ("RoleGranted", "iroha_data_model.account.Id"), ("MetadataInserted", "iroha_data_model.account.Id"), ("MetadataRemoved", "iroha_data_model.account.Id")] -AccountEventFilter = Enum[("ByCreated", type(None)), ("ByDeleted", type(None)), ("ByAuthenticationAdded", type(None)), ("ByAuthenticationRemoved", type(None)), ("ByPermissionAdded", type(None)), ("ByPermissionRemoved", type(None)), ("ByRoleRevoked", type(None)), ("ByRoleGranted", type(None)), ("ByMetadataInserted", type(None)), ("ByMetadataRemoved", type(None)), ("ByAsset", "iroha_data_model.events.data.filters.FilterOpt")] + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +AccountEvent = make_enum("AccountEvent", [("Asset", get_class("iroha_data_model.events.data.events.asset.AssetEvent")), ("Created", get_class("iroha_data_model.account.Id")), ("Deleted", get_class("iroha_data_model.account.Id")), ("AuthenticationAdded", get_class("iroha_data_model.account.Id")), ("AuthenticationRemoved", get_class("iroha_data_model.account.Id")), ("PermissionAdded", get_class("iroha_data_model.events.data.events.account.AccountPermissionChanged")), ("PermissionRemoved", get_class("iroha_data_model.events.data.events.account.AccountPermissionChanged")), ("RoleRevoked", get_class("iroha_data_model.events.data.events.account.AccountRoleChanged")), ("RoleGranted", get_class("iroha_data_model.events.data.events.account.AccountRoleChanged")), ("MetadataInserted", get_class("iroha_data_model.events.data.events.MetadataChanged")), ("MetadataRemoved", get_class("iroha_data_model.events.data.events.MetadataChanged"))], typing.Union[get_class("iroha_data_model.events.data.events.asset.AssetEvent"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.account.Id"), get_class("iroha_data_model.events.data.events.account.AccountPermissionChanged"), get_class("iroha_data_model.events.data.events.account.AccountPermissionChanged"), get_class("iroha_data_model.events.data.events.account.AccountRoleChanged"), get_class("iroha_data_model.events.data.events.account.AccountRoleChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged")]) + +AccountEventFilter = make_enum("AccountEventFilter", [("ByCreated", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByAuthenticationAdded", get_class(type(None))), ("ByAuthenticationRemoved", get_class(type(None))), ("ByPermissionAdded", get_class(type(None))), ("ByPermissionRemoved", get_class(type(None))), ("ByRoleRevoked", get_class(type(None))), ("ByRoleGranted", get_class(type(None))), ("ByMetadataInserted", get_class(type(None))), ("ByMetadataRemoved", get_class(type(None))), ("ByAsset", get_class("iroha_data_model.events.data.filters.FilterOpt"))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class("iroha_data_model.events.data.filters.FilterOpt")]) + AccountFilter = make_struct("AccountFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +AccountPermissionChanged = make_struct("AccountPermissionChanged", [("account_id", "iroha_data_model.account.Id"), ("permission_id", "iroha_data_model.permission.token.Id")]) + +AccountRoleChanged = make_struct("AccountRoleChanged", [("account_id", "iroha_data_model.account.Id"), ("role_id", "iroha_data_model.role.Id")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/asset/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/asset/__init__.py index 1102bb08..8a8181ad 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/asset/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/asset/__init__.py @@ -1,9 +1,21 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -AssetDefinitionEvent = Enum[("Created", "iroha_data_model.asset.DefinitionId"), ("MintabilityChanged", "iroha_data_model.asset.DefinitionId"), ("Deleted", "iroha_data_model.asset.DefinitionId"), ("MetadataInserted", "iroha_data_model.asset.DefinitionId"), ("MetadataRemoved", "iroha_data_model.asset.DefinitionId")] -AssetDefinitionEventFilter = Enum[("ByCreated", type(None)), ("ByMintabilityChanged", type(None)), ("ByDeleted", type(None)), ("ByMetadataInserted", type(None)), ("ByMetadataRemoved", type(None))] + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +AssetChanged = make_struct("AssetChanged", [("asset_id", "iroha_data_model.asset.Id"), ("amount", "iroha_data_model.asset.AssetValue")]) + +AssetDefinitionEvent = make_enum("AssetDefinitionEvent", [("Created", get_class("iroha_data_model.asset.DefinitionId")), ("MintabilityChanged", get_class("iroha_data_model.asset.DefinitionId")), ("Deleted", get_class("iroha_data_model.asset.DefinitionId")), ("MetadataInserted", get_class("iroha_data_model.events.data.events.MetadataChanged")), ("MetadataRemoved", get_class("iroha_data_model.events.data.events.MetadataChanged")), ("TotalQuantityChanged", get_class("iroha_data_model.events.data.events.asset.AssetDefinitionTotalQuantityChanged"))], typing.Union[get_class("iroha_data_model.asset.DefinitionId"), get_class("iroha_data_model.asset.DefinitionId"), get_class("iroha_data_model.asset.DefinitionId"), get_class("iroha_data_model.events.data.events.MetadataChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged"), get_class("iroha_data_model.events.data.events.asset.AssetDefinitionTotalQuantityChanged")]) + +AssetDefinitionEventFilter = make_enum("AssetDefinitionEventFilter", [("ByCreated", get_class(type(None))), ("ByMintabilityChanged", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByMetadataInserted", get_class(type(None))), ("ByMetadataRemoved", get_class(type(None))), ("ByTotalQuantityChanged", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + AssetDefinitionFilter = make_struct("AssetDefinitionFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) -AssetEvent = Enum[("Created", "iroha_data_model.asset.Id"), ("Deleted", "iroha_data_model.asset.Id"), ("Added", "iroha_data_model.asset.Id"), ("Removed", "iroha_data_model.asset.Id"), ("MetadataInserted", "iroha_data_model.asset.Id"), ("MetadataRemoved", "iroha_data_model.asset.Id")] -AssetEventFilter = Enum[("ByCreated", type(None)), ("ByDeleted", type(None)), ("ByAdded", type(None)), ("ByRemoved", type(None)), ("ByMetadataInserted", type(None)), ("ByMetadataRemoved", type(None))] +AssetDefinitionTotalQuantityChanged = make_struct("AssetDefinitionTotalQuantityChanged", [("asset_definition_id", "iroha_data_model.asset.DefinitionId"), ("total_amount", "iroha_data_model.NumericValue")]) + +AssetEvent = make_enum("AssetEvent", [("Created", get_class("iroha_data_model.asset.Id")), ("Deleted", get_class("iroha_data_model.asset.Id")), ("Added", get_class("iroha_data_model.events.data.events.asset.AssetChanged")), ("Removed", get_class("iroha_data_model.events.data.events.asset.AssetChanged")), ("MetadataInserted", get_class("iroha_data_model.events.data.events.MetadataChanged")), ("MetadataRemoved", get_class("iroha_data_model.events.data.events.MetadataChanged"))], typing.Union[get_class("iroha_data_model.asset.Id"), get_class("iroha_data_model.asset.Id"), get_class("iroha_data_model.events.data.events.asset.AssetChanged"), get_class("iroha_data_model.events.data.events.asset.AssetChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged")]) + +AssetEventFilter = make_enum("AssetEventFilter", [("ByCreated", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByAdded", get_class(type(None))), ("ByRemoved", get_class(type(None))), ("ByMetadataInserted", get_class(type(None))), ("ByMetadataRemoved", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + AssetFilter = make_struct("AssetFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/domain/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/domain/__init__.py index 0c11ea06..f8d0ccda 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/domain/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/domain/__init__.py @@ -1,5 +1,11 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -DomainEvent = Enum[("Account", "iroha_data_model.events.data.events.account.AccountEvent"), ("AssetDefinition", "iroha_data_model.events.data.events.asset.AssetDefinitionEvent"), ("Created", "iroha_data_model.domain.Id"), ("Deleted", "iroha_data_model.domain.Id"), ("MetadataInserted", "iroha_data_model.domain.Id"), ("MetadataRemoved", "iroha_data_model.domain.Id")] -DomainEventFilter = Enum[("ByCreated", type(None)), ("ByDeleted", type(None)), ("ByMetadataInserted", type(None)), ("ByMetadataRemoved", type(None)), ("ByAccount", "iroha_data_model.events.data.filters.FilterOpt"), ("ByAssetDefinition", "iroha_data_model.events.data.filters.FilterOpt")] + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +DomainEvent = make_enum("DomainEvent", [("Account", get_class("iroha_data_model.events.data.events.account.AccountEvent")), ("AssetDefinition", get_class("iroha_data_model.events.data.events.asset.AssetDefinitionEvent")), ("Created", get_class("iroha_data_model.domain.Id")), ("Deleted", get_class("iroha_data_model.domain.Id")), ("MetadataInserted", get_class("iroha_data_model.events.data.events.MetadataChanged")), ("MetadataRemoved", get_class("iroha_data_model.events.data.events.MetadataChanged"))], typing.Union[get_class("iroha_data_model.events.data.events.account.AccountEvent"), get_class("iroha_data_model.events.data.events.asset.AssetDefinitionEvent"), get_class("iroha_data_model.domain.Id"), get_class("iroha_data_model.domain.Id"), get_class("iroha_data_model.events.data.events.MetadataChanged"), get_class("iroha_data_model.events.data.events.MetadataChanged")]) + +DomainEventFilter = make_enum("DomainEventFilter", [("ByCreated", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByMetadataInserted", get_class(type(None))), ("ByMetadataRemoved", get_class(type(None))), ("ByAccount", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByAssetDefinition", get_class("iroha_data_model.events.data.filters.FilterOpt"))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt")]) + DomainFilter = make_struct("DomainFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/peer/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/peer/__init__.py index 034f19d3..82f76fde 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/peer/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/peer/__init__.py @@ -1,5 +1,11 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -PeerEvent = Enum[("Added", "iroha_data_model.peer.Id"), ("Removed", "iroha_data_model.peer.Id")] -PeerEventFilter = Enum[("ByAdded", type(None)), ("ByRemoved", type(None))] + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +PeerEvent = make_enum("PeerEvent", [("Added", get_class("iroha_data_model.peer.Id")), ("Removed", get_class("iroha_data_model.peer.Id"))], typing.Union[get_class("iroha_data_model.peer.Id"), get_class("iroha_data_model.peer.Id")]) + +PeerEventFilter = make_enum("PeerEventFilter", [("ByAdded", get_class(type(None))), ("ByRemoved", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None))]) + PeerFilter = make_struct("PeerFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/permission/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/permission/__init__.py new file mode 100644 index 00000000..e5e662e3 --- /dev/null +++ b/iroha2/sys/iroha_data_model/events/data/events/permission/__init__.py @@ -0,0 +1,9 @@ + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +PermissionTokenEvent = make_enum("PermissionTokenEvent", [("DefinitionCreated", get_class("iroha_data_model.permission.token.Definition")), ("DefinitionDeleted", get_class("iroha_data_model.permission.token.Definition"))], typing.Union[get_class("iroha_data_model.permission.token.Definition"), get_class("iroha_data_model.permission.token.Definition")]) + +PermissionValidatorEvent = make_enum("PermissionValidatorEvent", [("Added", get_class("iroha_data_model.permission.validator.Id")), ("Removed", get_class("iroha_data_model.permission.validator.Id"))], typing.Union[get_class("iroha_data_model.permission.validator.Id"), get_class("iroha_data_model.permission.validator.Id")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/permission_token/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/permission_token/__init__.py index 29100f70..5a21ff6a 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/permission_token/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/permission_token/__init__.py @@ -1,2 +1,5 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -PermissionTokenEvent = Enum[("DefinitionCreated", "iroha_data_model.permissions.PermissionTokenDefinition"), ("DefinitionDeleted", "iroha_data_model.permissions.PermissionTokenDefinition")] + +from ......rust import make_enum, make_struct, make_tuple, Dict, get_class +import typing + +PermissionTokenEvent = make_enum("PermissionTokenEvent", [("DefinitionCreated", get_class("iroha_data_model.permissions.PermissionTokenDefinition")), ("DefinitionDeleted", get_class("iroha_data_model.permissions.PermissionTokenDefinition"))], typing.Union[get_class("iroha_data_model.permissions.PermissionTokenDefinition"), get_class("iroha_data_model.permissions.PermissionTokenDefinition")]) diff --git a/iroha2/sys/iroha_data_model/events/data/events/role/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/role/__init__.py index cebe8a71..05e790bd 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/role/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/role/__init__.py @@ -1,7 +1,13 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -PermissionRemoved = make_struct("PermissionRemoved", [("role_id", "iroha_data_model.role.Id"), ("permission_definition_id", "iroha_data_model.permissions.Id")]) -RoleEvent = Enum[("Created", "iroha_data_model.role.Id"), ("Deleted", "iroha_data_model.role.Id"), ("PermissionRemoved", "iroha_data_model.events.data.events.role.PermissionRemoved")] -RoleEventFilter = Enum[("ByCreated", type(None)), ("ByDeleted", type(None)), ("ByPermissionRemoved", type(None))] +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +PermissionRemoved = make_struct("PermissionRemoved", [("role_id", "iroha_data_model.role.Id"), ("permission_definition_id", "iroha_data_model.permission.token.Id")]) + +RoleEvent = make_enum("RoleEvent", [("Created", get_class("iroha_data_model.role.Id")), ("Deleted", get_class("iroha_data_model.role.Id")), ("PermissionRemoved", get_class("iroha_data_model.events.data.events.role.PermissionRemoved"))], typing.Union[get_class("iroha_data_model.role.Id"), get_class("iroha_data_model.role.Id"), get_class("iroha_data_model.events.data.events.role.PermissionRemoved")]) + +RoleEventFilter = make_enum("RoleEventFilter", [("ByCreated", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByPermissionRemoved", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None))]) + RoleFilter = make_struct("RoleFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/events/trigger/__init__.py b/iroha2/sys/iroha_data_model/events/data/events/trigger/__init__.py index 6ff7f76e..f6f88937 100644 --- a/iroha2/sys/iroha_data_model/events/data/events/trigger/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/events/trigger/__init__.py @@ -1,5 +1,13 @@ -from ......rust import Enum, make_struct, make_tuple, Dict -TriggerEvent = Enum[("Created", "iroha_data_model.trigger.Id"), ("Deleted", "iroha_data_model.trigger.Id"), ("Extended", "iroha_data_model.trigger.Id"), ("Shortened", "iroha_data_model.trigger.Id")] -TriggerEventFilter = Enum[("ByCreated", type(None)), ("ByDeleted", type(None)), ("ByExtended", type(None)), ("ByShortened", type(None))] + +from ......rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +TriggerEvent = make_enum("TriggerEvent", [("Created", get_class("iroha_data_model.trigger.Id")), ("Deleted", get_class("iroha_data_model.trigger.Id")), ("Extended", get_class("iroha_data_model.events.data.events.trigger.TriggerNumberOfExecutionsChanged")), ("Shortened", get_class("iroha_data_model.events.data.events.trigger.TriggerNumberOfExecutionsChanged"))], typing.Union[get_class("iroha_data_model.trigger.Id"), get_class("iroha_data_model.trigger.Id"), get_class("iroha_data_model.events.data.events.trigger.TriggerNumberOfExecutionsChanged"), get_class("iroha_data_model.events.data.events.trigger.TriggerNumberOfExecutionsChanged")]) + +TriggerEventFilter = make_enum("TriggerEventFilter", [("ByCreated", get_class(type(None))), ("ByDeleted", get_class(type(None))), ("ByExtended", get_class(type(None))), ("ByShortened", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + TriggerFilter = make_struct("TriggerFilter", [("origin_filter", "iroha_data_model.events.data.filters.FilterOpt"), ("event_filter", "iroha_data_model.events.data.filters.FilterOpt")]) +TriggerNumberOfExecutionsChanged = make_struct("TriggerNumberOfExecutionsChanged", [("trigger_id", "iroha_data_model.trigger.Id"), ("by", int)]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/data/filters/__init__.py b/iroha2/sys/iroha_data_model/events/data/filters/__init__.py index f06c6852..edad328a 100644 --- a/iroha2/sys/iroha_data_model/events/data/filters/__init__.py +++ b/iroha2/sys/iroha_data_model/events/data/filters/__init__.py @@ -1,4 +1,10 @@ -from .....rust import Enum, make_struct, make_tuple, Dict -EntityFilter = Enum[("ByPeer", "iroha_data_model.events.data.filters.FilterOpt"), ("ByDomain", "iroha_data_model.events.data.filters.FilterOpt"), ("ByAccount", "iroha_data_model.events.data.filters.FilterOpt"), ("ByAssetDefinition", "iroha_data_model.events.data.filters.FilterOpt"), ("ByAsset", "iroha_data_model.events.data.filters.FilterOpt"), ("ByTrigger", "iroha_data_model.events.data.filters.FilterOpt"), ("ByRole", "iroha_data_model.events.data.filters.FilterOpt")] -FilterOpt = Enum[("AcceptAll", type(None)), ("BySome", "iroha_data_model.events.data.events.account.AccountEventFilter")] + +from .....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +EntityFilter = make_enum("EntityFilter", [("ByPeer", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByDomain", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByAccount", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByAssetDefinition", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByAsset", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByTrigger", get_class("iroha_data_model.events.data.filters.FilterOpt")), ("ByRole", get_class("iroha_data_model.events.data.filters.FilterOpt"))], typing.Union[get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt"), get_class("iroha_data_model.events.data.filters.FilterOpt")]) + +FilterOpt = make_enum("FilterOpt", [("AcceptAll", get_class(type(None))), ("BySome", get_class("iroha_data_model.events.data.events.account.AccountEventFilter"))], typing.Union[get_class(type(None)), get_class("iroha_data_model.events.data.events.account.AccountEventFilter")]) + OriginFilter = make_tuple("OriginFilter", ["iroha_data_model.account.Id"]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/execute_trigger/__init__.py b/iroha2/sys/iroha_data_model/events/execute_trigger/__init__.py index e7d024c2..f6bc8f23 100644 --- a/iroha2/sys/iroha_data_model/events/execute_trigger/__init__.py +++ b/iroha2/sys/iroha_data_model/events/execute_trigger/__init__.py @@ -1,5 +1,9 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Event = make_struct("Event", [("trigger_id", "iroha_data_model.trigger.Id"), ("authority", "iroha_data_model.account.Id")]) EventFilter = make_struct("EventFilter", [("trigger_id", "iroha_data_model.trigger.Id"), ("authority", "iroha_data_model.account.Id")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/pipeline/__init__.py b/iroha2/sys/iroha_data_model/events/pipeline/__init__.py index f056ef26..0f273d9b 100644 --- a/iroha2/sys/iroha_data_model/events/pipeline/__init__.py +++ b/iroha2/sys/iroha_data_model/events/pipeline/__init__.py @@ -1,8 +1,15 @@ -from ....rust import Enum, make_struct, make_tuple, Dict -EntityKind = Enum[("Block", type(None)), ("Transaction", type(None))] + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +EntityKind = make_enum("EntityKind", [("Block", get_class(type(None))), ("Transaction", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None))]) + Event = make_struct("Event", [("entity_kind", "iroha_data_model.events.pipeline.EntityKind"), ("status", "iroha_data_model.events.pipeline.Status"), ("hash", "iroha_crypto.hash.Hash")]) EventFilter = make_struct("EventFilter", [("entity_kind", "iroha_data_model.events.pipeline.EntityKind"), ("status_kind", "iroha_data_model.events.pipeline.StatusKind"), ("hash", "iroha_crypto.hash.Hash")]) -Status = Enum[("Validating", type(None)), ("Rejected", "iroha_data_model.transaction.RejectionReason"), ("Committed", type(None))] -StatusKind = Enum[("Validating", type(None)), ("Rejected", type(None)), ("Committed", type(None))] +Status = make_enum("Status", [("Validating", get_class(type(None))), ("Rejected", get_class("iroha_data_model.transaction.RejectionReason")), ("Committed", get_class(type(None)))], typing.Union[get_class(type(None)), get_class("iroha_data_model.transaction.RejectionReason"), get_class(type(None))]) + +StatusKind = make_enum("StatusKind", [("Validating", get_class(type(None))), ("Rejected", get_class(type(None))), ("Committed", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None))]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/events/time/__init__.py b/iroha2/sys/iroha_data_model/events/time/__init__.py index 4ff627cc..f9bed625 100644 --- a/iroha2/sys/iroha_data_model/events/time/__init__.py +++ b/iroha2/sys/iroha_data_model/events/time/__init__.py @@ -1,9 +1,14 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Event = make_struct("Event", [("prev_interval", "iroha_data_model.events.time.Interval"), ("interval", "iroha_data_model.events.time.Interval")]) EventFilter = make_tuple("EventFilter", ["iroha_data_model.events.time.ExecutionTime"]) -ExecutionTime = Enum[("PreCommit", type(None)), ("Schedule", "iroha_data_model.events.time.Schedule")] +ExecutionTime = make_enum("ExecutionTime", [("PreCommit", get_class(type(None))), ("Schedule", get_class("iroha_data_model.events.time.Schedule"))], typing.Union[get_class(type(None)), get_class("iroha_data_model.events.time.Schedule")]) + Interval = make_struct("Interval", [("since", "Duration"), ("length", "Duration")]) Schedule = make_struct("Schedule", [("start", "Duration"), ("period", "Duration")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/expression/__init__.py b/iroha2/sys/iroha_data_model/expression/__init__.py index 23ede7e3..b906d111 100644 --- a/iroha2/sys/iroha_data_model/expression/__init__.py +++ b/iroha2/sys/iroha_data_model/expression/__init__.py @@ -1,4 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Add = make_struct("Add", [("left", "iroha_data_model.expression.EvaluatesTo"), ("right", "iroha_data_model.expression.EvaluatesTo")]) And = make_struct("And", [("left", "iroha_data_model.expression.EvaluatesTo"), ("right", "iroha_data_model.expression.EvaluatesTo")]) @@ -9,7 +12,7 @@ ContainsAny = make_struct("ContainsAny", [("collection", "iroha_data_model.expression.EvaluatesTo"), ("elements", "iroha_data_model.expression.EvaluatesTo")]) -ContextValue = make_struct("ContextValue", [("value_name", str)]) +ContextValue = make_struct("ContextValue", [("value_name", "iroha_data_model.name.Name")]) Divide = make_struct("Divide", [("left", "iroha_data_model.expression.EvaluatesTo"), ("right", "iroha_data_model.expression.EvaluatesTo")]) @@ -17,7 +20,8 @@ EvaluatesTo = make_struct("EvaluatesTo", [("expression", "iroha_data_model.expression.Expression")]) -Expression = Enum[("Add", "iroha_data_model.expression.Add"), ("Subtract", "iroha_data_model.expression.Subtract"), ("Multiply", "iroha_data_model.expression.Multiply"), ("Divide", "iroha_data_model.expression.Divide"), ("Mod", "iroha_data_model.expression.Mod"), ("RaiseTo", "iroha_data_model.expression.RaiseTo"), ("Greater", "iroha_data_model.expression.Greater"), ("Less", "iroha_data_model.expression.Less"), ("Equal", "iroha_data_model.expression.Equal"), ("Not", "iroha_data_model.expression.Not"), ("And", "iroha_data_model.expression.And"), ("Or", "iroha_data_model.expression.Or"), ("If", "iroha_data_model.expression.If"), ("Raw", "iroha_data_model.Value"), ("Query", "iroha_data_model.query.QueryBox"), ("Contains", "iroha_data_model.expression.Contains"), ("ContainsAll", "iroha_data_model.expression.ContainsAll"), ("ContainsAny", "iroha_data_model.expression.ContainsAny"), ("Where", "iroha_data_model.expression.Where"), ("ContextValue", "iroha_data_model.expression.ContextValue")] +Expression = make_enum("Expression", [("Add", get_class("iroha_data_model.expression.Add")), ("Subtract", get_class("iroha_data_model.expression.Subtract")), ("Multiply", get_class("iroha_data_model.expression.Multiply")), ("Divide", get_class("iroha_data_model.expression.Divide")), ("Mod", get_class("iroha_data_model.expression.Mod")), ("RaiseTo", get_class("iroha_data_model.expression.RaiseTo")), ("Greater", get_class("iroha_data_model.expression.Greater")), ("Less", get_class("iroha_data_model.expression.Less")), ("Equal", get_class("iroha_data_model.expression.Equal")), ("Not", get_class("iroha_data_model.expression.Not")), ("And", get_class("iroha_data_model.expression.And")), ("Or", get_class("iroha_data_model.expression.Or")), ("If", get_class("iroha_data_model.expression.If")), ("Raw", get_class("iroha_data_model.Value")), ("Query", get_class("iroha_data_model.query.QueryBox")), ("Contains", get_class("iroha_data_model.expression.Contains")), ("ContainsAll", get_class("iroha_data_model.expression.ContainsAll")), ("ContainsAny", get_class("iroha_data_model.expression.ContainsAny")), ("Where", get_class("iroha_data_model.expression.Where")), ("ContextValue", get_class("iroha_data_model.expression.ContextValue"))], typing.Union[get_class("iroha_data_model.expression.Add"), get_class("iroha_data_model.expression.Subtract"), get_class("iroha_data_model.expression.Multiply"), get_class("iroha_data_model.expression.Divide"), get_class("iroha_data_model.expression.Mod"), get_class("iroha_data_model.expression.RaiseTo"), get_class("iroha_data_model.expression.Greater"), get_class("iroha_data_model.expression.Less"), get_class("iroha_data_model.expression.Equal"), get_class("iroha_data_model.expression.Not"), get_class("iroha_data_model.expression.And"), get_class("iroha_data_model.expression.Or"), get_class("iroha_data_model.expression.If"), get_class("iroha_data_model.Value"), get_class("iroha_data_model.query.QueryBox"), get_class("iroha_data_model.expression.Contains"), get_class("iroha_data_model.expression.ContainsAll"), get_class("iroha_data_model.expression.ContainsAny"), get_class("iroha_data_model.expression.Where"), get_class("iroha_data_model.expression.ContextValue")]) + Greater = make_struct("Greater", [("left", "iroha_data_model.expression.EvaluatesTo"), ("right", "iroha_data_model.expression.EvaluatesTo")]) If = make_struct("If", [("condition", "iroha_data_model.expression.EvaluatesTo"), ("then_expression", "iroha_data_model.expression.EvaluatesTo"), ("else_expression", "iroha_data_model.expression.EvaluatesTo")]) @@ -38,3 +42,4 @@ Where = make_struct("Where", [("expression", "iroha_data_model.expression.EvaluatesTo"), ("values", Dict)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/isi/__init__.py b/iroha2/sys/iroha_data_model/isi/__init__.py index 7e00f894..217cda2f 100644 --- a/iroha2/sys/iroha_data_model/isi/__init__.py +++ b/iroha2/sys/iroha_data_model/isi/__init__.py @@ -1,4 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + BurnBox = make_struct("BurnBox", [("object", "iroha_data_model.expression.EvaluatesTo"), ("destination_id", "iroha_data_model.expression.EvaluatesTo")]) ExecuteTriggerBox = make_struct("ExecuteTriggerBox", [("trigger_id", "iroha_data_model.trigger.Id")]) @@ -9,7 +12,8 @@ If = make_struct("If", [("condition", "iroha_data_model.expression.EvaluatesTo"), ("then", "iroha_data_model.isi.Instruction"), ("otherwise", "iroha_data_model.isi.Instruction")]) -Instruction = Enum[("Register", "iroha_data_model.isi.RegisterBox"), ("Unregister", "iroha_data_model.isi.UnregisterBox"), ("Mint", "iroha_data_model.isi.MintBox"), ("Burn", "iroha_data_model.isi.BurnBox"), ("Transfer", "iroha_data_model.isi.TransferBox"), ("If", "iroha_data_model.isi.If"), ("Pair", "iroha_data_model.isi.Pair"), ("Sequence", "iroha_data_model.isi.SequenceBox"), ("Fail", "iroha_data_model.isi.FailBox"), ("SetKeyValue", "iroha_data_model.isi.SetKeyValueBox"), ("RemoveKeyValue", "iroha_data_model.isi.RemoveKeyValueBox"), ("Grant", "iroha_data_model.isi.GrantBox"), ("Revoke", "iroha_data_model.isi.RevokeBox"), ("ExecuteTrigger", "iroha_data_model.isi.ExecuteTriggerBox")] +Instruction = make_enum("Instruction", [("Register", get_class("iroha_data_model.isi.RegisterBox")), ("Unregister", get_class("iroha_data_model.isi.UnregisterBox")), ("Mint", get_class("iroha_data_model.isi.MintBox")), ("Burn", get_class("iroha_data_model.isi.BurnBox")), ("Transfer", get_class("iroha_data_model.isi.TransferBox")), ("If", get_class("iroha_data_model.isi.If")), ("Pair", get_class("iroha_data_model.isi.Pair")), ("Sequence", get_class("iroha_data_model.isi.SequenceBox")), ("Fail", get_class("iroha_data_model.isi.FailBox")), ("SetKeyValue", get_class("iroha_data_model.isi.SetKeyValueBox")), ("RemoveKeyValue", get_class("iroha_data_model.isi.RemoveKeyValueBox")), ("Grant", get_class("iroha_data_model.isi.GrantBox")), ("Revoke", get_class("iroha_data_model.isi.RevokeBox")), ("ExecuteTrigger", get_class("iroha_data_model.isi.ExecuteTriggerBox"))], typing.Union[get_class("iroha_data_model.isi.RegisterBox"), get_class("iroha_data_model.isi.UnregisterBox"), get_class("iroha_data_model.isi.MintBox"), get_class("iroha_data_model.isi.BurnBox"), get_class("iroha_data_model.isi.TransferBox"), get_class("iroha_data_model.isi.If"), get_class("iroha_data_model.isi.Pair"), get_class("iroha_data_model.isi.SequenceBox"), get_class("iroha_data_model.isi.FailBox"), get_class("iroha_data_model.isi.SetKeyValueBox"), get_class("iroha_data_model.isi.RemoveKeyValueBox"), get_class("iroha_data_model.isi.GrantBox"), get_class("iroha_data_model.isi.RevokeBox"), get_class("iroha_data_model.isi.ExecuteTriggerBox")]) + MintBox = make_struct("MintBox", [("object", "iroha_data_model.expression.EvaluatesTo"), ("destination_id", "iroha_data_model.expression.EvaluatesTo")]) Pair = make_struct("Pair", [("left_instruction", "iroha_data_model.isi.Instruction"), ("right_instruction", "iroha_data_model.isi.Instruction")]) @@ -28,3 +32,4 @@ UnregisterBox = make_struct("UnregisterBox", [("object_id", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/metadata/__init__.py b/iroha2/sys/iroha_data_model/metadata/__init__.py index 54b58fda..3f5b4fd3 100644 --- a/iroha2/sys/iroha_data_model/metadata/__init__.py +++ b/iroha2/sys/iroha_data_model/metadata/__init__.py @@ -1,3 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Metadata = make_struct("Metadata", [("map", Dict)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/name/__init__.py b/iroha2/sys/iroha_data_model/name/__init__.py index 99128ede..798ddf13 100644 --- a/iroha2/sys/iroha_data_model/name/__init__.py +++ b/iroha2/sys/iroha_data_model/name/__init__.py @@ -1,2 +1,6 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Name = make_tuple("Name", [str]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/pagination/__init__.py b/iroha2/sys/iroha_data_model/pagination/__init__.py index 31ebd452..d16f709c 100644 --- a/iroha2/sys/iroha_data_model/pagination/__init__.py +++ b/iroha2/sys/iroha_data_model/pagination/__init__.py @@ -1,3 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Pagination = make_struct("Pagination", [("start", int), ("limit", int)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/peer/__init__.py b/iroha2/sys/iroha_data_model/peer/__init__.py index bcae6dce..020f2cf6 100644 --- a/iroha2/sys/iroha_data_model/peer/__init__.py +++ b/iroha2/sys/iroha_data_model/peer/__init__.py @@ -1,5 +1,9 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Id = make_struct("Id", [("address", str), ("public_key", "iroha_crypto.PublicKey")]) Peer = make_struct("Peer", [("id", "iroha_data_model.peer.Id")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/permission/__init__.py b/iroha2/sys/iroha_data_model/permission/__init__.py new file mode 100644 index 00000000..484bd865 --- /dev/null +++ b/iroha2/sys/iroha_data_model/permission/__init__.py @@ -0,0 +1,5 @@ + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/permission/token/__init__.py b/iroha2/sys/iroha_data_model/permission/token/__init__.py new file mode 100644 index 00000000..1e10565e --- /dev/null +++ b/iroha2/sys/iroha_data_model/permission/token/__init__.py @@ -0,0 +1,11 @@ + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Definition = make_struct("Definition", [("id", "iroha_data_model.permission.token.Id"), ("params", Dict)]) + +Id = make_struct("Id", [("name", "iroha_data_model.name.Name")]) + +Token = make_struct("Token", [("definition_id", "iroha_data_model.permission.token.Id"), ("params", Dict)]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/permission/validator/__init__.py b/iroha2/sys/iroha_data_model/permission/validator/__init__.py new file mode 100644 index 00000000..9fd3fb1d --- /dev/null +++ b/iroha2/sys/iroha_data_model/permission/validator/__init__.py @@ -0,0 +1,11 @@ + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Id = make_struct("Id", [("name", "iroha_data_model.name.Name"), ("account_id", "iroha_data_model.account.Id")]) + +Type = make_enum("Type", [("Transaction", get_class(type(None))), ("Instruction", get_class(type(None))), ("Query", get_class(type(None))), ("Expression", get_class(type(None)))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None))]) + +Validator = make_struct("Validator", [("id", "iroha_data_model.permission.validator.Id"), ("validator_type", "iroha_data_model.permission.validator.Type"), ("wasm", "iroha_data_model.transaction.WasmSmartContract")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/permissions/__init__.py b/iroha2/sys/iroha_data_model/permissions/__init__.py index 34134aa4..7923ce26 100644 --- a/iroha2/sys/iroha_data_model/permissions/__init__.py +++ b/iroha2/sys/iroha_data_model/permissions/__init__.py @@ -1,4 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, Dict, get_class +import typing + Id = make_struct("Id", [("name", "iroha_data_model.name.Name")]) PermissionToken = make_struct("PermissionToken", [("definition_id", "iroha_data_model.permissions.Id"), ("params", Dict)]) diff --git a/iroha2/sys/iroha_data_model/predicate/__init__.py b/iroha2/sys/iroha_data_model/predicate/__init__.py index c59430f6..93ce5c30 100644 --- a/iroha2/sys/iroha_data_model/predicate/__init__.py +++ b/iroha2/sys/iroha_data_model/predicate/__init__.py @@ -1,2 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -PredicateBox = Enum[("And", list), ("Or", list), ("Not", "iroha_data_model.predicate.PredicateBox"), ("Raw", "iroha_data_model.predicate.value.Predicate")] + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +GenericPredicateBox = make_enum("GenericPredicateBox", [("And", get_class("iroha_data_model.predicate.nontrivial.NonTrivial")), ("Or", get_class("iroha_data_model.predicate.nontrivial.NonTrivial")), ("Not", get_class("iroha_data_model.predicate.GenericPredicateBox")), ("Raw", get_class("iroha_data_model.predicate.value.Predicate"))], typing.Union[get_class("iroha_data_model.predicate.nontrivial.NonTrivial"), get_class("iroha_data_model.predicate.nontrivial.NonTrivial"), get_class("iroha_data_model.predicate.GenericPredicateBox"), get_class("iroha_data_model.predicate.value.Predicate")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/predicate/ip_addr/__init__.py b/iroha2/sys/iroha_data_model/predicate/ip_addr/__init__.py index e5fddca9..5da657d6 100644 --- a/iroha2/sys/iroha_data_model/predicate/ip_addr/__init__.py +++ b/iroha2/sys/iroha_data_model/predicate/ip_addr/__init__.py @@ -1,3 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Ipv4Predicate = make_tuple("Ipv4Predicate", [list]) Ipv6Predicate = make_tuple("Ipv6Predicate", [list]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/predicate/nontrivial/__init__.py b/iroha2/sys/iroha_data_model/predicate/nontrivial/__init__.py new file mode 100644 index 00000000..00d9d710 --- /dev/null +++ b/iroha2/sys/iroha_data_model/predicate/nontrivial/__init__.py @@ -0,0 +1,6 @@ + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +NonTrivial = make_tuple("NonTrivial", [list]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/predicate/numerical/__init__.py b/iroha2/sys/iroha_data_model/predicate/numerical/__init__.py index 5f7c1ce5..43bd30c8 100644 --- a/iroha2/sys/iroha_data_model/predicate/numerical/__init__.py +++ b/iroha2/sys/iroha_data_model/predicate/numerical/__init__.py @@ -1,6 +1,11 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Interval = make_struct("Interval", [("start", int), ("limit", int)]) SemiInterval = make_struct("SemiInterval", [("start", "iroha_primitives.fixed.Fixed"), ("limit", "iroha_primitives.fixed.Fixed")]) -SemiRange = Enum[("U32", "iroha_data_model.predicate.numerical.SemiInterval"), ("U128", "iroha_data_model.predicate.numerical.SemiInterval"), ("Fixed", "iroha_data_model.predicate.numerical.SemiInterval")] +SemiRange = make_enum("SemiRange", [("U32", get_class("iroha_data_model.predicate.numerical.SemiInterval")), ("U128", get_class("iroha_data_model.predicate.numerical.SemiInterval")), ("Fixed", get_class("iroha_data_model.predicate.numerical.SemiInterval"))], typing.Union[get_class("iroha_data_model.predicate.numerical.SemiInterval"), get_class("iroha_data_model.predicate.numerical.SemiInterval"), get_class("iroha_data_model.predicate.numerical.SemiInterval")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/predicate/string/__init__.py b/iroha2/sys/iroha_data_model/predicate/string/__init__.py index b9a5f021..e65490d3 100644 --- a/iroha2/sys/iroha_data_model/predicate/string/__init__.py +++ b/iroha2/sys/iroha_data_model/predicate/string/__init__.py @@ -1,2 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict -Predicate = Enum[("Contains", str), ("StartsWith", str), ("EndsWith", str), ("Is", str)] + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Predicate = make_enum("Predicate", [("Contains", get_class(str)), ("StartsWith", get_class(str)), ("EndsWith", get_class(str)), ("Is", get_class(str))], typing.Union[get_class(str), get_class(str), get_class(str), get_class(str)]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/predicate/value/__init__.py b/iroha2/sys/iroha_data_model/predicate/value/__init__.py index c2a61073..43ab8580 100644 --- a/iroha2/sys/iroha_data_model/predicate/value/__init__.py +++ b/iroha2/sys/iroha_data_model/predicate/value/__init__.py @@ -1,7 +1,13 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + AtIndex = make_struct("AtIndex", [("index", int), ("predicate", "iroha_data_model.predicate.value.Predicate")]) -Container = Enum[("Any", "iroha_data_model.predicate.value.Predicate"), ("All", "iroha_data_model.predicate.value.Predicate"), ("AtIndex", "iroha_data_model.predicate.value.AtIndex"), ("ValueOfKey", "iroha_data_model.predicate.value.ValueOfKey"), ("HasKey", "iroha_data_model.name.Name")] -Predicate = Enum[("Identifiable", "iroha_data_model.predicate.string.Predicate"), ("Container", "iroha_data_model.predicate.value.Container"), ("Display", "iroha_data_model.predicate.string.Predicate"), ("Numerical", "iroha_data_model.predicate.numerical.SemiRange"), ("TimeStamp", "iroha_data_model.predicate.numerical.SemiInterval"), ("Ipv4Addr", "iroha_data_model.predicate.ip_addr.Ipv4Predicate"), ("Ipv6Addr", "iroha_data_model.predicate.ip_addr.Ipv6Predicate"), ("Pass", type(None))] +Container = make_enum("Container", [("Any", get_class("iroha_data_model.predicate.value.Predicate")), ("All", get_class("iroha_data_model.predicate.value.Predicate")), ("AtIndex", get_class("iroha_data_model.predicate.value.AtIndex")), ("ValueOfKey", get_class("iroha_data_model.predicate.value.ValueOfKey")), ("HasKey", get_class("iroha_data_model.name.Name"))], typing.Union[get_class("iroha_data_model.predicate.value.Predicate"), get_class("iroha_data_model.predicate.value.Predicate"), get_class("iroha_data_model.predicate.value.AtIndex"), get_class("iroha_data_model.predicate.value.ValueOfKey"), get_class("iroha_data_model.name.Name")]) + +Predicate = make_enum("Predicate", [("Identifiable", get_class("iroha_data_model.predicate.string.Predicate")), ("Container", get_class("iroha_data_model.predicate.value.Container")), ("Display", get_class("iroha_data_model.predicate.string.Predicate")), ("Numerical", get_class("iroha_data_model.predicate.numerical.SemiRange")), ("TimeStamp", get_class("iroha_data_model.predicate.numerical.SemiInterval")), ("Ipv4Addr", get_class("iroha_data_model.predicate.ip_addr.Ipv4Predicate")), ("Ipv6Addr", get_class("iroha_data_model.predicate.ip_addr.Ipv6Predicate")), ("Pass", get_class(type(None)))], typing.Union[get_class("iroha_data_model.predicate.string.Predicate"), get_class("iroha_data_model.predicate.value.Container"), get_class("iroha_data_model.predicate.string.Predicate"), get_class("iroha_data_model.predicate.numerical.SemiRange"), get_class("iroha_data_model.predicate.numerical.SemiInterval"), get_class("iroha_data_model.predicate.ip_addr.Ipv4Predicate"), get_class("iroha_data_model.predicate.ip_addr.Ipv6Predicate"), get_class(type(None))]) + ValueOfKey = make_struct("ValueOfKey", [("key", "iroha_data_model.name.Name"), ("predicate", "iroha_data_model.predicate.value.Predicate")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/__init__.py b/iroha2/sys/iroha_data_model/query/__init__.py index e8ce48f5..4743a753 100644 --- a/iroha2/sys/iroha_data_model/query/__init__.py +++ b/iroha2/sys/iroha_data_model/query/__init__.py @@ -1,11 +1,18 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -PaginatedQueryResult = make_struct("PaginatedQueryResult", [("result", "iroha_data_model.query.QueryResult"), ("filter", "iroha_data_model.predicate.PredicateBox"), ("pagination", "iroha_data_model.pagination.Pagination"), ("total", int)]) -Payload = make_struct("Payload", [("timestamp_ms", "Compact"), ("query", "iroha_data_model.query.QueryBox"), ("account_id", "iroha_data_model.account.Id"), ("filter", "iroha_data_model.predicate.PredicateBox")]) +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +PaginatedQueryResult = make_struct("PaginatedQueryResult", [("result", "iroha_data_model.query.QueryResult"), ("filter", "iroha_data_model.predicate.GenericPredicateBox"), ("pagination", "iroha_data_model.pagination.Pagination"), ("sorting", "iroha_data_model.sorting.Sorting"), ("total", int)]) + +Payload = make_struct("Payload", [("timestamp_ms", "Compact"), ("query", "iroha_data_model.query.QueryBox"), ("account_id", "iroha_data_model.account.Id"), ("filter", "iroha_data_model.predicate.GenericPredicateBox")]) + +QueryBox = make_enum("QueryBox", [("FindAllAccounts", get_class("iroha_data_model.query.account.FindAllAccounts")), ("FindAccountById", get_class("iroha_data_model.query.account.FindAccountById")), ("FindAccountKeyValueByIdAndKey", get_class("iroha_data_model.query.account.FindAccountKeyValueByIdAndKey")), ("FindAccountsByName", get_class("iroha_data_model.query.account.FindAccountsByName")), ("FindAccountsByDomainId", get_class("iroha_data_model.query.account.FindAccountsByDomainId")), ("FindAccountsWithAsset", get_class("iroha_data_model.query.account.FindAccountsWithAsset")), ("FindAllAssets", get_class("iroha_data_model.query.asset.FindAllAssets")), ("FindAllAssetsDefinitions", get_class("iroha_data_model.query.asset.FindAllAssetsDefinitions")), ("FindAssetById", get_class("iroha_data_model.query.asset.FindAssetById")), ("FindAssetDefinitionById", get_class("iroha_data_model.query.asset.FindAssetDefinitionById")), ("FindAssetsByName", get_class("iroha_data_model.query.asset.FindAssetsByName")), ("FindAssetsByAccountId", get_class("iroha_data_model.query.asset.FindAssetsByAccountId")), ("FindAssetsByAssetDefinitionId", get_class("iroha_data_model.query.asset.FindAssetsByAssetDefinitionId")), ("FindAssetsByDomainId", get_class("iroha_data_model.query.asset.FindAssetsByDomainId")), ("FindAssetsByDomainIdAndAssetDefinitionId", get_class("iroha_data_model.query.asset.FindAssetsByDomainIdAndAssetDefinitionId")), ("FindAssetQuantityById", get_class("iroha_data_model.query.asset.FindAssetQuantityById")), ("FindTotalAssetQuantityByAssetDefinitionId", get_class("iroha_data_model.query.asset.FindTotalAssetQuantityByAssetDefinitionId")), ("FindAssetKeyValueByIdAndKey", get_class("iroha_data_model.query.asset.FindAssetKeyValueByIdAndKey")), ("FindAssetDefinitionKeyValueByIdAndKey", get_class("iroha_data_model.query.asset.FindAssetDefinitionKeyValueByIdAndKey")), ("FindAllDomains", get_class("iroha_data_model.query.domain.FindAllDomains")), ("FindDomainById", get_class("iroha_data_model.query.domain.FindDomainById")), ("FindDomainKeyValueByIdAndKey", get_class("iroha_data_model.query.domain.FindDomainKeyValueByIdAndKey")), ("FindAllPeers", get_class("iroha_data_model.query.peer.FindAllPeers")), ("FindAllBlocks", get_class("iroha_data_model.query.block.FindAllBlocks")), ("FindAllBlockHeaders", get_class("iroha_data_model.query.block.FindAllBlockHeaders")), ("FindBlockHeaderByHash", get_class("iroha_data_model.query.block.FindBlockHeaderByHash")), ("FindAllTransactions", get_class("iroha_data_model.query.transaction.FindAllTransactions")), ("FindTransactionsByAccountId", get_class("iroha_data_model.query.transaction.FindTransactionsByAccountId")), ("FindTransactionByHash", get_class("iroha_data_model.query.transaction.FindTransactionByHash")), ("FindPermissionTokensByAccountId", get_class("iroha_data_model.query.permissions.FindPermissionTokensByAccountId")), ("FindAllPermissionTokenDefinitions", get_class("iroha_data_model.query.permissions.FindAllPermissionTokenDefinitions")), ("FindAllActiveTriggerIds", get_class("iroha_data_model.query.trigger.FindAllActiveTriggerIds")), ("FindTriggerById", get_class("iroha_data_model.query.trigger.FindTriggerById")), ("FindTriggerKeyValueByIdAndKey", get_class("iroha_data_model.query.trigger.FindTriggerKeyValueByIdAndKey")), ("FindTriggersByDomainId", get_class("iroha_data_model.query.trigger.FindTriggersByDomainId")), ("FindAllRoles", get_class("iroha_data_model.query.role.FindAllRoles")), ("FindAllRoleIds", get_class("iroha_data_model.query.role.FindAllRoleIds")), ("FindRoleByRoleId", get_class("iroha_data_model.query.role.FindRoleByRoleId")), ("FindRolesByAccountId", get_class("iroha_data_model.query.role.FindRolesByAccountId"))], typing.Union[get_class("iroha_data_model.query.account.FindAllAccounts"), get_class("iroha_data_model.query.account.FindAccountById"), get_class("iroha_data_model.query.account.FindAccountKeyValueByIdAndKey"), get_class("iroha_data_model.query.account.FindAccountsByName"), get_class("iroha_data_model.query.account.FindAccountsByDomainId"), get_class("iroha_data_model.query.account.FindAccountsWithAsset"), get_class("iroha_data_model.query.asset.FindAllAssets"), get_class("iroha_data_model.query.asset.FindAllAssetsDefinitions"), get_class("iroha_data_model.query.asset.FindAssetById"), get_class("iroha_data_model.query.asset.FindAssetDefinitionById"), get_class("iroha_data_model.query.asset.FindAssetsByName"), get_class("iroha_data_model.query.asset.FindAssetsByAccountId"), get_class("iroha_data_model.query.asset.FindAssetsByAssetDefinitionId"), get_class("iroha_data_model.query.asset.FindAssetsByDomainId"), get_class("iroha_data_model.query.asset.FindAssetsByDomainIdAndAssetDefinitionId"), get_class("iroha_data_model.query.asset.FindAssetQuantityById"), get_class("iroha_data_model.query.asset.FindTotalAssetQuantityByAssetDefinitionId"), get_class("iroha_data_model.query.asset.FindAssetKeyValueByIdAndKey"), get_class("iroha_data_model.query.asset.FindAssetDefinitionKeyValueByIdAndKey"), get_class("iroha_data_model.query.domain.FindAllDomains"), get_class("iroha_data_model.query.domain.FindDomainById"), get_class("iroha_data_model.query.domain.FindDomainKeyValueByIdAndKey"), get_class("iroha_data_model.query.peer.FindAllPeers"), get_class("iroha_data_model.query.block.FindAllBlocks"), get_class("iroha_data_model.query.block.FindAllBlockHeaders"), get_class("iroha_data_model.query.block.FindBlockHeaderByHash"), get_class("iroha_data_model.query.transaction.FindAllTransactions"), get_class("iroha_data_model.query.transaction.FindTransactionsByAccountId"), get_class("iroha_data_model.query.transaction.FindTransactionByHash"), get_class("iroha_data_model.query.permissions.FindPermissionTokensByAccountId"), get_class("iroha_data_model.query.permissions.FindAllPermissionTokenDefinitions"), get_class("iroha_data_model.query.trigger.FindAllActiveTriggerIds"), get_class("iroha_data_model.query.trigger.FindTriggerById"), get_class("iroha_data_model.query.trigger.FindTriggerKeyValueByIdAndKey"), get_class("iroha_data_model.query.trigger.FindTriggersByDomainId"), get_class("iroha_data_model.query.role.FindAllRoles"), get_class("iroha_data_model.query.role.FindAllRoleIds"), get_class("iroha_data_model.query.role.FindRoleByRoleId"), get_class("iroha_data_model.query.role.FindRolesByAccountId")]) -QueryBox = Enum[("FindAllAccounts", "iroha_data_model.query.account.FindAllAccounts"), ("FindAccountById", "iroha_data_model.query.account.FindAccountById"), ("FindAccountKeyValueByIdAndKey", "iroha_data_model.query.account.FindAccountKeyValueByIdAndKey"), ("FindAccountsByName", "iroha_data_model.query.account.FindAccountsByName"), ("FindAccountsByDomainId", "iroha_data_model.query.account.FindAccountsByDomainId"), ("FindAccountsWithAsset", "iroha_data_model.query.account.FindAccountsWithAsset"), ("FindAllAssets", "iroha_data_model.query.asset.FindAllAssets"), ("FindAllAssetsDefinitions", "iroha_data_model.query.asset.FindAllAssetsDefinitions"), ("FindAssetById", "iroha_data_model.query.asset.FindAssetById"), ("FindAssetDefinitionById", "iroha_data_model.query.asset.FindAssetDefinitionById"), ("FindAssetsByName", "iroha_data_model.query.asset.FindAssetsByName"), ("FindAssetsByAccountId", "iroha_data_model.query.asset.FindAssetsByAccountId"), ("FindAssetsByAssetDefinitionId", "iroha_data_model.query.asset.FindAssetsByAssetDefinitionId"), ("FindAssetsByDomainId", "iroha_data_model.query.asset.FindAssetsByDomainId"), ("FindAssetsByDomainIdAndAssetDefinitionId", "iroha_data_model.query.asset.FindAssetsByDomainIdAndAssetDefinitionId"), ("FindAssetQuantityById", "iroha_data_model.query.asset.FindAssetQuantityById"), ("FindAssetKeyValueByIdAndKey", "iroha_data_model.query.asset.FindAssetKeyValueByIdAndKey"), ("FindAssetDefinitionKeyValueByIdAndKey", "iroha_data_model.query.asset.FindAssetDefinitionKeyValueByIdAndKey"), ("FindAllDomains", "iroha_data_model.query.domain.FindAllDomains"), ("FindDomainById", "iroha_data_model.query.domain.FindDomainById"), ("FindDomainKeyValueByIdAndKey", "iroha_data_model.query.domain.FindDomainKeyValueByIdAndKey"), ("FindAllPeers", "iroha_data_model.query.peer.FindAllPeers"), ("FindAllBlocks", "iroha_data_model.query.block.FindAllBlocks"), ("FindAllBlockHeaders", "iroha_data_model.query.block.FindAllBlockHeaders"), ("FindBlockHeaderByHash", "iroha_data_model.query.block.FindBlockHeaderByHash"), ("FindAllTransactions", "iroha_data_model.query.transaction.FindAllTransactions"), ("FindTransactionsByAccountId", "iroha_data_model.query.transaction.FindTransactionsByAccountId"), ("FindTransactionByHash", "iroha_data_model.query.transaction.FindTransactionByHash"), ("FindPermissionTokensByAccountId", "iroha_data_model.query.permissions.FindPermissionTokensByAccountId"), ("FindAllPermissionTokenDefinitions", "iroha_data_model.query.permissions.FindAllPermissionTokenDefinitions"), ("FindAllActiveTriggerIds", "iroha_data_model.query.trigger.FindAllActiveTriggerIds"), ("FindTriggerById", "iroha_data_model.query.trigger.FindTriggerById"), ("FindTriggerKeyValueByIdAndKey", "iroha_data_model.query.trigger.FindTriggerKeyValueByIdAndKey"), ("FindTriggersByDomainId", "iroha_data_model.query.trigger.FindTriggersByDomainId"), ("FindAllRoles", "iroha_data_model.query.role.FindAllRoles"), ("FindAllRoleIds", "iroha_data_model.query.role.FindAllRoleIds"), ("FindRoleByRoleId", "iroha_data_model.query.role.FindRoleByRoleId"), ("FindRolesByAccountId", "iroha_data_model.query.role.FindRolesByAccountId")] QueryResult = make_tuple("QueryResult", ["iroha_data_model.Value"]) SignedQueryRequest = make_struct("SignedQueryRequest", [("payload", "iroha_data_model.query.Payload"), ("signature", "iroha_crypto.signature.SignatureOf")]) -VersionedPaginatedQueryResult = Enum[("V1", "iroha_data_model.query.PaginatedQueryResult")] -VersionedSignedQueryRequest = Enum[("V1", "iroha_data_model.query.SignedQueryRequest")] +VersionedPaginatedQueryResult = make_enum("VersionedPaginatedQueryResult", [("V1", get_class("iroha_data_model.query.PaginatedQueryResult"))], typing.Union[get_class("iroha_data_model.query.PaginatedQueryResult")]) + +VersionedSignedQueryRequest = make_enum("VersionedSignedQueryRequest", [("V1", get_class("iroha_data_model.query.SignedQueryRequest"))], typing.Union[get_class("iroha_data_model.query.SignedQueryRequest")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/account/__init__.py b/iroha2/sys/iroha_data_model/query/account/__init__.py index 94c8e51b..58a5ecb6 100644 --- a/iroha2/sys/iroha_data_model/query/account/__init__.py +++ b/iroha2/sys/iroha_data_model/query/account/__init__.py @@ -1,4 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAccountById = make_struct("FindAccountById", [("id", "iroha_data_model.expression.EvaluatesTo")]) FindAccountKeyValueByIdAndKey = make_struct("FindAccountKeyValueByIdAndKey", [("id", "iroha_data_model.expression.EvaluatesTo"), ("key", "iroha_data_model.expression.EvaluatesTo")]) @@ -10,3 +13,4 @@ FindAccountsWithAsset = make_struct("FindAccountsWithAsset", [("asset_definition_id", "iroha_data_model.expression.EvaluatesTo")]) FindAllAccounts = make_tuple("FindAllAccounts") +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/asset/__init__.py b/iroha2/sys/iroha_data_model/query/asset/__init__.py index bba305d9..e7c1b89a 100644 --- a/iroha2/sys/iroha_data_model/query/asset/__init__.py +++ b/iroha2/sys/iroha_data_model/query/asset/__init__.py @@ -1,4 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllAssets = make_tuple("FindAllAssets") FindAllAssetsDefinitions = make_tuple("FindAllAssetsDefinitions") FindAssetById = make_struct("FindAssetById", [("id", "iroha_data_model.expression.EvaluatesTo")]) @@ -21,3 +24,6 @@ FindAssetsByName = make_struct("FindAssetsByName", [("name", "iroha_data_model.expression.EvaluatesTo")]) +FindTotalAssetQuantityByAssetDefinitionId = make_struct("FindTotalAssetQuantityByAssetDefinitionId", [("id", "iroha_data_model.expression.EvaluatesTo")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/block/__init__.py b/iroha2/sys/iroha_data_model/query/block/__init__.py index ee8a7044..5dd39931 100644 --- a/iroha2/sys/iroha_data_model/query/block/__init__.py +++ b/iroha2/sys/iroha_data_model/query/block/__init__.py @@ -1,5 +1,9 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllBlockHeaders = make_tuple("FindAllBlockHeaders") FindAllBlocks = make_tuple("FindAllBlocks") FindBlockHeaderByHash = make_struct("FindBlockHeaderByHash", [("hash", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/domain/__init__.py b/iroha2/sys/iroha_data_model/query/domain/__init__.py index d09151b7..49f206c2 100644 --- a/iroha2/sys/iroha_data_model/query/domain/__init__.py +++ b/iroha2/sys/iroha_data_model/query/domain/__init__.py @@ -1,6 +1,10 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllDomains = make_tuple("FindAllDomains") FindDomainById = make_struct("FindDomainById", [("id", "iroha_data_model.expression.EvaluatesTo")]) FindDomainKeyValueByIdAndKey = make_struct("FindDomainKeyValueByIdAndKey", [("id", "iroha_data_model.expression.EvaluatesTo"), ("key", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/peer/__init__.py b/iroha2/sys/iroha_data_model/query/peer/__init__.py index e6b3cfe9..ecb09364 100644 --- a/iroha2/sys/iroha_data_model/query/peer/__init__.py +++ b/iroha2/sys/iroha_data_model/query/peer/__init__.py @@ -1,2 +1,6 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllPeers = make_tuple("FindAllPeers") +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/permissions/__init__.py b/iroha2/sys/iroha_data_model/query/permissions/__init__.py index c858ca25..15bce6c6 100644 --- a/iroha2/sys/iroha_data_model/query/permissions/__init__.py +++ b/iroha2/sys/iroha_data_model/query/permissions/__init__.py @@ -1,4 +1,8 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllPermissionTokenDefinitions = make_tuple("FindAllPermissionTokenDefinitions") FindPermissionTokensByAccountId = make_struct("FindPermissionTokensByAccountId", [("id", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/role/__init__.py b/iroha2/sys/iroha_data_model/query/role/__init__.py index 6ae26ea0..272359e3 100644 --- a/iroha2/sys/iroha_data_model/query/role/__init__.py +++ b/iroha2/sys/iroha_data_model/query/role/__init__.py @@ -1,7 +1,11 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllRoleIds = make_tuple("FindAllRoleIds") FindAllRoles = make_tuple("FindAllRoles") FindRoleByRoleId = make_struct("FindRoleByRoleId", [("id", "iroha_data_model.expression.EvaluatesTo")]) FindRolesByAccountId = make_struct("FindRolesByAccountId", [("id", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/transaction/__init__.py b/iroha2/sys/iroha_data_model/query/transaction/__init__.py index 8b2593eb..8e79a709 100644 --- a/iroha2/sys/iroha_data_model/query/transaction/__init__.py +++ b/iroha2/sys/iroha_data_model/query/transaction/__init__.py @@ -1,6 +1,10 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllTransactions = make_tuple("FindAllTransactions") FindTransactionByHash = make_struct("FindTransactionByHash", [("hash", "iroha_data_model.expression.EvaluatesTo")]) FindTransactionsByAccountId = make_struct("FindTransactionsByAccountId", [("account_id", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/query/trigger/__init__.py b/iroha2/sys/iroha_data_model/query/trigger/__init__.py index 1a60011f..3643c0b5 100644 --- a/iroha2/sys/iroha_data_model/query/trigger/__init__.py +++ b/iroha2/sys/iroha_data_model/query/trigger/__init__.py @@ -1,4 +1,7 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + FindAllActiveTriggerIds = make_tuple("FindAllActiveTriggerIds") FindTriggerById = make_struct("FindTriggerById", [("id", "iroha_data_model.expression.EvaluatesTo")]) @@ -6,3 +9,4 @@ FindTriggersByDomainId = make_struct("FindTriggersByDomainId", [("domain_id", "iroha_data_model.expression.EvaluatesTo")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/role/__init__.py b/iroha2/sys/iroha_data_model/role/__init__.py index 1053fe1b..76e4e940 100644 --- a/iroha2/sys/iroha_data_model/role/__init__.py +++ b/iroha2/sys/iroha_data_model/role/__init__.py @@ -1,7 +1,11 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Id = make_struct("Id", [("name", "iroha_data_model.name.Name")]) NewRole = make_struct("NewRole", [("inner", "iroha_data_model.role.Role")]) Role = make_struct("Role", [("id", "iroha_data_model.role.Id"), ("permissions", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/sorting/__init__.py b/iroha2/sys/iroha_data_model/sorting/__init__.py new file mode 100644 index 00000000..16179f7e --- /dev/null +++ b/iroha2/sys/iroha_data_model/sorting/__init__.py @@ -0,0 +1,7 @@ + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Sorting = make_struct("Sorting", [("sort_by_metadata_key", "iroha_data_model.name.Name")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/transaction/__init__.py b/iroha2/sys/iroha_data_model/transaction/__init__.py index 19a855c6..35c57549 100644 --- a/iroha2/sys/iroha_data_model/transaction/__init__.py +++ b/iroha2/sys/iroha_data_model/transaction/__init__.py @@ -1,6 +1,11 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -BlockRejectionReason = Enum[("ConsensusBlockRejection", type(None))] -Executable = Enum[("Instructions", list), ("Wasm", "iroha_data_model.transaction.WasmSmartContract")] + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +BlockRejectionReason = make_enum("BlockRejectionReason", [("ConsensusBlockRejection", get_class(type(None)))], typing.Union[get_class(type(None))]) + +Executable = make_enum("Executable", [("Instructions", get_class(list)), ("Wasm", get_class("iroha_data_model.transaction.WasmSmartContract"))], typing.Union[get_class(list), get_class("iroha_data_model.transaction.WasmSmartContract")]) + InstructionExecutionFail = make_struct("InstructionExecutionFail", [("instruction", "iroha_data_model.isi.Instruction"), ("reason", str)]) NotPermittedFail = make_struct("NotPermittedFail", [("reason", str)]) @@ -9,22 +14,29 @@ RejectedTransaction = make_struct("RejectedTransaction", [("payload", "iroha_data_model.transaction.Payload"), ("signatures", "iroha_crypto.signature.SignaturesOf"), ("rejection_reason", "iroha_data_model.transaction.TransactionRejectionReason")]) -RejectionReason = Enum[("Block", "iroha_data_model.transaction.BlockRejectionReason"), ("Transaction", "iroha_data_model.transaction.TransactionRejectionReason")] -Transaction = make_struct("Transaction", [("payload", "iroha_data_model.transaction.Payload"), ("signatures", list)]) +RejectionReason = make_enum("RejectionReason", [("Block", get_class("iroha_data_model.transaction.BlockRejectionReason")), ("Transaction", get_class("iroha_data_model.transaction.TransactionRejectionReason"))], typing.Union[get_class("iroha_data_model.transaction.BlockRejectionReason"), get_class("iroha_data_model.transaction.TransactionRejectionReason")]) + +SignedTransaction = make_struct("SignedTransaction", [("payload", "iroha_data_model.transaction.Payload"), ("signatures", list)]) TransactionLimitError = make_tuple("TransactionLimitError", [str]) TransactionQueryResult = make_struct("TransactionQueryResult", [("tx_value", "iroha_data_model.transaction.TransactionValue"), ("block_hash", "iroha_crypto.hash.Hash")]) -TransactionRejectionReason = Enum[("NotPermitted", "iroha_data_model.transaction.NotPermittedFail"), ("UnsatisfiedSignatureCondition", "iroha_data_model.transaction.UnsatisfiedSignatureConditionFail"), ("LimitCheck", "iroha_data_model.transaction.TransactionLimitError"), ("InstructionExecution", "iroha_data_model.transaction.InstructionExecutionFail"), ("WasmExecution", "iroha_data_model.transaction.WasmExecutionFail"), ("UnexpectedGenesisAccountSignature", type(None))] -TransactionValue = Enum[("Transaction", "iroha_data_model.transaction.VersionedTransaction"), ("RejectedTransaction", "iroha_data_model.transaction.VersionedRejectedTransaction")] +TransactionRejectionReason = make_enum("TransactionRejectionReason", [("NotPermitted", get_class("iroha_data_model.transaction.NotPermittedFail")), ("UnsatisfiedSignatureCondition", get_class("iroha_data_model.transaction.UnsatisfiedSignatureConditionFail")), ("LimitCheck", get_class("iroha_data_model.transaction.TransactionLimitError")), ("InstructionExecution", get_class("iroha_data_model.transaction.InstructionExecutionFail")), ("WasmExecution", get_class("iroha_data_model.transaction.WasmExecutionFail")), ("UnexpectedGenesisAccountSignature", get_class(type(None)))], typing.Union[get_class("iroha_data_model.transaction.NotPermittedFail"), get_class("iroha_data_model.transaction.UnsatisfiedSignatureConditionFail"), get_class("iroha_data_model.transaction.TransactionLimitError"), get_class("iroha_data_model.transaction.InstructionExecutionFail"), get_class("iroha_data_model.transaction.WasmExecutionFail"), get_class(type(None))]) + +TransactionValue = make_enum("TransactionValue", [("Transaction", get_class("iroha_data_model.transaction.VersionedSignedTransaction")), ("RejectedTransaction", get_class("iroha_data_model.transaction.VersionedRejectedTransaction"))], typing.Union[get_class("iroha_data_model.transaction.VersionedSignedTransaction"), get_class("iroha_data_model.transaction.VersionedRejectedTransaction")]) + UnsatisfiedSignatureConditionFail = make_struct("UnsatisfiedSignatureConditionFail", [("reason", str)]) ValidTransaction = make_struct("ValidTransaction", [("payload", "iroha_data_model.transaction.Payload"), ("signatures", "iroha_crypto.signature.SignaturesOf")]) -VersionedRejectedTransaction = Enum[("V1", "iroha_data_model.transaction.RejectedTransaction")] -VersionedTransaction = Enum[("V1", "iroha_data_model.transaction.Transaction")] -VersionedValidTransaction = Enum[("V1", "iroha_data_model.transaction.ValidTransaction")] +VersionedRejectedTransaction = make_enum("VersionedRejectedTransaction", [("V1", get_class("iroha_data_model.transaction.RejectedTransaction"))], typing.Union[get_class("iroha_data_model.transaction.RejectedTransaction")]) + +VersionedSignedTransaction = make_enum("VersionedSignedTransaction", [("V1", get_class("iroha_data_model.transaction.SignedTransaction"))], typing.Union[get_class("iroha_data_model.transaction.SignedTransaction")]) + +VersionedValidTransaction = make_enum("VersionedValidTransaction", [("V1", get_class("iroha_data_model.transaction.ValidTransaction"))], typing.Union[get_class("iroha_data_model.transaction.ValidTransaction")]) + WasmExecutionFail = make_struct("WasmExecutionFail", [("reason", str)]) WasmSmartContract = make_struct("WasmSmartContract", [("raw_data", list)]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/trigger/__init__.py b/iroha2/sys/iroha_data_model/trigger/__init__.py index 8d7985c9..b5acf0d9 100644 --- a/iroha2/sys/iroha_data_model/trigger/__init__.py +++ b/iroha2/sys/iroha_data_model/trigger/__init__.py @@ -1,5 +1,9 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Id = make_struct("Id", [("name", "iroha_data_model.name.Name"), ("domain_id", "iroha_data_model.domain.Id")]) Trigger = make_struct("Trigger", [("id", "iroha_data_model.trigger.Id"), ("action", "iroha_data_model.trigger.action.Action")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_data_model/trigger/action/__init__.py b/iroha2/sys/iroha_data_model/trigger/action/__init__.py index e343ad5a..2dca9bb3 100644 --- a/iroha2/sys/iroha_data_model/trigger/action/__init__.py +++ b/iroha2/sys/iroha_data_model/trigger/action/__init__.py @@ -1,4 +1,9 @@ -from ....rust import Enum, make_struct, make_tuple, Dict + +from ....rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Action = make_struct("Action", [("executable", "iroha_data_model.transaction.Executable"), ("repeats", "iroha_data_model.trigger.action.Repeats"), ("technical_account", "iroha_data_model.account.Id"), ("filter", "iroha_data_model.events.FilterBox"), ("metadata", "iroha_data_model.metadata.Metadata")]) -Repeats = Enum[("Indefinitely", type(None)), ("Exactly", "AtomicU32Wrapper")] +Repeats = make_enum("Repeats", [("Indefinitely", get_class(type(None))), ("Exactly", get_class("AtomicU32Wrapper"))], typing.Union[get_class(type(None)), get_class("AtomicU32Wrapper")]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_primitives/__init__.py b/iroha2/sys/iroha_primitives/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/iroha_primitives/__init__.py +++ b/iroha2/sys/iroha_primitives/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_primitives/addr/__init__.py b/iroha2/sys/iroha_primitives/addr/__init__.py index 4d762f11..9b0e4728 100644 --- a/iroha2/sys/iroha_primitives/addr/__init__.py +++ b/iroha2/sys/iroha_primitives/addr/__init__.py @@ -1,3 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Ipv4Addr = make_tuple("Ipv4Addr", [list]) Ipv6Addr = make_tuple("Ipv6Addr", [list]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_primitives/fixed/__init__.py b/iroha2/sys/iroha_primitives/fixed/__init__.py index 20a380f0..585fc6dd 100644 --- a/iroha2/sys/iroha_primitives/fixed/__init__.py +++ b/iroha2/sys/iroha_primitives/fixed/__init__.py @@ -1,2 +1,6 @@ -from ...rust import Enum, make_struct, make_tuple, Dict + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + Fixed = make_tuple("Fixed", [str]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_version/__init__.py b/iroha2/sys/iroha_version/__init__.py index 80c639b3..8b4b7147 100644 --- a/iroha2/sys/iroha_version/__init__.py +++ b/iroha2/sys/iroha_version/__init__.py @@ -1,4 +1,9 @@ -from ..rust import Enum, make_struct, make_tuple, Dict -RawVersioned = Enum[("Json", str), ("ScaleBytes", list)] + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +RawVersioned = make_enum("RawVersioned", [("Json", get_class(str)), ("ScaleBytes", get_class(list))], typing.Union[get_class(str), get_class(list)]) + UnsupportedVersion = make_struct("UnsupportedVersion", [("version", int), ("raw", "iroha_version.RawVersioned")]) +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/iroha_version/error/__init__.py b/iroha2/sys/iroha_version/error/__init__.py index 5b300fc0..dc9d9fe8 100644 --- a/iroha2/sys/iroha_version/error/__init__.py +++ b/iroha2/sys/iroha_version/error/__init__.py @@ -1,2 +1,7 @@ -from ...rust import Enum, make_struct, make_tuple, Dict -Error = Enum[("NotVersioned", type(None)), ("UnsupportedJsonEncode", type(None)), ("ExpectedJson", type(None)), ("UnsupportedScaleEncode", type(None)), ("Serde", type(None)), ("ParityScale", type(None)), ("ParseInt", type(None)), ("UnsupportedVersion", "iroha_version.UnsupportedVersion"), ("ExtraBytesLeft", int)] + +from ...rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +Error = make_enum("Error", [("NotVersioned", get_class(type(None))), ("UnsupportedJsonEncode", get_class(type(None))), ("ExpectedJson", get_class(type(None))), ("UnsupportedScaleEncode", get_class(type(None))), ("Serde", get_class(type(None))), ("ParityScale", get_class(type(None))), ("ParseInt", get_class(type(None))), ("UnsupportedVersion", get_class("iroha_version.UnsupportedVersion")), ("ExtraBytesLeft", get_class(int))], typing.Union[get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class(type(None)), get_class("iroha_version.UnsupportedVersion"), get_class(int)]) + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/rust.py b/iroha2/sys/rust.py index 72c4e44f..8478bb1f 100644 --- a/iroha2/sys/rust.py +++ b/iroha2/sys/rust.py @@ -1,16 +1,76 @@ # Export +import abc from collections.abc import Iterable import typing -from typing import NamedTuple +import types +from typing import NamedTuple, Tuple, Union, TypeVar, Optional +from functools import partial import enum import collections import dataclasses from importlib import import_module from ..iroha2 import Dict, List +import inspect ClassPath = str +def get_caller() -> types.ModuleType: + """ + Returns reference to the calling module + """ + stack = inspect.stack() + for frame_info in stack: + mod = inspect.getmodule(frame_info.frame) + if mod is not None and mod.__name__ != __name__: + return mod + return None + + +class SelfResolvingTypeVar(typing.TypeVar, _root=True): + """ + Hacky workaround type for dependency cycles caused by self-referencing types. + """ + + def evaluate(self): + """ + Evaluate the underlying TypeVar to the actual type. + """ + return self.__bound__._evaluate(self.caller_module.__dict__, globals(), + set()) + + def resolve(self): + """ + Overwrite self with the actual type + """ + self = self.evaluate() + + def __call__(self, args, **kvargs): + return self.evaluate()(args, kvargs) + + def __init__(self, *args, **kvargs): + super().__init__(*args, **kvargs) + + caller_module = get_caller() + + if not hasattr(caller_module, "__typevars_to_resolve"): + caller_module.__typevars_to_resolve = [] + caller_module.__typevars_to_resolve.append(self) + + self.caller_module = caller_module + + @classmethod + def resolve_all(_): + """ + Resolves all self-referencing placeholders in the calling module, + overwriting them with actual types. + Should be called at the end of the module. + """ + caller_module = get_caller() + for tv in getattr(caller_module, "__typevars_to_resolve", []): + tv.resolve() + + def query(*path): class IntoInner: @@ -27,15 +87,20 @@ def parse_output(out): def to_rust(obj): if isinstance(obj, list): return [to_rust(i) for i in obj] + if isinstance(obj, tuple): if len(obj) == 0: return None else: return tuple(to_rust(i) for i in obj) + if isinstance(obj, dict): return {k: to_rust(v) for k, v in obj.items()} - return obj.to_rust() if hasattr(obj, 'to_rust') else obj + if hasattr(obj, "to_rust"): + return obj.to_rust() + + return obj def from_rust(obj, cls): @@ -53,118 +118,129 @@ def from_rust(obj, cls): return obj -def get_class(path) -> type: +def get_class(path: Union[type, str]) -> type: if isinstance(path, type): return path path = path.split('.') name = path[-1] import_path = '.' + '.'.join(path[:-1]) - mod = import_module(import_path, package='iroha2.sys') - return getattr(mod, name) - - -# TODO: (#132) bring in line with other factories -class _Enum(type): - - @staticmethod - def _make_class(variants): - - class RustEnum: - __variants = None - Type = enum.Enum('Type', [k for k, v in variants]) - - def __str__(self): - return f"{self.variant.name}" - - @classmethod - def _variants(cls): - if not cls.__variants: - cls.__variants = {k: get_class(v) for k, v in variants} - return cls.__variants - - @classmethod - def from_rust(cls, value): - # TODO: Dict should inherit from Mapping - if isinstance(value, collections.Mapping)\ - or isinstance(value, Dict): - if len(list(value.keys())) > 1: - raise ValueError - - variant = list(value.keys())[0] - variant_class = cls._variants()[variant] - variant_value = from_rust(value[variant], variant_class) - return cls(variant_value, variant) - elif type(value) is str: - if value in cls._variants().keys(): - return cls(None, value) - else: - raise ValueError - else: - raise ValueError - - def _from_value(self, value): - for variant, ty in self._variants().items(): - # Strip generics (i. e. list[int] -> list) - # since there's no standard analogue to - # isinstance for generic aliases - ty = typing.get_origin(ty) or ty - if isinstance(value, ty): - self.variant = self.Type[variant] - self.value = value - return - - raise TypeError(f"Unknown type for enum: {value}") - - def __init__(self, value, variant=None): - if variant is None: - self._from_value(value) - else: - self.variant = self.Type[variant] - self.value = value + try: + mod = import_module(import_path, package='iroha2.sys') + return getattr(mod, name) + except AttributeError: + # Forward reference, not yet in scope + # Return symbolic variable to be resolved later + return SelfResolvingTypeVar(name, bound=f'{name}') - def to_rust(self) -> dict: - return {self.variant.name: to_rust(self.value)} - for var, ty in variants: +def make_enum_variant(base, variant_name, variant_type): - def constructor_meta(value, var, ty): - if isinstance(ty, str): - ty = get_class(ty) + def repr_enum_variant(self): + return f"{base.__name__}.{variant_name}({repr(self._value)})" - if not isinstance(value, ty): - value = ty(value) - return RustEnum(value, variant=var) + def enum_variant_to_rust(self): + encoded = to_rust(self._value) + return {variant_name: encoded} - # Type here might be a string also - if ty == type(None): - # https://stackoverflow.com/questions/2295290/what-do-lambda-function-closures-capture - constructor = ( - lambda var: lambda: RustEnum(None, variant=var))(var) - else: + return type(f"{base.__name__}.{variant_name}", (base, ), { + "to_rust": enum_variant_to_rust, + "__repr__": repr_enum_variant, + }) - constructor = ( - lambda var, ty: lambda v: constructor_meta(v, var, ty))( - var, ty) - setattr(RustEnum, var, staticmethod(constructor)) +def make_enum(enum_name: str, variants: [Tuple[str, type]], + typs: TypeVar) -> type: + """ + Creates a type corresponding to rust Enum. + Actually creates a base enum type and a type + corresponding to each of the variants, available as + `EnumName.VariantName`. Base enum type can never be + instantiated, calling it directly tries to guess + the variant and instantiate corresponding type, + if the value passed to constructor is unambiguous. + E.g. for a fictional enum `Value[Integer, String]` + `Value(8)` will return `Value.Integer(8)`. + """ - return RustEnum + typemap = {name: typ for name, typ in variants} + + # __new__ must know the base enum type + def make_new(base): + + def new(cls, value: Optional[typs] = None, name: Optional[str] = None): + # We should never construct base enum object directly, + # always a subclass of representing a concrete variant + if cls == base: + if name is None: + for var_name in typemap: + + # Resolve forward references + if isinstance(typemap[var_name], SelfResolvingTypeVar): + typemap[var_name] = typemap[var_name].evaluate() + + # Found variant of suitable type + if isinstance(value, typemap[var_name]): + # Multiple variants of suitable type exist, + # invocation is ambiguous without specifying + # variant + if name is not None: + raise ValueError( + f"{base.__name__} instantiated with ambiguous type: {value}" + ) + name = var_name + + # No variant with such type exists + if name is None: + raise TypeError + + cls = getattr(base, name) + + # Instantiate variant-type object + return super(base, cls).__new__(cls) + + return new + + def init_enum(self, value: typs = None, name=None): + self._value = value + + def enum_from_rust(cls, obj): + if isinstance(obj, dict): + name = list(obj.keys())[0] + value = obj[name] + return cls(from_rust(value, typemap[name]), name) + elif isinstance(obj, str): + return cls(None, obj) + else: + raise ValueError - def __getitem__( - cls, - variants, - ) -> type: - if isinstance(variants, tuple) and isinstance(variants[0], str): - variants = [variants] + # Dereference to contained value + def get_value_attr(self, name): + return getattr(self._value, name) - return cls.__class__._make_class(variants) + enum_type = type( + enum_name, + (abc.ABC, ), + { + "__init__": init_enum, + "__getattr__": get_value_attr, + "from_rust": classmethod(enum_from_rust), + # to_rust is defined on variant subclasses + }) + # These methods need to be generated already + # having the base enum type. + setattr(enum_type, "__new__", make_new(enum_type)) + for name, typ in variants: + setattr(enum_type, name, make_enum_variant(enum_type, name, typ)) -class Enum(metaclass=_Enum): - pass + return enum_type def make_tuple(name, fields=None): + """ + Create an analogue to a rust typle. + """ + if fields is None: fields = [] @@ -174,6 +250,9 @@ def make_tuple(name, fields=None): def make_struct(structname, fields): + """ + Create an analogue to a rust typle. + """ def struct_to_rust(s): # `asdict` doesn't work here since it relies on deepcopy, which isn't @@ -187,7 +266,8 @@ def struct_from_rust(cls, obj): argtype = get_class(argtype) try: # Special case, since those are flattened - # TODO: handle it better + # TODO: requires changes to iroha schema + # to handle properly if structname == "EvaluatesTo" or structname == "Metadata": arg = obj else: diff --git a/iroha2/sys/u128/__init__.py b/iroha2/sys/u128/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/u128/__init__.py +++ b/iroha2/sys/u128/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/u16/__init__.py b/iroha2/sys/u16/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/u16/__init__.py +++ b/iroha2/sys/u16/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/u32/__init__.py b/iroha2/sys/u32/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/u32/__init__.py +++ b/iroha2/sys/u32/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/u64/__init__.py b/iroha2/sys/u64/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/u64/__init__.py +++ b/iroha2/sys/u64/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/iroha2/sys/u8/__init__.py b/iroha2/sys/u8/__init__.py index 8e864bec..91a9aa48 100644 --- a/iroha2/sys/u8/__init__.py +++ b/iroha2/sys/u8/__init__.py @@ -1 +1,5 @@ -from ..rust import Enum, make_struct, make_tuple, Dict + +from ..rust import make_enum, make_struct, make_tuple, get_class, SelfResolvingTypeVar, Dict +import typing + +SelfResolvingTypeVar.resolve_all() diff --git a/src/lib.rs b/src/lib.rs index 7c39cf65..c1d6f667 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,15 +8,16 @@ clippy::multiple_inherent_impl )] +use core::ops::{Deref, DerefMut}; use std::collections::HashMap; -use std::ops::{Deref, DerefMut}; use color_eyre::eyre; -use iroha_client::{client, Configuration}; +use iroha_client::client; +use iroha_config::client::Configuration; use iroha_crypto::{Hash, KeyGenConfiguration}; use iroha_crypto::{PrivateKey, PublicKey}; use iroha_data_model::prelude::*; -use iroha_version::prelude::*; +use iroha_version::scale::EncodeVersioned; use pyo3::class::iter::IterNextOutput; use pyo3::prelude::*; @@ -106,7 +107,7 @@ impl Client { ) -> PyResult> { let isi = isi.into_iter().map(ToPy::into_inner).into(); self.build_transaction(isi, metadata.into_inner()) - .map(VersionedTransaction::from) + .map(VersionedSignedTransaction::from) .map_err(to_py_err) .map(|tx| tx.encode_versioned()) } diff --git a/src/python.rs b/src/python.rs index f86602f9..d4e9cb20 100644 --- a/src/python.rs +++ b/src/python.rs @@ -1,4 +1,4 @@ -use std::{ +use core::{ fmt::Write, ops::{Deref, DerefMut}, };