From f0768f70ba12da8a39cee058d209b680c5ed0339 Mon Sep 17 00:00:00 2001 From: Piotr Heilman Date: Fri, 6 Sep 2024 16:24:23 +0200 Subject: [PATCH] wip --- Cargo.lock | 494 ++++++++++++++++-- Cargo.toml | 1 + .../reqwest/configuration.mustache | 134 +++++ crates/tx-sitter-client/.gitignore | 3 + .../.openapi-generator-ignore | 23 + .../tx-sitter-client/.openapi-generator/FILES | 45 ++ .../.openapi-generator/VERSION | 1 + crates/tx-sitter-client/.travis.yml | 1 + crates/tx-sitter-client/Cargo.toml | 18 + crates/tx-sitter-client/README.md | 94 ++++ crates/tx-sitter-client/docs/AdminV1Api.md | 238 +++++++++ .../docs/CreateApiKeyResponse.md | 11 + .../docs/CreateRelayerRequest.md | 12 + .../docs/CreateRelayerResponse.md | 12 + crates/tx-sitter-client/docs/GetTxResponse.md | 18 + .../tx-sitter-client/docs/JsonRpcVersion.md | 12 + crates/tx-sitter-client/docs/NetworkInfo.md | 14 + .../tx-sitter-client/docs/NewNetworkInfo.md | 13 + .../docs/RelayerGasPriceLimit.md | 12 + crates/tx-sitter-client/docs/RelayerInfo.md | 21 + crates/tx-sitter-client/docs/RelayerUpdate.md | 15 + crates/tx-sitter-client/docs/RelayerV1Api.md | 129 +++++ crates/tx-sitter-client/docs/RpcRequest.md | 14 + crates/tx-sitter-client/docs/SendTxRequest.md | 17 + .../tx-sitter-client/docs/SendTxResponse.md | 11 + crates/tx-sitter-client/docs/ServiceApi.md | 34 ++ .../docs/TransactionPriority.md | 16 + crates/tx-sitter-client/docs/TxStatus.md | 14 + crates/tx-sitter-client/git_push.sh | 57 ++ .../tx-sitter-client/src/apis/admin_v1_api.rs | 388 ++++++++++++++ .../src/apis/configuration.rs | 96 ++++ crates/tx-sitter-client/src/apis/mod.rs | 106 ++++ .../src/apis/relayer_v1_api.rs | 214 ++++++++ .../tx-sitter-client/src/apis/service_api.rs | 55 ++ crates/tx-sitter-client/src/lib.rs | 11 + .../src/models/create_api_key_response.rs | 28 + .../src/models/create_relayer_request.rs | 32 ++ .../src/models/create_relayer_response.rs | 32 ++ .../src/models/get_tx_response.rs | 52 ++ .../src/models/json_rpc_version.rs | 35 ++ crates/tx-sitter-client/src/models/mod.rs | 30 ++ .../src/models/network_info.rs | 36 ++ .../src/models/new_network_info.rs | 33 ++ .../src/models/relayer_gas_price_limit.rs | 31 ++ .../src/models/relayer_info.rs | 58 ++ .../src/models/relayer_update.rs | 39 ++ .../src/models/rpc_request.rs | 36 ++ .../src/models/send_tx_request.rs | 49 ++ .../src/models/send_tx_response.rs | 27 + .../src/models/transaction_priority.rs | 47 ++ .../tx-sitter-client/src/models/tx_status.rs | 41 ++ src/server.rs | 35 +- tests/create_relayer_new_api.rs | 34 ++ 53 files changed, 2959 insertions(+), 70 deletions(-) create mode 100644 client-template/reqwest/configuration.mustache create mode 100644 crates/tx-sitter-client/.gitignore create mode 100644 crates/tx-sitter-client/.openapi-generator-ignore create mode 100644 crates/tx-sitter-client/.openapi-generator/FILES create mode 100644 crates/tx-sitter-client/.openapi-generator/VERSION create mode 100644 crates/tx-sitter-client/.travis.yml create mode 100644 crates/tx-sitter-client/Cargo.toml create mode 100644 crates/tx-sitter-client/README.md create mode 100644 crates/tx-sitter-client/docs/AdminV1Api.md create mode 100644 crates/tx-sitter-client/docs/CreateApiKeyResponse.md create mode 100644 crates/tx-sitter-client/docs/CreateRelayerRequest.md create mode 100644 crates/tx-sitter-client/docs/CreateRelayerResponse.md create mode 100644 crates/tx-sitter-client/docs/GetTxResponse.md create mode 100644 crates/tx-sitter-client/docs/JsonRpcVersion.md create mode 100644 crates/tx-sitter-client/docs/NetworkInfo.md create mode 100644 crates/tx-sitter-client/docs/NewNetworkInfo.md create mode 100644 crates/tx-sitter-client/docs/RelayerGasPriceLimit.md create mode 100644 crates/tx-sitter-client/docs/RelayerInfo.md create mode 100644 crates/tx-sitter-client/docs/RelayerUpdate.md create mode 100644 crates/tx-sitter-client/docs/RelayerV1Api.md create mode 100644 crates/tx-sitter-client/docs/RpcRequest.md create mode 100644 crates/tx-sitter-client/docs/SendTxRequest.md create mode 100644 crates/tx-sitter-client/docs/SendTxResponse.md create mode 100644 crates/tx-sitter-client/docs/ServiceApi.md create mode 100644 crates/tx-sitter-client/docs/TransactionPriority.md create mode 100644 crates/tx-sitter-client/docs/TxStatus.md create mode 100644 crates/tx-sitter-client/git_push.sh create mode 100644 crates/tx-sitter-client/src/apis/admin_v1_api.rs create mode 100644 crates/tx-sitter-client/src/apis/configuration.rs create mode 100644 crates/tx-sitter-client/src/apis/mod.rs create mode 100644 crates/tx-sitter-client/src/apis/relayer_v1_api.rs create mode 100644 crates/tx-sitter-client/src/apis/service_api.rs create mode 100644 crates/tx-sitter-client/src/lib.rs create mode 100644 crates/tx-sitter-client/src/models/create_api_key_response.rs create mode 100644 crates/tx-sitter-client/src/models/create_relayer_request.rs create mode 100644 crates/tx-sitter-client/src/models/create_relayer_response.rs create mode 100644 crates/tx-sitter-client/src/models/get_tx_response.rs create mode 100644 crates/tx-sitter-client/src/models/json_rpc_version.rs create mode 100644 crates/tx-sitter-client/src/models/mod.rs create mode 100644 crates/tx-sitter-client/src/models/network_info.rs create mode 100644 crates/tx-sitter-client/src/models/new_network_info.rs create mode 100644 crates/tx-sitter-client/src/models/relayer_gas_price_limit.rs create mode 100644 crates/tx-sitter-client/src/models/relayer_info.rs create mode 100644 crates/tx-sitter-client/src/models/relayer_update.rs create mode 100644 crates/tx-sitter-client/src/models/rpc_request.rs create mode 100644 crates/tx-sitter-client/src/models/send_tx_request.rs create mode 100644 crates/tx-sitter-client/src/models/send_tx_response.rs create mode 100644 crates/tx-sitter-client/src/models/transaction_priority.rs create mode 100644 crates/tx-sitter-client/src/models/tx_status.rs create mode 100644 tests/create_relayer_new_api.rs diff --git a/Cargo.lock b/Cargo.lock index 53c24f0..8bc3a99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + [[package]] name = "arrayvec" version = "0.7.4" @@ -297,7 +303,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "tracing", - "uuid 1.5.0", + "uuid 1.10.0", ] [[package]] @@ -479,11 +485,11 @@ dependencies = [ "http-body 0.4.5", "http-body 1.0.0", "hyper 0.14.27", - "hyper-rustls", + "hyper-rustls 0.24.2", "once_cell", "pin-project-lite", "pin-utils", - "rustls", + "rustls 0.21.9", "tokio", "tracing", ] @@ -832,8 +838,9 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1238,6 +1245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1575,7 +1583,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "reqwest", + "reqwest 0.11.24", "serde", "serde_json", "syn 2.0.39", @@ -1637,7 +1645,7 @@ checksum = "abbac2c890bdbe0f1b8e549a53b00e2c4c1de86bb077c1094d1f38cdf9381a56" dependencies = [ "chrono", "ethers-core", - "reqwest", + "reqwest 0.11.24", "semver", "serde", "serde_json", @@ -1662,7 +1670,7 @@ dependencies = [ "futures-locks", "futures-util", "instant", - "reqwest", + "reqwest 0.11.24", "serde", "serde_json", "thiserror", @@ -1695,7 +1703,7 @@ dependencies = [ "jsonwebtoken", "once_cell", "pin-project", - "reqwest", + "reqwest 0.11.24", "serde", "serde_json", "thiserror", @@ -1861,9 +1869,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2392,6 +2400,7 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", + "want", ] [[package]] @@ -2404,10 +2413,27 @@ dependencies = [ "http 0.2.11", "hyper 0.14.27", "log", - "rustls", + "rustls 0.21.9", "rustls-native-certs", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.3.1", + "hyper-util", + "rustls 0.23.12", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", ] [[package]] @@ -2423,6 +2449,22 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.5" @@ -2430,12 +2472,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", + "futures-channel", "futures-util", "http 1.1.0", "http-body 1.0.0", "hyper 1.3.1", "pin-project-lite", + "socket2 0.5.5", "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2469,9 +2516,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2529,6 +2576,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] @@ -2539,6 +2587,7 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", "hashbrown 0.14.2", + "serde", ] [[package]] @@ -2832,7 +2881,7 @@ checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea" dependencies = [ "base64 0.21.5", "hyper 0.14.27", - "hyper-tls", + "hyper-tls 0.5.0", "indexmap 1.9.3", "ipnet", "metrics", @@ -2875,6 +2924,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3003,6 +3062,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -3186,7 +3251,7 @@ dependencies = [ "opentelemetry-http", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "reqwest", + "reqwest 0.11.24", "rmp", "thiserror", "url", @@ -3202,7 +3267,7 @@ dependencies = [ "bytes", "http 0.2.11", "opentelemetry", - "reqwest", + "reqwest 0.11.24", ] [[package]] @@ -3325,7 +3390,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -3399,9 +3464,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -4020,8 +4085,8 @@ dependencies = [ "http 0.2.11", "http-body 0.4.5", "hyper 0.14.27", - "hyper-rustls", - "hyper-tls", + "hyper-rustls 0.24.2", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -4030,16 +4095,16 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", - "rustls-pemfile", + "rustls 0.21.9", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 0.1.2", - "system-configuration", + "system-configuration 0.5.1", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.24.1", "tower-service", "url", "wasm-bindgen", @@ -4049,6 +4114,65 @@ dependencies = [ "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.5", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-rustls 0.27.3", + "hyper-tls 0.6.0", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile 2.1.3", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "system-configuration 0.6.1", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + +[[package]] +name = "reqwest-middleware" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" +dependencies = [ + "anyhow", + "async-trait", + "http 1.1.0", + "reqwest 0.12.7", + "serde", + "thiserror", + "tower-service", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -4222,10 +4346,23 @@ checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", "ring 0.17.5", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.102.7", + "subtle", + "zeroize", +] + [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -4233,7 +4370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "schannel", "security-framework", ] @@ -4247,6 +4384,22 @@ dependencies = [ "base64 0.21.5", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64 0.22.1", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4257,6 +4410,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.102.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +dependencies = [ + "ring 0.17.5", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.14" @@ -4437,6 +4601,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "serde_spanned" version = "0.6.4" @@ -4458,6 +4633,36 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.1.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "serde_yaml" version = "0.9.29" @@ -4683,8 +4888,8 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "rustls", - "rustls-pemfile", + "rustls 0.21.9", + "rustls-pemfile 1.0.4", "serde", "serde_json", "sha2", @@ -4930,7 +5135,7 @@ dependencies = [ "fs2", "hex", "once_cell", - "reqwest", + "reqwest 0.11.24", "semver", "serde", "serde_json", @@ -4985,7 +5190,18 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.5.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.4.1", + "core-foundation", + "system-configuration-sys 0.6.0", ] [[package]] @@ -4998,6 +5214,16 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -5019,7 +5245,7 @@ dependencies = [ "opentelemetry-datadog", "opentelemetry-http", "opentelemetry_sdk", - "reqwest", + "reqwest 0.11.24", "serde", "serde_json", "thiserror", @@ -5122,12 +5348,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -5142,10 +5369,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -5219,7 +5447,18 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.9", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.12", + "rustls-pki-types", "tokio", ] @@ -5242,9 +5481,9 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.21.9", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tungstenite", "webpki-roots 0.25.2", ] @@ -5328,6 +5567,27 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.2" @@ -5478,7 +5738,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls", + "rustls 0.21.9", "sha1", "thiserror", "url", @@ -5521,7 +5781,7 @@ dependencies = [ "postgres-docker-utils", "rand", "regex", - "reqwest", + "reqwest 0.11.24", "serde", "serde_json", "sha3", @@ -5536,11 +5796,26 @@ dependencies = [ "tracing", "tracing-error", "tracing-subscriber", + "tx-sitter-client", "url", "uuid 0.8.2", "version", ] +[[package]] +name = "tx-sitter-client" +version = "0.1.0" +dependencies = [ + "reqwest 0.12.7", + "reqwest-middleware", + "serde", + "serde_json", + "serde_repr", + "serde_with", + "url", + "uuid 1.10.0", +] + [[package]] name = "typenum" version = "1.17.0" @@ -5580,6 +5855,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -5649,9 +5933,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -5688,9 +5972,13 @@ dependencies = [ [[package]] name = "uuid" -version = "1.5.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +dependencies = [ + "getrandom", + "serde", +] [[package]] name = "valuable" @@ -5839,7 +6127,7 @@ version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" dependencies = [ - "rustls-webpki", + "rustls-webpki 0.101.7", ] [[package]] @@ -5897,7 +6185,37 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", ] [[package]] @@ -5906,7 +6224,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -5915,13 +6233,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -5930,42 +6264,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.5.19" diff --git a/Cargo.toml b/Cargo.toml index 94d4f81..b8aea9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ aws-types = "1.2.1" # Internal postgres-docker-utils = { path = "crates/postgres-docker-utils" } +tx-sitter-client = { path = "crates/tx-sitter-client" } # Company telemetry-batteries = { git = "https://github.com/worldcoin/telemetry-batteries", rev = "e0891328b29d9f85df037633feccca2f74a291a6" } diff --git a/client-template/reqwest/configuration.mustache b/client-template/reqwest/configuration.mustache new file mode 100644 index 0000000..af11397 --- /dev/null +++ b/client-template/reqwest/configuration.mustache @@ -0,0 +1,134 @@ +{{>partial_header}} + +{{#withAWSV4Signature}} +use std::time::SystemTime; +use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest}; +use http; +use secrecy::{SecretString, ExposeSecret}; +{{/withAWSV4Signature}} + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: {{#supportMiddleware}}reqwest_middleware::ClientWithMiddleware{{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client{{/supportMiddleware}}, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + {{#withAWSV4Signature}} + pub aws_v4_key: Option, + {{/withAWSV4Signature}} + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + +{{#withAWSV4Signature}} +#[derive(Debug, Clone)] +pub struct AWSv4Key { + pub access_key: String, + pub secret_key: SecretString, + pub region: String, + pub service: String, +} + +impl AWSv4Key { + pub fn sign(&self, uri: &str, method: &str, body: &str) -> Result, aws_sigv4::http_request::Error> { + let request = http::Request::builder() + .uri(uri) + .method(method) + .body(body).unwrap(); + let signing_settings = SigningSettings::default(); + let signing_params = SigningParams::builder() + .access_key(self.access_key.as_str()) + .secret_key(self.secret_key.expose_secret().as_str()) + .region(self.region.as_str()) + .service_name(self.service.as_str()) + .time(SystemTime::now()) + .settings(signing_settings) + .build() + .unwrap(); + let signable_request = SignableRequest::from(&request); + let (mut signing_instructions, _signature) = sign(signable_request, &signing_params)?.into_parts(); + let mut additional_headers = Vec::<(String, String)>::new(); + if let Some(new_headers) = signing_instructions.take_headers() { + for (name, value) in new_headers.into_iter() { + additional_headers.push((name.expect("header should have name").to_string(), + value.to_str().expect("header value should be a string").to_string())); + } + } + Ok(additional_headers) + } +} +{{/withAWSV4Signature}} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "{{{basePath}}}".to_owned(), + user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, + client: {{#supportMiddleware}}reqwest_middleware::ClientBuilder::new(reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new()).build(){{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client::new(){{/supportMiddleware}}, + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, +{{#withAWSV4Signature}} aws_v4_key: None,{{/withAWSV4Signature}} + } + } +} + +pub struct ConfigurationBuilder { + pub base_path: Option, + pub user_agent: Option, + pub basic_auth: Option, +} + +impl ConfigurationBuilder { + pub fn new() -> ConfigurationBuilder { + ConfigurationBuilder { + base_path: None, + user_agent: None, + basic_auth: None, + } + } + + pub fn base_path(mut self, base_path: String) -> Self { + self.base_path = Some(base_path); + self + } + + pub fn user_agent(mut self, user_agent: String) -> Self { + self.user_agent = Some(user_agent); + self + } + + pub fn basic_auth(mut self, user: String, pass: Option) -> Self { + self.basic_auth = Some((user, pass)); + self + } + + pub fn build(self) -> Configuration { + let mut conf: Configuration = Default::default(); + + if let Some(base_path) = self.base_path { + conf.base_path = base_path; + } + + if let Some(user_agent) = self.user_agent { + conf.user_agent = Some(user_agent); + } + + if let Some(basic_auth) = self.basic_auth { + conf.basic_auth = Some(basic_auth); + } + + conf + } +} diff --git a/crates/tx-sitter-client/.gitignore b/crates/tx-sitter-client/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/crates/tx-sitter-client/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/crates/tx-sitter-client/.openapi-generator-ignore b/crates/tx-sitter-client/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/crates/tx-sitter-client/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/crates/tx-sitter-client/.openapi-generator/FILES b/crates/tx-sitter-client/.openapi-generator/FILES new file mode 100644 index 0000000..7f1a432 --- /dev/null +++ b/crates/tx-sitter-client/.openapi-generator/FILES @@ -0,0 +1,45 @@ +.gitignore +.travis.yml +Cargo.toml +README.md +docs/AdminV1Api.md +docs/CreateApiKeyResponse.md +docs/CreateRelayerRequest.md +docs/CreateRelayerResponse.md +docs/GetTxResponse.md +docs/JsonRpcVersion.md +docs/NetworkInfo.md +docs/NewNetworkInfo.md +docs/RelayerGasPriceLimit.md +docs/RelayerInfo.md +docs/RelayerUpdate.md +docs/RelayerV1Api.md +docs/RpcRequest.md +docs/SendTxRequest.md +docs/SendTxResponse.md +docs/ServiceApi.md +docs/TransactionPriority.md +docs/TxStatus.md +git_push.sh +src/apis/admin_v1_api.rs +src/apis/configuration.rs +src/apis/mod.rs +src/apis/relayer_v1_api.rs +src/apis/service_api.rs +src/lib.rs +src/models/create_api_key_response.rs +src/models/create_relayer_request.rs +src/models/create_relayer_response.rs +src/models/get_tx_response.rs +src/models/json_rpc_version.rs +src/models/mod.rs +src/models/network_info.rs +src/models/new_network_info.rs +src/models/relayer_gas_price_limit.rs +src/models/relayer_info.rs +src/models/relayer_update.rs +src/models/rpc_request.rs +src/models/send_tx_request.rs +src/models/send_tx_response.rs +src/models/transaction_priority.rs +src/models/tx_status.rs diff --git a/crates/tx-sitter-client/.openapi-generator/VERSION b/crates/tx-sitter-client/.openapi-generator/VERSION new file mode 100644 index 0000000..17f2442 --- /dev/null +++ b/crates/tx-sitter-client/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.9.0-SNAPSHOT diff --git a/crates/tx-sitter-client/.travis.yml b/crates/tx-sitter-client/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/crates/tx-sitter-client/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/crates/tx-sitter-client/Cargo.toml b/crates/tx-sitter-client/Cargo.toml new file mode 100644 index 0000000..6d6a442 --- /dev/null +++ b/crates/tx-sitter-client/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "tx-sitter-client" +version = "0.1.0" +authors = ["OpenAPI Generator team and contributors"] +description = "A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. " +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +uuid = { version = "^1.8", features = ["serde", "v4"] } +reqwest = { version = "^0.12", features = ["json", "multipart"] } +reqwest-middleware = { version = "^0.3", features = ["json", "multipart"] } diff --git a/crates/tx-sitter-client/README.md b/crates/tx-sitter-client/README.md new file mode 100644 index 0000000..3732147 --- /dev/null +++ b/crates/tx-sitter-client/README.md @@ -0,0 +1,94 @@ +# Rust API client for tx-sitter-client + +A transaction relayer service! + +## Operating a relayer +Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. + +### 1. Setup a network +tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. + +To see the list of currently added networks use the `GET /1/admin/networks` endpoint. + +### 2. Create a relayer +A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). + +To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. + +### 3. Create an API key +By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. + +### 4. Use the API key +Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. + +You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + + + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 0.1.0 +- Package version: 0.1.0 +- Generator version: 7.9.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `tx-sitter-client` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +tx-sitter-client = { path = "./tx-sitter-client" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:3000* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AdminV1Api* | [**create_network**](docs/AdminV1Api.md#create_network) | **POST** /1/admin/network/{chain_id} | Create Network +*AdminV1Api* | [**create_relayer**](docs/AdminV1Api.md#create_relayer) | **POST** /1/admin/relayer | Create Relayer +*AdminV1Api* | [**get_networks**](docs/AdminV1Api.md#get_networks) | **GET** /1/admin/networks | Get Networks +*AdminV1Api* | [**get_relayer**](docs/AdminV1Api.md#get_relayer) | **GET** /1/admin/relayer/{relayer_id} | Get Relayer +*AdminV1Api* | [**get_relayers**](docs/AdminV1Api.md#get_relayers) | **GET** /1/admin/relayers | Get Relayers +*AdminV1Api* | [**relayer_create_api_key**](docs/AdminV1Api.md#relayer_create_api_key) | **POST** /1/admin/relayer/{relayer_id}/key | Create Relayer API Key +*AdminV1Api* | [**reset_relayer**](docs/AdminV1Api.md#reset_relayer) | **POST** /1/admin/relayer/{relayer_id}/reset | Reset Relayer transactions +*AdminV1Api* | [**update_relayer**](docs/AdminV1Api.md#update_relayer) | **POST** /1/admin/relayer/{relayer_id} | Update Relayer +*RelayerV1Api* | [**call_rpc**](docs/RelayerV1Api.md#call_rpc) | **POST** /1/api/{api_token}/rpc | Relayer RPC +*RelayerV1Api* | [**create_transaction**](docs/RelayerV1Api.md#create_transaction) | **POST** /1/api/{api_token}/tx | Send Transaction +*RelayerV1Api* | [**get_transaction**](docs/RelayerV1Api.md#get_transaction) | **GET** /1/api/{api_token}/tx/{tx_id} | Get Transaction +*RelayerV1Api* | [**get_transactions**](docs/RelayerV1Api.md#get_transactions) | **GET** /1/api/{api_token}/txs | Get Transactions +*ServiceApi* | [**health**](docs/ServiceApi.md#health) | **GET** /health | Health + + +## Documentation For Models + + - [CreateApiKeyResponse](docs/CreateApiKeyResponse.md) + - [CreateRelayerRequest](docs/CreateRelayerRequest.md) + - [CreateRelayerResponse](docs/CreateRelayerResponse.md) + - [GetTxResponse](docs/GetTxResponse.md) + - [JsonRpcVersion](docs/JsonRpcVersion.md) + - [NetworkInfo](docs/NetworkInfo.md) + - [NewNetworkInfo](docs/NewNetworkInfo.md) + - [RelayerGasPriceLimit](docs/RelayerGasPriceLimit.md) + - [RelayerInfo](docs/RelayerInfo.md) + - [RelayerUpdate](docs/RelayerUpdate.md) + - [RpcRequest](docs/RpcRequest.md) + - [SendTxRequest](docs/SendTxRequest.md) + - [SendTxResponse](docs/SendTxResponse.md) + - [TransactionPriority](docs/TransactionPriority.md) + - [TxStatus](docs/TxStatus.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/crates/tx-sitter-client/docs/AdminV1Api.md b/crates/tx-sitter-client/docs/AdminV1Api.md new file mode 100644 index 0000000..757c572 --- /dev/null +++ b/crates/tx-sitter-client/docs/AdminV1Api.md @@ -0,0 +1,238 @@ +# \AdminV1Api + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_network**](AdminV1Api.md#create_network) | **POST** /1/admin/network/{chain_id} | Create Network +[**create_relayer**](AdminV1Api.md#create_relayer) | **POST** /1/admin/relayer | Create Relayer +[**get_networks**](AdminV1Api.md#get_networks) | **GET** /1/admin/networks | Get Networks +[**get_relayer**](AdminV1Api.md#get_relayer) | **GET** /1/admin/relayer/{relayer_id} | Get Relayer +[**get_relayers**](AdminV1Api.md#get_relayers) | **GET** /1/admin/relayers | Get Relayers +[**relayer_create_api_key**](AdminV1Api.md#relayer_create_api_key) | **POST** /1/admin/relayer/{relayer_id}/key | Create Relayer API Key +[**reset_relayer**](AdminV1Api.md#reset_relayer) | **POST** /1/admin/relayer/{relayer_id}/reset | Reset Relayer transactions +[**update_relayer**](AdminV1Api.md#update_relayer) | **POST** /1/admin/relayer/{relayer_id} | Update Relayer + + + +## create_network + +> create_network(chain_id, new_network_info) +Create Network + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**chain_id** | **i32** | | [required] | +**new_network_info** | [**NewNetworkInfo**](NewNetworkInfo.md) | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json; charset=utf-8 +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_relayer + +> models::CreateRelayerResponse create_relayer(create_relayer_request) +Create Relayer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**create_relayer_request** | [**CreateRelayerRequest**](CreateRelayerRequest.md) | | [required] | + +### Return type + +[**models::CreateRelayerResponse**](CreateRelayerResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json; charset=utf-8 +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_networks + +> Vec get_networks() +Get Networks + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](NetworkInfo.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_relayer + +> models::RelayerInfo get_relayer(relayer_id) +Get Relayer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**relayer_id** | **String** | | [required] | + +### Return type + +[**models::RelayerInfo**](RelayerInfo.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_relayers + +> Vec get_relayers() +Get Relayers + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**Vec**](RelayerInfo.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## relayer_create_api_key + +> models::CreateApiKeyResponse relayer_create_api_key(relayer_id) +Create Relayer API Key + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**relayer_id** | **String** | | [required] | + +### Return type + +[**models::CreateApiKeyResponse**](CreateApiKeyResponse.md) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## reset_relayer + +> reset_relayer(relayer_id) +Reset Relayer transactions + +Purges unsent transactions, useful for unstucking the relayer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**relayer_id** | **String** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## update_relayer + +> update_relayer(relayer_id, relayer_update) +Update Relayer + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**relayer_id** | **String** | | [required] | +**relayer_update** | [**RelayerUpdate**](RelayerUpdate.md) | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[BasicAuth](../README.md#BasicAuth) + +### HTTP request headers + +- **Content-Type**: application/json; charset=utf-8 +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/tx-sitter-client/docs/CreateApiKeyResponse.md b/crates/tx-sitter-client/docs/CreateApiKeyResponse.md new file mode 100644 index 0000000..02ba449 --- /dev/null +++ b/crates/tx-sitter-client/docs/CreateApiKeyResponse.md @@ -0,0 +1,11 @@ +# CreateApiKeyResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_key** | **String** | Base64 encoded API key | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/CreateRelayerRequest.md b/crates/tx-sitter-client/docs/CreateRelayerRequest.md new file mode 100644 index 0000000..1915353 --- /dev/null +++ b/crates/tx-sitter-client/docs/CreateRelayerRequest.md @@ -0,0 +1,12 @@ +# CreateRelayerRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | New relayer name | +**chain_id** | **i32** | The chain id of the relayer | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/CreateRelayerResponse.md b/crates/tx-sitter-client/docs/CreateRelayerResponse.md new file mode 100644 index 0000000..d0308e0 --- /dev/null +++ b/crates/tx-sitter-client/docs/CreateRelayerResponse.md @@ -0,0 +1,12 @@ +# CreateRelayerResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**relayer_id** | **String** | ID of the created relayer | +**address** | **String** | Address of the created relayer | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/GetTxResponse.md b/crates/tx-sitter-client/docs/GetTxResponse.md new file mode 100644 index 0000000..55c823a --- /dev/null +++ b/crates/tx-sitter-client/docs/GetTxResponse.md @@ -0,0 +1,18 @@ +# GetTxResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tx_id** | **String** | | +**to** | **String** | Hex encoded ethereum address | +**data** | Option<**String**> | | [optional] +**value** | **String** | A decimal 256-bit unsigned integer | [default to 0] +**gas_limit** | **String** | A decimal 256-bit unsigned integer | [default to 0] +**nonce** | **i32** | | +**tx_hash** | Option<**String**> | A hex encoded 256-bit hash | [optional][default to 0x0000000000000000000000000000000000000000000000000000000000000000] +**status** | Option<[**models::TxStatus**](TxStatus.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/JsonRpcVersion.md b/crates/tx-sitter-client/docs/JsonRpcVersion.md new file mode 100644 index 0000000..d58f109 --- /dev/null +++ b/crates/tx-sitter-client/docs/JsonRpcVersion.md @@ -0,0 +1,12 @@ +# JsonRpcVersion + +## Enum Variants + +| Name | Value | +|---- | -----| +| Variant2Period0 | 2.0 | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/NetworkInfo.md b/crates/tx-sitter-client/docs/NetworkInfo.md new file mode 100644 index 0000000..53468b3 --- /dev/null +++ b/crates/tx-sitter-client/docs/NetworkInfo.md @@ -0,0 +1,14 @@ +# NetworkInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**chain_id** | **i32** | | +**name** | **String** | | +**http_rpc** | **String** | | +**ws_rpc** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/NewNetworkInfo.md b/crates/tx-sitter-client/docs/NewNetworkInfo.md new file mode 100644 index 0000000..2f228eb --- /dev/null +++ b/crates/tx-sitter-client/docs/NewNetworkInfo.md @@ -0,0 +1,13 @@ +# NewNetworkInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | | +**http_rpc** | **String** | | +**ws_rpc** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/RelayerGasPriceLimit.md b/crates/tx-sitter-client/docs/RelayerGasPriceLimit.md new file mode 100644 index 0000000..d8ba6a5 --- /dev/null +++ b/crates/tx-sitter-client/docs/RelayerGasPriceLimit.md @@ -0,0 +1,12 @@ +# RelayerGasPriceLimit + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **String** | A decimal 256-bit unsigned integer | [default to 0] +**chain_id** | **i64** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/RelayerInfo.md b/crates/tx-sitter-client/docs/RelayerInfo.md new file mode 100644 index 0000000..8c3592c --- /dev/null +++ b/crates/tx-sitter-client/docs/RelayerInfo.md @@ -0,0 +1,21 @@ +# RelayerInfo + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | +**name** | **String** | | +**chain_id** | **i32** | | +**key_id** | **String** | | +**address** | **String** | Hex encoded ethereum address | +**nonce** | **i32** | | +**current_nonce** | **i32** | | +**max_inflight_txs** | **i32** | | +**max_queued_txs** | **i32** | | +**gas_price_limits** | [**Vec**](RelayerGasPriceLimit.md) | | +**enabled** | **bool** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/RelayerUpdate.md b/crates/tx-sitter-client/docs/RelayerUpdate.md new file mode 100644 index 0000000..8119c82 --- /dev/null +++ b/crates/tx-sitter-client/docs/RelayerUpdate.md @@ -0,0 +1,15 @@ +# RelayerUpdate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**relayer_name** | Option<**String**> | | [optional] +**max_inflight_txs** | Option<**i32**> | | [optional] +**max_queued_txs** | Option<**i32**> | | [optional] +**gas_price_limits** | Option<[**Vec**](RelayerGasPriceLimit.md)> | | [optional] +**enabled** | Option<**bool**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/RelayerV1Api.md b/crates/tx-sitter-client/docs/RelayerV1Api.md new file mode 100644 index 0000000..80e792d --- /dev/null +++ b/crates/tx-sitter-client/docs/RelayerV1Api.md @@ -0,0 +1,129 @@ +# \RelayerV1Api + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**call_rpc**](RelayerV1Api.md#call_rpc) | **POST** /1/api/{api_token}/rpc | Relayer RPC +[**create_transaction**](RelayerV1Api.md#create_transaction) | **POST** /1/api/{api_token}/tx | Send Transaction +[**get_transaction**](RelayerV1Api.md#get_transaction) | **GET** /1/api/{api_token}/tx/{tx_id} | Get Transaction +[**get_transactions**](RelayerV1Api.md#get_transactions) | **GET** /1/api/{api_token}/txs | Get Transactions + + + +## call_rpc + +> serde_json::Value call_rpc(api_token, rpc_request) +Relayer RPC + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**api_token** | **String** | | [required] | +**rpc_request** | [**RpcRequest**](RpcRequest.md) | | [required] | + +### Return type + +[**serde_json::Value**](serde_json::Value.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json; charset=utf-8 +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## create_transaction + +> models::SendTxResponse create_transaction(api_token, send_tx_request) +Send Transaction + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**api_token** | **String** | | [required] | +**send_tx_request** | [**SendTxRequest**](SendTxRequest.md) | | [required] | + +### Return type + +[**models::SendTxResponse**](SendTxResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json; charset=utf-8 +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_transaction + +> models::GetTxResponse get_transaction(api_token, tx_id) +Get Transaction + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**api_token** | **String** | | [required] | +**tx_id** | **String** | | [required] | + +### Return type + +[**models::GetTxResponse**](GetTxResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +## get_transactions + +> Vec get_transactions(api_token, status, unsent) +Get Transactions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**api_token** | **String** | | [required] | +**status** | Option<[**TxStatus**](.md)> | Optional tx status to filter by | | +**unsent** | Option<**bool**> | Fetch unsent txs, overrides the status query | |[default to false] + +### Return type + +[**Vec**](GetTxResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json; charset=utf-8 + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/tx-sitter-client/docs/RpcRequest.md b/crates/tx-sitter-client/docs/RpcRequest.md new file mode 100644 index 0000000..468d75c --- /dev/null +++ b/crates/tx-sitter-client/docs/RpcRequest.md @@ -0,0 +1,14 @@ +# RpcRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **i32** | | +**method** | **String** | | +**params** | Option<[**serde_json::Value**](.md)> | | [optional][default to null] +**jsonrpc** | [**models::JsonRpcVersion**](JsonRpcVersion.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/SendTxRequest.md b/crates/tx-sitter-client/docs/SendTxRequest.md new file mode 100644 index 0000000..4a39e31 --- /dev/null +++ b/crates/tx-sitter-client/docs/SendTxRequest.md @@ -0,0 +1,17 @@ +# SendTxRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**to** | **String** | Hex encoded ethereum address | +**value** | **String** | Transaction value | [default to 0] +**data** | Option<**String**> | | [optional] +**gas_limit** | **String** | Transaction gas limit | [default to 0] +**priority** | Option<[**models::TransactionPriority**](TransactionPriority.md)> | | [optional] +**tx_id** | Option<**String**> | An optional transaction id. If not provided tx-sitter will generate a UUID. Can be used to provide idempotency for the transaction. | [optional] +**blobs** | Option<[**Vec>**](Vec.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/SendTxResponse.md b/crates/tx-sitter-client/docs/SendTxResponse.md new file mode 100644 index 0000000..14a4217 --- /dev/null +++ b/crates/tx-sitter-client/docs/SendTxResponse.md @@ -0,0 +1,11 @@ +# SendTxResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tx_id** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/ServiceApi.md b/crates/tx-sitter-client/docs/ServiceApi.md new file mode 100644 index 0000000..457d1e8 --- /dev/null +++ b/crates/tx-sitter-client/docs/ServiceApi.md @@ -0,0 +1,34 @@ +# \ServiceApi + +All URIs are relative to *http://localhost:3000* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**health**](ServiceApi.md#health) | **GET** /health | Health + + + +## health + +> health() +Health + +### Parameters + +This endpoint does not need any parameter. + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/crates/tx-sitter-client/docs/TransactionPriority.md b/crates/tx-sitter-client/docs/TransactionPriority.md new file mode 100644 index 0000000..72ec087 --- /dev/null +++ b/crates/tx-sitter-client/docs/TransactionPriority.md @@ -0,0 +1,16 @@ +# TransactionPriority + +## Enum Variants + +| Name | Value | +|---- | -----| +| Slowest | slowest | +| Slow | slow | +| Regular | regular | +| Fast | fast | +| Fastest | fastest | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/docs/TxStatus.md b/crates/tx-sitter-client/docs/TxStatus.md new file mode 100644 index 0000000..413f41e --- /dev/null +++ b/crates/tx-sitter-client/docs/TxStatus.md @@ -0,0 +1,14 @@ +# TxStatus + +## Enum Variants + +| Name | Value | +|---- | -----| +| Pending | pending | +| Mined | mined | +| Finalized | finalized | + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/crates/tx-sitter-client/git_push.sh b/crates/tx-sitter-client/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/crates/tx-sitter-client/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/crates/tx-sitter-client/src/apis/admin_v1_api.rs b/crates/tx-sitter-client/src/apis/admin_v1_api.rs new file mode 100644 index 0000000..8f46b27 --- /dev/null +++ b/crates/tx-sitter-client/src/apis/admin_v1_api.rs @@ -0,0 +1,388 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`create_network`] +#[derive(Clone, Debug)] +pub struct CreateNetworkParams { + pub chain_id: i32, + pub new_network_info: models::NewNetworkInfo +} + +/// struct for passing parameters to the method [`create_relayer`] +#[derive(Clone, Debug)] +pub struct CreateRelayerParams { + pub create_relayer_request: models::CreateRelayerRequest +} + +/// struct for passing parameters to the method [`get_relayer`] +#[derive(Clone, Debug)] +pub struct GetRelayerParams { + pub relayer_id: String +} + +/// struct for passing parameters to the method [`relayer_create_api_key`] +#[derive(Clone, Debug)] +pub struct RelayerCreateApiKeyParams { + pub relayer_id: String +} + +/// struct for passing parameters to the method [`reset_relayer`] +#[derive(Clone, Debug)] +pub struct ResetRelayerParams { + pub relayer_id: String +} + +/// struct for passing parameters to the method [`update_relayer`] +#[derive(Clone, Debug)] +pub struct UpdateRelayerParams { + pub relayer_id: String, + pub relayer_update: models::RelayerUpdate +} + + +/// struct for typed errors of method [`create_network`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateNetworkError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_relayer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRelayerError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_networks`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetNetworksError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_relayer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRelayerError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_relayers`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRelayersError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`relayer_create_api_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RelayerCreateApiKeyError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`reset_relayer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ResetRelayerError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`update_relayer`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateRelayerError { + UnknownValue(serde_json::Value), +} + + +pub async fn create_network(configuration: &configuration::Configuration, params: CreateNetworkParams) -> Result<(), Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let chain_id = params.chain_id; + let new_network_info = params.new_network_info; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/network/{chain_id}", local_var_configuration.base_path, chain_id=chain_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&new_network_info); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn create_relayer(configuration: &configuration::Configuration, params: CreateRelayerParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let create_relayer_request = params.create_relayer_request; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayer", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&create_relayer_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_networks(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/networks", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_relayer(configuration: &configuration::Configuration, params: GetRelayerParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let relayer_id = params.relayer_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayer/{relayer_id}", local_var_configuration.base_path, relayer_id=crate::apis::urlencode(relayer_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_relayers(configuration: &configuration::Configuration) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayers", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn relayer_create_api_key(configuration: &configuration::Configuration, params: RelayerCreateApiKeyParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let relayer_id = params.relayer_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayer/{relayer_id}/key", local_var_configuration.base_path, relayer_id=crate::apis::urlencode(relayer_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +/// Purges unsent transactions, useful for unstucking the relayer +pub async fn reset_relayer(configuration: &configuration::Configuration, params: ResetRelayerParams) -> Result<(), Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let relayer_id = params.relayer_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayer/{relayer_id}/reset", local_var_configuration.base_path, relayer_id=crate::apis::urlencode(relayer_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn update_relayer(configuration: &configuration::Configuration, params: UpdateRelayerParams) -> Result<(), Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let relayer_id = params.relayer_id; + let relayer_update = params.relayer_update; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/admin/relayer/{relayer_id}", local_var_configuration.base_path, relayer_id=crate::apis::urlencode(relayer_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { + local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&relayer_update); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/crates/tx-sitter-client/src/apis/configuration.rs b/crates/tx-sitter-client/src/apis/configuration.rs new file mode 100644 index 0000000..56a4e42 --- /dev/null +++ b/crates/tx-sitter-client/src/apis/configuration.rs @@ -0,0 +1,96 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest_middleware::ClientWithMiddleware, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, + // TODO: take an oauth2 token source, similar to the go one +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "http://localhost:3000".to_owned(), + user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), + client: reqwest_middleware::ClientBuilder::new(reqwest::Client::new()).build(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + + } + } +} + +pub struct ConfigurationBuilder { + pub base_path: Option, + pub user_agent: Option, + pub basic_auth: Option, +} + +impl ConfigurationBuilder { + pub fn new() -> ConfigurationBuilder { + ConfigurationBuilder { + base_path: None, + user_agent: None, + basic_auth: None, + } + } + + pub fn base_path(mut self, base_path: String) -> Self { + self.base_path = Some(base_path); + self + } + + pub fn user_agent(mut self, user_agent: String) -> Self { + self.user_agent = Some(user_agent); + self + } + + pub fn basic_auth(mut self, user: String, pass: Option) -> Self { + self.basic_auth = Some((user, pass)); + self + } + + pub fn build(self) -> Configuration { + let mut conf: Configuration = Default::default(); + + if let Some(base_path) = self.base_path { + conf.base_path = base_path; + } + + if let Some(user_agent) = self.user_agent { + conf.user_agent = Some(user_agent); + } + + if let Some(basic_auth) = self.basic_auth { + conf.basic_auth = Some(basic_auth); + } + + conf + } +} diff --git a/crates/tx-sitter-client/src/apis/mod.rs b/crates/tx-sitter-client/src/apis/mod.rs new file mode 100644 index 0000000..8a66d82 --- /dev/null +++ b/crates/tx-sitter-client/src/apis/mod.rs @@ -0,0 +1,106 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + ReqwestMiddleware(reqwest_middleware::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::ReqwestMiddleware(e) => ("reqwest-middleware", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::ReqwestMiddleware(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: reqwest_middleware::Error) -> Self { + Error::ReqwestMiddleware(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod admin_v1_api; +pub mod relayer_v1_api; +pub mod service_api; + +pub mod configuration; diff --git a/crates/tx-sitter-client/src/apis/relayer_v1_api.rs b/crates/tx-sitter-client/src/apis/relayer_v1_api.rs new file mode 100644 index 0000000..c228375 --- /dev/null +++ b/crates/tx-sitter-client/src/apis/relayer_v1_api.rs @@ -0,0 +1,214 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + +/// struct for passing parameters to the method [`call_rpc`] +#[derive(Clone, Debug)] +pub struct CallRpcParams { + pub api_token: String, + pub rpc_request: models::RpcRequest +} + +/// struct for passing parameters to the method [`create_transaction`] +#[derive(Clone, Debug)] +pub struct CreateTransactionParams { + pub api_token: String, + pub send_tx_request: models::SendTxRequest +} + +/// struct for passing parameters to the method [`get_transaction`] +#[derive(Clone, Debug)] +pub struct GetTransactionParams { + pub api_token: String, + pub tx_id: String +} + +/// struct for passing parameters to the method [`get_transactions`] +#[derive(Clone, Debug)] +pub struct GetTransactionsParams { + pub api_token: String, + /// Optional tx status to filter by + pub status: Option, + /// Fetch unsent txs, overrides the status query + pub unsent: Option +} + + +/// struct for typed errors of method [`call_rpc`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CallRpcError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_transaction`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTransactionError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_transaction`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransactionError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_transactions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTransactionsError { + UnknownValue(serde_json::Value), +} + + +pub async fn call_rpc(configuration: &configuration::Configuration, params: CallRpcParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let api_token = params.api_token; + let rpc_request = params.rpc_request; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/api/{api_token}/rpc", local_var_configuration.base_path, api_token=crate::apis::urlencode(api_token)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&rpc_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn create_transaction(configuration: &configuration::Configuration, params: CreateTransactionParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let api_token = params.api_token; + let send_tx_request = params.send_tx_request; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/api/{api_token}/tx", local_var_configuration.base_path, api_token=crate::apis::urlencode(api_token)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&send_tx_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_transaction(configuration: &configuration::Configuration, params: GetTransactionParams) -> Result> { + let local_var_configuration = configuration; + + // unbox the parameters + let api_token = params.api_token; + let tx_id = params.tx_id; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/api/{api_token}/tx/{tx_id}", local_var_configuration.base_path, api_token=crate::apis::urlencode(api_token), tx_id=crate::apis::urlencode(tx_id)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_transactions(configuration: &configuration::Configuration, params: GetTransactionsParams) -> Result, Error> { + let local_var_configuration = configuration; + + // unbox the parameters + let api_token = params.api_token; + let status = params.status; + let unsent = params.unsent; + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/1/api/{api_token}/txs", local_var_configuration.base_path, api_token=crate::apis::urlencode(api_token)); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = status { + local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = unsent { + local_var_req_builder = local_var_req_builder.query(&[("unsent", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/crates/tx-sitter-client/src/apis/service_api.rs b/crates/tx-sitter-client/src/apis/service_api.rs new file mode 100644 index 0000000..e045ffa --- /dev/null +++ b/crates/tx-sitter-client/src/apis/service_api.rs @@ -0,0 +1,55 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + + +/// struct for typed errors of method [`health`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum HealthError { + UnknownValue(serde_json::Value), +} + + +pub async fn health(configuration: &configuration::Configuration) -> Result<(), Error> { + let local_var_configuration = configuration; + + // unbox the parameters + + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/health", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/crates/tx-sitter-client/src/lib.rs b/crates/tx-sitter-client/src/lib.rs new file mode 100644 index 0000000..e152062 --- /dev/null +++ b/crates/tx-sitter-client/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/crates/tx-sitter-client/src/models/create_api_key_response.rs b/crates/tx-sitter-client/src/models/create_api_key_response.rs new file mode 100644 index 0000000..2b1e688 --- /dev/null +++ b/crates/tx-sitter-client/src/models/create_api_key_response.rs @@ -0,0 +1,28 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateApiKeyResponse { + /// Base64 encoded API key + #[serde(rename = "apiKey")] + pub api_key: String, +} + +impl CreateApiKeyResponse { + pub fn new(api_key: String) -> CreateApiKeyResponse { + CreateApiKeyResponse { + api_key, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/create_relayer_request.rs b/crates/tx-sitter-client/src/models/create_relayer_request.rs new file mode 100644 index 0000000..41b039f --- /dev/null +++ b/crates/tx-sitter-client/src/models/create_relayer_request.rs @@ -0,0 +1,32 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateRelayerRequest { + /// New relayer name + #[serde(rename = "name")] + pub name: String, + /// The chain id of the relayer + #[serde(rename = "chainId")] + pub chain_id: i32, +} + +impl CreateRelayerRequest { + pub fn new(name: String, chain_id: i32) -> CreateRelayerRequest { + CreateRelayerRequest { + name, + chain_id, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/create_relayer_response.rs b/crates/tx-sitter-client/src/models/create_relayer_response.rs new file mode 100644 index 0000000..6ea9cea --- /dev/null +++ b/crates/tx-sitter-client/src/models/create_relayer_response.rs @@ -0,0 +1,32 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct CreateRelayerResponse { + /// ID of the created relayer + #[serde(rename = "relayerId")] + pub relayer_id: String, + /// Address of the created relayer + #[serde(rename = "address")] + pub address: String, +} + +impl CreateRelayerResponse { + pub fn new(relayer_id: String, address: String) -> CreateRelayerResponse { + CreateRelayerResponse { + relayer_id, + address, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/get_tx_response.rs b/crates/tx-sitter-client/src/models/get_tx_response.rs new file mode 100644 index 0000000..01227e0 --- /dev/null +++ b/crates/tx-sitter-client/src/models/get_tx_response.rs @@ -0,0 +1,52 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct GetTxResponse { + #[serde(rename = "txId")] + pub tx_id: String, + /// Hex encoded ethereum address + #[serde(rename = "to")] + pub to: String, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option, + /// A decimal 256-bit unsigned integer + #[serde(rename = "value")] + pub value: String, + /// A decimal 256-bit unsigned integer + #[serde(rename = "gasLimit")] + pub gas_limit: String, + #[serde(rename = "nonce")] + pub nonce: i32, + /// A hex encoded 256-bit hash + #[serde(rename = "txHash", skip_serializing_if = "Option::is_none")] + pub tx_hash: Option, + #[serde(rename = "status", skip_serializing_if = "Option::is_none")] + pub status: Option>, +} + +impl GetTxResponse { + pub fn new(tx_id: String, to: String, value: String, gas_limit: String, nonce: i32) -> GetTxResponse { + GetTxResponse { + tx_id, + to, + data: None, + value, + gas_limit, + nonce, + tx_hash: None, + status: None, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/json_rpc_version.rs b/crates/tx-sitter-client/src/models/json_rpc_version.rs new file mode 100644 index 0000000..cffa4d1 --- /dev/null +++ b/crates/tx-sitter-client/src/models/json_rpc_version.rs @@ -0,0 +1,35 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum JsonRpcVersion { + #[serde(rename = "2.0")] + Variant2Period0, + +} + +impl std::fmt::Display for JsonRpcVersion { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Variant2Period0 => write!(f, "2.0"), + } + } +} + +impl Default for JsonRpcVersion { + fn default() -> JsonRpcVersion { + Self::Variant2Period0 + } +} + diff --git a/crates/tx-sitter-client/src/models/mod.rs b/crates/tx-sitter-client/src/models/mod.rs new file mode 100644 index 0000000..75f702f --- /dev/null +++ b/crates/tx-sitter-client/src/models/mod.rs @@ -0,0 +1,30 @@ +pub mod create_api_key_response; +pub use self::create_api_key_response::CreateApiKeyResponse; +pub mod create_relayer_request; +pub use self::create_relayer_request::CreateRelayerRequest; +pub mod create_relayer_response; +pub use self::create_relayer_response::CreateRelayerResponse; +pub mod get_tx_response; +pub use self::get_tx_response::GetTxResponse; +pub mod json_rpc_version; +pub use self::json_rpc_version::JsonRpcVersion; +pub mod network_info; +pub use self::network_info::NetworkInfo; +pub mod new_network_info; +pub use self::new_network_info::NewNetworkInfo; +pub mod relayer_gas_price_limit; +pub use self::relayer_gas_price_limit::RelayerGasPriceLimit; +pub mod relayer_info; +pub use self::relayer_info::RelayerInfo; +pub mod relayer_update; +pub use self::relayer_update::RelayerUpdate; +pub mod rpc_request; +pub use self::rpc_request::RpcRequest; +pub mod send_tx_request; +pub use self::send_tx_request::SendTxRequest; +pub mod send_tx_response; +pub use self::send_tx_response::SendTxResponse; +pub mod transaction_priority; +pub use self::transaction_priority::TransactionPriority; +pub mod tx_status; +pub use self::tx_status::TxStatus; diff --git a/crates/tx-sitter-client/src/models/network_info.rs b/crates/tx-sitter-client/src/models/network_info.rs new file mode 100644 index 0000000..6601b77 --- /dev/null +++ b/crates/tx-sitter-client/src/models/network_info.rs @@ -0,0 +1,36 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NetworkInfo { + #[serde(rename = "chainId")] + pub chain_id: i32, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "httpRpc")] + pub http_rpc: String, + #[serde(rename = "wsRpc")] + pub ws_rpc: String, +} + +impl NetworkInfo { + pub fn new(chain_id: i32, name: String, http_rpc: String, ws_rpc: String) -> NetworkInfo { + NetworkInfo { + chain_id, + name, + http_rpc, + ws_rpc, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/new_network_info.rs b/crates/tx-sitter-client/src/models/new_network_info.rs new file mode 100644 index 0000000..dfaa156 --- /dev/null +++ b/crates/tx-sitter-client/src/models/new_network_info.rs @@ -0,0 +1,33 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct NewNetworkInfo { + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "httpRpc")] + pub http_rpc: String, + #[serde(rename = "wsRpc")] + pub ws_rpc: String, +} + +impl NewNetworkInfo { + pub fn new(name: String, http_rpc: String, ws_rpc: String) -> NewNetworkInfo { + NewNetworkInfo { + name, + http_rpc, + ws_rpc, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/relayer_gas_price_limit.rs b/crates/tx-sitter-client/src/models/relayer_gas_price_limit.rs new file mode 100644 index 0000000..15b272e --- /dev/null +++ b/crates/tx-sitter-client/src/models/relayer_gas_price_limit.rs @@ -0,0 +1,31 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RelayerGasPriceLimit { + /// A decimal 256-bit unsigned integer + #[serde(rename = "value")] + pub value: String, + #[serde(rename = "chainId")] + pub chain_id: i64, +} + +impl RelayerGasPriceLimit { + pub fn new(value: String, chain_id: i64) -> RelayerGasPriceLimit { + RelayerGasPriceLimit { + value, + chain_id, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/relayer_info.rs b/crates/tx-sitter-client/src/models/relayer_info.rs new file mode 100644 index 0000000..57da49e --- /dev/null +++ b/crates/tx-sitter-client/src/models/relayer_info.rs @@ -0,0 +1,58 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RelayerInfo { + #[serde(rename = "id")] + pub id: String, + #[serde(rename = "name")] + pub name: String, + #[serde(rename = "chainId")] + pub chain_id: i32, + #[serde(rename = "keyId")] + pub key_id: String, + /// Hex encoded ethereum address + #[serde(rename = "address")] + pub address: String, + #[serde(rename = "nonce")] + pub nonce: i32, + #[serde(rename = "currentNonce")] + pub current_nonce: i32, + #[serde(rename = "maxInflightTxs")] + pub max_inflight_txs: i32, + #[serde(rename = "maxQueuedTxs")] + pub max_queued_txs: i32, + #[serde(rename = "gasPriceLimits")] + pub gas_price_limits: Vec, + #[serde(rename = "enabled")] + pub enabled: bool, +} + +impl RelayerInfo { + pub fn new(id: String, name: String, chain_id: i32, key_id: String, address: String, nonce: i32, current_nonce: i32, max_inflight_txs: i32, max_queued_txs: i32, gas_price_limits: Vec, enabled: bool) -> RelayerInfo { + RelayerInfo { + id, + name, + chain_id, + key_id, + address, + nonce, + current_nonce, + max_inflight_txs, + max_queued_txs, + gas_price_limits, + enabled, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/relayer_update.rs b/crates/tx-sitter-client/src/models/relayer_update.rs new file mode 100644 index 0000000..613c369 --- /dev/null +++ b/crates/tx-sitter-client/src/models/relayer_update.rs @@ -0,0 +1,39 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RelayerUpdate { + #[serde(rename = "relayerName", skip_serializing_if = "Option::is_none")] + pub relayer_name: Option, + #[serde(rename = "maxInflightTxs", skip_serializing_if = "Option::is_none")] + pub max_inflight_txs: Option, + #[serde(rename = "maxQueuedTxs", skip_serializing_if = "Option::is_none")] + pub max_queued_txs: Option, + #[serde(rename = "gasPriceLimits", skip_serializing_if = "Option::is_none")] + pub gas_price_limits: Option>, + #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")] + pub enabled: Option, +} + +impl RelayerUpdate { + pub fn new() -> RelayerUpdate { + RelayerUpdate { + relayer_name: None, + max_inflight_txs: None, + max_queued_txs: None, + gas_price_limits: None, + enabled: None, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/rpc_request.rs b/crates/tx-sitter-client/src/models/rpc_request.rs new file mode 100644 index 0000000..5a3eb03 --- /dev/null +++ b/crates/tx-sitter-client/src/models/rpc_request.rs @@ -0,0 +1,36 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RpcRequest { + #[serde(rename = "id")] + pub id: i32, + #[serde(rename = "method")] + pub method: String, + #[serde(rename = "params", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub params: Option>, + #[serde(rename = "jsonrpc")] + pub jsonrpc: models::JsonRpcVersion, +} + +impl RpcRequest { + pub fn new(id: i32, method: String, jsonrpc: models::JsonRpcVersion) -> RpcRequest { + RpcRequest { + id, + method, + params: None, + jsonrpc, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/send_tx_request.rs b/crates/tx-sitter-client/src/models/send_tx_request.rs new file mode 100644 index 0000000..240533d --- /dev/null +++ b/crates/tx-sitter-client/src/models/send_tx_request.rs @@ -0,0 +1,49 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SendTxRequest { + /// Hex encoded ethereum address + #[serde(rename = "to")] + pub to: String, + /// Transaction value + #[serde(rename = "value")] + pub value: String, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option, + /// Transaction gas limit + #[serde(rename = "gasLimit")] + pub gas_limit: String, + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option>, + /// An optional transaction id. If not provided tx-sitter will generate a UUID. Can be used to provide idempotency for the transaction. + #[serde(rename = "txId", skip_serializing_if = "Option::is_none")] + pub tx_id: Option, + #[serde(rename = "blobs", skip_serializing_if = "Option::is_none")] + pub blobs: Option>>, +} + +impl SendTxRequest { + pub fn new(to: String, value: String, gas_limit: String) -> SendTxRequest { + SendTxRequest { + to, + value, + data: None, + gas_limit, + priority: None, + tx_id: None, + blobs: None, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/send_tx_response.rs b/crates/tx-sitter-client/src/models/send_tx_response.rs new file mode 100644 index 0000000..ca7b62d --- /dev/null +++ b/crates/tx-sitter-client/src/models/send_tx_response.rs @@ -0,0 +1,27 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SendTxResponse { + #[serde(rename = "txId")] + pub tx_id: String, +} + +impl SendTxResponse { + pub fn new(tx_id: String) -> SendTxResponse { + SendTxResponse { + tx_id, + } + } +} + diff --git a/crates/tx-sitter-client/src/models/transaction_priority.rs b/crates/tx-sitter-client/src/models/transaction_priority.rs new file mode 100644 index 0000000..1f94f76 --- /dev/null +++ b/crates/tx-sitter-client/src/models/transaction_priority.rs @@ -0,0 +1,47 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TransactionPriority { + #[serde(rename = "slowest")] + Slowest, + #[serde(rename = "slow")] + Slow, + #[serde(rename = "regular")] + Regular, + #[serde(rename = "fast")] + Fast, + #[serde(rename = "fastest")] + Fastest, + +} + +impl std::fmt::Display for TransactionPriority { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Slowest => write!(f, "slowest"), + Self::Slow => write!(f, "slow"), + Self::Regular => write!(f, "regular"), + Self::Fast => write!(f, "fast"), + Self::Fastest => write!(f, "fastest"), + } + } +} + +impl Default for TransactionPriority { + fn default() -> TransactionPriority { + Self::Slowest + } +} + diff --git a/crates/tx-sitter-client/src/models/tx_status.rs b/crates/tx-sitter-client/src/models/tx_status.rs new file mode 100644 index 0000000..24f0f02 --- /dev/null +++ b/crates/tx-sitter-client/src/models/tx_status.rs @@ -0,0 +1,41 @@ +/* + * Tx Sitter + * + * A transaction relayer service! ## Operating a relayer Below is a guide on using this service. Note that septs 1 through 4 require authentication using HTTP Basic auth. Using swagger explorer make sure to click the authorize button and use the correct credentials. Default dev creds are `admin:admin`. ### 1. Setup a network tx-sitter keeps track of supported networks in its internal database. In order to be able to create any relayers at least one network must be present. To add a network use the `POST /1/admin/networks/:chain_id` endpoint. To see the list of currently added networks use the `GET /1/admin/networks` endpoint. ### 2. Create a relayer A relayer is an abstraction layer on top of a private key stored locally (for testing purposes only!) or using a secrets manager (currently only AWS KMS is supported). To create a relayer use the `POST /1/admin/relayer` endpoint. The data returned will contain a relayer id, make sure to copy it to the clipboard. ### 3. Create an API key By itself a relayer is not very useful. In order to send transactions one must create an API key. To do that use the `POST /1/admin/relayer/:relayer_id/key` endpoint. **Make sure to copy the API key from the response. It's not possible to recover it!** But it's always possible to create a new one. ### 4. Use the API key Once an API keys has been created it's possible to use the relayer api to, among other things, send transactions. You can use the `POST /1/api/:api_token/tx` endpoint to create a transaction. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum TxStatus { + #[serde(rename = "pending")] + Pending, + #[serde(rename = "mined")] + Mined, + #[serde(rename = "finalized")] + Finalized, + +} + +impl std::fmt::Display for TxStatus { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Pending => write!(f, "pending"), + Self::Mined => write!(f, "mined"), + Self::Finalized => write!(f, "finalized"), + } + } +} + +impl Default for TxStatus { + fn default() -> TxStatus { + Self::Pending + } +} + diff --git a/src/server.rs b/src/server.rs index 91878eb..0d3e3e6 100644 --- a/src/server.rs +++ b/src/server.rs @@ -12,7 +12,7 @@ use poem::web::{Data, LocalAddr}; use poem::{EndpointExt, Result, Route}; use poem_openapi::param::{Path, Query}; use poem_openapi::payload::Json; -use poem_openapi::{ApiResponse, OpenApi, OpenApiService}; +use poem_openapi::{ApiResponse, OpenApi, OpenApiService, Tags}; use security::BasicAuth; use serde_json::Value; use url::Url; @@ -31,12 +31,19 @@ use crate::types::{ mod security; mod trace_middleware; +#[derive(Tags)] +enum OpenAPITags { + AdminV1, + RelayerV1, + Service +} + struct AdminApi; #[OpenApi(prefix_path = "/1/admin/")] impl AdminApi { /// Create Relayer - #[oai(path = "/relayer", method = "post")] + #[oai(path = "/relayer", method = "post", operation_id = "create_relayer", tag = "OpenAPITags::AdminV1")] async fn create_relayer( &self, basic_auth: BasicAuth, @@ -69,7 +76,7 @@ impl AdminApi { } /// Get Relayers - #[oai(path = "/relayers", method = "get")] + #[oai(path = "/relayers", method = "get", operation_id = "get_relayers", tag = "OpenAPITags::AdminV1")] async fn get_relayers( &self, basic_auth: BasicAuth, @@ -83,7 +90,7 @@ impl AdminApi { } /// Get Relayer - #[oai(path = "/relayer/:relayer_id", method = "get")] + #[oai(path = "/relayer/:relayer_id", method = "get", operation_id = "get_relayer", tag = "OpenAPITags::AdminV1")] async fn get_relayer( &self, basic_auth: BasicAuth, @@ -104,7 +111,7 @@ impl AdminApi { } /// Update Relayer - #[oai(path = "/relayer/:relayer_id", method = "post")] + #[oai(path = "/relayer/:relayer_id", method = "post", operation_id = "update_relayer", tag = "OpenAPITags::AdminV1")] async fn update_relayer( &self, basic_auth: BasicAuth, @@ -122,7 +129,7 @@ impl AdminApi { /// Reset Relayer transactions /// /// Purges unsent transactions, useful for unstucking the relayer - #[oai(path = "/relayer/:relayer_id/reset", method = "post")] + #[oai(path = "/relayer/:relayer_id/reset", method = "post", operation_id = "reset_relayer", tag = "OpenAPITags::AdminV1")] async fn purge_unsent_txs( &self, basic_auth: BasicAuth, @@ -137,7 +144,7 @@ impl AdminApi { } /// Create Relayer API Key - #[oai(path = "/relayer/:relayer_id/key", method = "post")] + #[oai(path = "/relayer/:relayer_id/key", method = "post", operation_id = "relayer_create_api_key", tag = "OpenAPITags::AdminV1")] async fn create_relayer_api_key( &self, basic_auth: BasicAuth, @@ -156,7 +163,7 @@ impl AdminApi { } /// Create Network - #[oai(path = "/network/:chain_id", method = "post")] + #[oai(path = "/network/:chain_id", method = "post", operation_id = "create_network", tag = "OpenAPITags::AdminV1")] async fn create_network( &self, basic_auth: BasicAuth, @@ -192,7 +199,7 @@ impl AdminApi { } /// Get Networks - #[oai(path = "/networks", method = "get")] + #[oai(path = "/networks", method = "get", operation_id = "get_networks", tag = "OpenAPITags::AdminV1")] async fn list_networks( &self, basic_auth: BasicAuth, @@ -211,7 +218,7 @@ struct RelayerApi; #[OpenApi(prefix_path = "/1/api/")] impl RelayerApi { /// Send Transaction - #[oai(path = "/:api_token/tx", method = "post")] + #[oai(path = "/:api_token/tx", method = "post", operation_id = "create_transaction", tag = "OpenAPITags::RelayerV1")] async fn send_tx( &self, Data(app): Data<&Arc>, @@ -312,7 +319,7 @@ impl RelayerApi { } /// Get Transaction - #[oai(path = "/:api_token/tx/:tx_id", method = "get")] + #[oai(path = "/:api_token/tx/:tx_id", method = "get", operation_id = "get_transaction", tag = "OpenAPITags::RelayerV1")] async fn get_tx( &self, Data(app): Data<&Arc>, @@ -353,7 +360,7 @@ impl RelayerApi { } /// Get Transactions - #[oai(path = "/:api_token/txs", method = "get")] + #[oai(path = "/:api_token/txs", method = "get", operation_id = "get_transactions", tag = "OpenAPITags::RelayerV1")] async fn get_txs( &self, Data(app): Data<&Arc>, @@ -402,7 +409,7 @@ impl RelayerApi { } /// Relayer RPC - #[oai(path = "/:api_token/rpc", method = "post")] + #[oai(path = "/:api_token/rpc", method = "post", operation_id = "call_rpc", tag = "OpenAPITags::RelayerV1")] async fn relayer_rpc( &self, Data(app): Data<&Arc>, @@ -453,7 +460,7 @@ enum ServiceResponse { #[OpenApi] impl ServiceApi { /// Health - #[oai(path = "/health", method = "get")] + #[oai(path = "/health", method = "get", operation_id = "health", tag = "OpenAPITags::Service")] async fn health(&self) -> ServiceResponse { ServiceResponse::Healthy } diff --git a/tests/create_relayer_new_api.rs b/tests/create_relayer_new_api.rs new file mode 100644 index 0000000..c94304f --- /dev/null +++ b/tests/create_relayer_new_api.rs @@ -0,0 +1,34 @@ +mod common; + +use tx_sitter_client::apis::admin_v1_api::CreateRelayerParams; +use tx_sitter_client::models::{CreateRelayerRequest, CreateRelayerResponse}; +use crate::common::prelude::*; + +#[tokio::test] +async fn create_relayer_new_api() -> eyre::Result<()> { + setup_tracing(); + + let (db_url, _db_container) = setup_db().await?; + let anvil = AnvilBuilder::default().spawn().await?; + + let (service, client) = + ServiceBuilder::default().build(&anvil, &db_url).await?; + + let configuration = + tx_sitter_client::apis::configuration::ConfigurationBuilder::new() + .base_path(format!("http://{}", service.local_addr())) + .basic_auth("".to_string(), Some("".to_string())) + .build(); + + let CreateRelayerResponse { .. } = tx_sitter_client::apis::admin_v1_api::create_relayer( + &configuration, + CreateRelayerParams{ + create_relayer_request: CreateRelayerRequest::new( + "Test relayer".to_string(), + DEFAULT_ANVIL_CHAIN_ID as i32, + ) + } + ).await?; + + Ok(()) +}