From 26b87c3949d324f33b0f7f881721f2107d82c725 Mon Sep 17 00:00:00 2001 From: shamardy <39480341+shamardy@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:58:21 +0300 Subject: [PATCH 1/2] chore(solana): remove solana implementation (#2239) The solana implementation was removed until it can be redone using the latest solana sdk --- Cargo.lock | 1851 ++--------------- mm2src/coins/Cargo.toml | 21 - mm2src/coins/lp_coins.rs | 152 -- mm2src/coins/solana.rs | 1098 ---------- mm2src/coins/solana/solana_common.rs | 181 -- mm2src/coins/solana/solana_common_tests.rs | 96 - .../coins/solana/solana_decode_tx_helpers.rs | 222 -- mm2src/coins/solana/solana_tests.rs | 436 ---- mm2src/coins/solana/spl.rs | 600 ------ mm2src/coins/solana/spl_tests.rs | 138 -- mm2src/coins_activation/Cargo.toml | 1 - mm2src/coins_activation/src/lib.rs | 14 - .../src/solana_with_tokens_activation.rs | 327 --- .../src/spl_token_activation.rs | 117 -- mm2src/mm2_main/Cargo.toml | 2 - mm2src/mm2_main/src/lp_ordermatch.rs | 6 +- mm2src/mm2_main/src/lp_swap.rs | 4 - .../mm2_main/src/rpc/dispatcher/dispatcher.rs | 18 - .../tests/docker_tests/docker_tests_common.rs | 23 - mm2src/mm2_main/tests/docker_tests/mod.rs | 1 - .../tests/docker_tests/solana_tests.rs | 144 -- mm2src/mm2_test_helpers/src/for_tests.rs | 47 - mm2src/mm2_test_helpers/src/structs.rs | 8 - 23 files changed, 151 insertions(+), 5356 deletions(-) delete mode 100644 mm2src/coins/solana.rs delete mode 100644 mm2src/coins/solana/solana_common.rs delete mode 100644 mm2src/coins/solana/solana_common_tests.rs delete mode 100644 mm2src/coins/solana/solana_decode_tx_helpers.rs delete mode 100644 mm2src/coins/solana/solana_tests.rs delete mode 100644 mm2src/coins/solana/spl.rs delete mode 100644 mm2src/coins/solana/spl_tests.rs delete mode 100644 mm2src/coins_activation/src/solana_with_tokens_activation.rs delete mode 100644 mm2src/coins_activation/src/spl_token_activation.rs delete mode 100644 mm2src/mm2_main/tests/docker_tests/solana_tests.rs diff --git a/Cargo.lock b/Cargo.lock index 08a985285b..cf62d3f115 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -119,12 +119,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "aliasable" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" - [[package]] name = "android_system_properties" version = "0.1.5" @@ -134,15 +128,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.42" @@ -186,12 +171,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - [[package]] name = "async-io" version = "1.13.0" @@ -261,7 +240,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -278,7 +257,7 @@ version = "0.1.76" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -391,12 +370,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base32" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" - [[package]] name = "base58" version = "0.2.0" @@ -409,12 +382,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" @@ -471,15 +438,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bip32" version = "0.2.2" @@ -610,20 +568,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "blake3" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" -dependencies = [ - "arrayref", - "arrayvec 0.7.1", - "cc", - "cfg-if 1.0.0", - "constant_time_eq", - "digest 0.10.7", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -695,51 +639,6 @@ dependencies = [ "serde_with", ] -[[package]] -name = "borsh" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" -dependencies = [ - "borsh-derive", - "hashbrown 0.11.2", -] - -[[package]] -name = "borsh-derive" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2 1.0.69", - "syn 1.0.95", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - [[package]] name = "bs58" version = "0.4.0" @@ -764,42 +663,12 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" -[[package]] -name = "bv" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" -dependencies = [ - "feature-probe", - "serde", -] - [[package]] name = "byte-slice-cast" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c1bf4a04a88c54f589125563643d773f3254b5c38571395e2b591c693bbc81" -[[package]] -name = "bytemuck" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -825,44 +694,12 @@ dependencies = [ "serde", ] -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "cache-padded" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24508e28c677875c380c20f4d28124fab6f8ed4ef929a1397d7b1a31e92f1005" -[[package]] -name = "caps" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61bf7211aad104ce2769ec05efcdfabf85ee84ac92461d142f22cf8badd0e54c" -dependencies = [ - "errno 0.2.8", - "libc", - "thiserror", -] - [[package]] name = "cbc" version = "0.1.2" @@ -877,9 +714,6 @@ name = "cc" version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -965,21 +799,6 @@ dependencies = [ "inout", ] -[[package]] -name = "clap" -version = "2.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "cloudabi" version = "0.0.3" @@ -989,15 +808,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -1016,7 +826,6 @@ dependencies = [ "async-trait", "base58", "base64 0.21.7", - "bincode", "bip32", "bitcoin", "bitcoin_hashes", @@ -1035,7 +844,6 @@ dependencies = [ "derive_more", "dirs", "ed25519-dalek", - "ed25519-dalek-bip32 0.2.0", "enum_derives", "ethabi", "ethcore-transaction", @@ -1080,7 +888,7 @@ dependencies = [ "mocktopus", "nom", "num-traits", - "parking_lot 0.12.0", + "parking_lot", "primitives", "prost", "prost-build", @@ -1095,7 +903,6 @@ dependencies = [ "rpc_task", "rust-ini", "rustls 0.21.10", - "satomic-swap", "script", "secp256k1 0.20.3", "secp256k1 0.24.3", @@ -1110,11 +917,6 @@ dependencies = [ "sha2 0.10.7", "sha3 0.9.1", "sia-rust", - "solana-client", - "solana-sdk", - "solana-transaction-status", - "spl-associated-token-account", - "spl-token", "spv_validation", "tendermint-rpc", "time 0.3.20", @@ -1164,7 +966,7 @@ dependencies = [ "mm2_metamask", "mm2_metrics", "mm2_number", - "parking_lot 0.12.0", + "parking_lot", "rpc", "rpc_task", "ser_error", @@ -1208,7 +1010,7 @@ dependencies = [ "libc", "lightning", "log", - "parking_lot 0.12.0", + "parking_lot", "parking_lot_core 0.6.2", "primitive-types", "rand 0.7.3", @@ -1250,21 +1052,6 @@ dependencies = [ "crossbeam-utils 0.8.16", ] -[[package]] -name = "console" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" -dependencies = [ - "encode_unicode", - "libc", - "once_cell", - "regex", - "terminal_size", - "unicode-width", - "winapi", -] - [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -1275,16 +1062,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "console_log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" -dependencies = [ - "log", - "web-sys", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -1556,7 +1333,7 @@ dependencies = [ "mm2_eth", "mm2_metamask", "num-traits", - "parking_lot 0.12.0", + "parking_lot", "primitives", "rpc", "rpc_task", @@ -1607,16 +1384,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "crypto-mac" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bcd97a54c7ca5ce2f6eb16f6bede5b0ab5f0055fedc17d2f0b4466e21671ca" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "crypto-mac" version = "0.11.1" @@ -1723,7 +1490,7 @@ dependencies = [ "cc", "codespan-reporting", "lazy_static", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "scratch", "syn 1.0.95", @@ -1741,7 +1508,7 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b846f081361125bfc8dc9d3940c84e1fd83ba54bbca7b17cd29483c828be0704" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -1764,9 +1531,9 @@ checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", - "strsim 0.10.0", + "strsim", "syn 1.0.95", ] @@ -1781,17 +1548,6 @@ dependencies = [ "syn 1.0.95", ] -[[package]] -name = "dashmap" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" -dependencies = [ - "cfg-if 1.0.0", - "num_cpus", - "rayon", -] - [[package]] name = "data-encoding" version = "2.4.0" @@ -1843,55 +1599,17 @@ dependencies = [ "zeroize", ] -[[package]] -name = "derivation-path" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193388a8c8c75a490b604ff61775e236541b8975e98e5ca1f6ea97d122b7e2db" -dependencies = [ - "failure", -] - -[[package]] -name = "derivation-path" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - [[package]] name = "derive_more" version = "0.99.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] -[[package]] -name = "dialoguer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61579ada4ec0c6031cfac3f86fdba0d195a7ebeb5e36693bd53cb5999a25beeb" -dependencies = [ - "console", - "lazy_static", - "tempfile", - "zeroize", -] - [[package]] name = "digest" version = "0.9.0" @@ -1913,15 +1631,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dir-diff" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2860407d7d7e2e004bb2128510ad9e8d669e76fa005ccf567977b5d71b8b4a0b" -dependencies = [ - "walkdir", -] - [[package]] name = "directories" version = "3.0.2" @@ -1942,16 +1651,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if 1.0.0", - "dirs-sys-next", -] - [[package]] name = "dirs-sys" version = "0.3.6" @@ -1963,40 +1662,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users 0.4.0", - "winapi", -] - -[[package]] -name = "dlopen" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e80ad39f814a9abe68583cd50a2d45c8a67561c3361ab8da240587dda80937" -dependencies = [ - "dlopen_derive", - "lazy_static", - "libc", - "winapi", -] - -[[package]] -name = "dlopen_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f236d9e1b1fbd81cea0f9cbdc8dcc7e8ebcd80e6659cd7cb2ad5f6c05946c581" -dependencies = [ - "libc", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "dtoa" version = "1.0.2" @@ -2065,31 +1730,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ed25519-dalek-bip32" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057f328f31294b5ab432e6c39642f54afd1531677d6d4ba2905932844cc242f3" -dependencies = [ - "derivation-path 0.1.3", - "ed25519-dalek", - "failure", - "hmac 0.9.0", - "sha2 0.9.9", -] - -[[package]] -name = "ed25519-dalek-bip32" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" -dependencies = [ - "derivation-path 0.2.0", - "ed25519-dalek", - "hmac 0.12.1", - "sha2 0.10.7", -] - [[package]] name = "edit-distance" version = "2.1.0" @@ -2121,12 +1761,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - [[package]] name = "encoding_rs" version = "0.8.28" @@ -2149,7 +1783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ "heck", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -2170,7 +1804,7 @@ name = "enum_derives" version = "0.1.0" dependencies = [ "itertools", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -2326,28 +1960,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", - "synstructure", -] - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -2369,12 +1981,6 @@ dependencies = [ "instant", ] -[[package]] -name = "feature-probe" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" - [[package]] name = "ff" version = "0.8.0" @@ -2402,18 +2008,6 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" -[[package]] -name = "filetime" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.2.10", - "winapi", -] - [[package]] name = "findshlibs" version = "0.5.0" @@ -2604,7 +2198,7 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -2688,22 +2282,11 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "serde", "typenum", "version_check", "zeroize", ] -[[package]] -name = "gethostname" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "getrandom" version = "0.1.14" @@ -2929,17 +2512,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" -[[package]] -name = "hidapi" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b1717343691998deb81766bfcd1dce6df0d5d6c37070b5a3de2bb6d39f7822" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "hkd32" version = "0.6.0" @@ -2962,16 +2534,6 @@ dependencies = [ "digest 0.9.0", ] -[[package]] -name = "hmac" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deae6d9dbb35ec2c502d62b8f7b1c000a0822c3b0794ba36b3149c0a1c840dff" -dependencies = [ - "crypto-mac 0.9.1", - "digest 0.9.0", -] - [[package]] name = "hmac" version = "0.11.0" @@ -3264,7 +2826,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -3275,12 +2837,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" -[[package]] -name = "index_list" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9d968042a4902e08810946fc7cd5851eb75e80301342305af755ca06cb82ce" - [[package]] name = "indexmap" version = "1.9.3" @@ -3301,18 +2857,6 @@ dependencies = [ "hashbrown 0.14.3", ] -[[package]] -name = "indicatif" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b" -dependencies = [ - "console", - "lazy_static", - "number_prefix", - "regex", -] - [[package]] name = "inout" version = "0.1.3" @@ -3414,15 +2958,6 @@ dependencies = [ "libc", ] -[[package]] -name = "jobserver" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.64" @@ -3542,16 +3077,6 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if 1.0.0", - "winapi", -] - [[package]] name = "libm" version = "0.1.4" @@ -3634,7 +3159,7 @@ dependencies = [ "multihash", "multistream-select", "once_cell", - "parking_lot 0.12.0", + "parking_lot", "pin-project", "quick-protobuf", "rand 0.8.4", @@ -3654,7 +3179,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", - "parking_lot 0.12.0", + "parking_lot", "smallvec 1.6.1", "trust-dns-resolver", ] @@ -3740,7 +3265,7 @@ dependencies = [ "asn1_der", "bs58 0.5.0", "ed25519-dalek", - "libsecp256k1 0.7.0", + "libsecp256k1", "log", "multihash", "quick-protobuf", @@ -3873,7 +3398,7 @@ source = "git+https://github.com/KomodoPlatform/rust-libp2p.git?tag=k-0.52.4#6fc dependencies = [ "heck", "proc-macro-warning", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -3918,7 +3443,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", - "parking_lot 0.12.0", + "parking_lot", "quicksink", "rw-stream-sink", "soketto", @@ -3940,25 +3465,6 @@ dependencies = [ "yamux 0.13.1", ] -[[package]] -name = "libsecp256k1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" -dependencies = [ - "arrayref", - "base64 0.12.3", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core 0.2.2", - "libsecp256k1-gen-ecmult 0.2.1", - "libsecp256k1-gen-genmult 0.2.1", - "rand 0.7.3", - "serde", - "sha2 0.9.9", - "typenum", -] - [[package]] name = "libsecp256k1" version = "0.7.0" @@ -3969,26 +3475,15 @@ dependencies = [ "base64 0.13.0", "digest 0.9.0", "hmac-drbg", - "libsecp256k1-core 0.3.0", - "libsecp256k1-gen-ecmult 0.3.0", - "libsecp256k1-gen-genmult 0.3.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", "rand 0.8.4", "serde", "sha2 0.9.9", "typenum", ] -[[package]] -name = "libsecp256k1-core" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle", -] - [[package]] name = "libsecp256k1-core" version = "0.3.0" @@ -4000,31 +3495,13 @@ dependencies = [ "subtle", ] -[[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" -dependencies = [ - "libsecp256k1-core 0.2.2", -] - [[package]] name = "libsecp256k1-gen-ecmult" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" dependencies = [ - "libsecp256k1-core 0.3.0", -] - -[[package]] -name = "libsecp256k1-gen-genmult" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" -dependencies = [ - "libsecp256k1-core 0.2.2", + "libsecp256k1-core", ] [[package]] @@ -4033,7 +3510,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" dependencies = [ - "libsecp256k1-core 0.3.0", + "libsecp256k1-core", ] [[package]] @@ -4230,15 +3707,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memmap2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.5.6" @@ -4303,7 +3771,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddece26afd34c31585c74a4db0630c376df271c285d682d1e55012197830b6df" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -4485,7 +3953,7 @@ dependencies = [ "cfg-if 1.0.0", "common", "futures 0.3.28", - "parking_lot 0.12.0", + "parking_lot", "serde", "tokio", "wasm-bindgen-test", @@ -4600,7 +4068,7 @@ dependencies = [ "mocktopus", "num-traits", "parity-util-mem", - "parking_lot 0.12.0", + "parking_lot", "primitives", "prost", "prost-build", @@ -4656,7 +4124,7 @@ dependencies = [ "lazy_static", "mm2_err_handle", "mm2_eth", - "parking_lot 0.12.0", + "parking_lot", "serde", "serde_derive", "serde_json", @@ -4711,7 +4179,7 @@ dependencies = [ "mm2_event_stream", "mm2_p2p", "mm2_state_machine", - "parking_lot 0.12.0", + "parking_lot", "pin-project", "prost", "rand 0.7.3", @@ -4845,7 +4313,7 @@ version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3048ef3680533a27f9f8e7d6a0bce44dc61e4895ea0f42709337fa1c8616fefe" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -4984,19 +4452,6 @@ dependencies = [ "smallvec 1.6.1", ] -[[package]] -name = "nix" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" -dependencies = [ - "bitflags", - "cc", - "cfg-if 1.0.0", - "libc", - "memoffset 0.6.4", -] - [[package]] name = "nix" version = "0.24.3" @@ -5045,7 +4500,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -5092,34 +4547,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9bd055fb730c4f8f4f57d45d35cd6b3f0980535b056dc7ff119cee6a66ed6f" -dependencies = [ - "derivative", - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486ea01961c4a818096de679a8b740b26d9033146ac5291b1c98557658f8cdd9" -dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "object" version = "0.29.0" @@ -5156,30 +4583,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "ouroboros" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f357ef82d1b4db66fbed0b8d542cbd3c22d0bf5b393b3c257b9ba4568e70c9c3" -dependencies = [ - "aliasable", - "ouroboros_macro", - "stable_deref_trait", -] - -[[package]] -name = "ouroboros_macro" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44a0b52c2cbaef7dffa5fec1a43274afe8bd2a644fa9fc50a9ef4ff0269b1257" -dependencies = [ - "Inflector", - "proc-macro-error", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", -] - [[package]] name = "packed_simd_2" version = "0.3.8" @@ -5220,8 +4623,8 @@ version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8" dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2 1.0.69", + "proc-macro-crate", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -5238,7 +4641,7 @@ dependencies = [ "impl-trait-for-tuples", "lru 0.7.5", "parity-util-mem-derive", - "parking_lot 0.12.0", + "parking_lot", "primitive-types", "smallvec 1.6.1", "winapi", @@ -5250,7 +4653,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "syn 1.0.95", "synstructure", ] @@ -5267,17 +4670,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" -[[package]] -name = "parking_lot" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.0", -] - [[package]] name = "parking_lot" version = "0.12.0" @@ -5295,7 +4687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" dependencies = [ "cfg-if 0.1.10", - "cloudabi 0.0.3", + "cloudabi", "libc", "redox_syscall 0.1.56", "rustc_version 0.2.3", @@ -5303,21 +4695,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot_core" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.1.0", - "instant", - "libc", - "redox_syscall 0.1.56", - "smallvec 1.6.1", - "winapi", -] - [[package]] name = "parking_lot_core" version = "0.9.1" @@ -5348,24 +4725,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" -[[package]] -name = "pbkdf2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" -dependencies = [ - "crypto-mac 0.8.0", -] - -[[package]] -name = "pbkdf2" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" -dependencies = [ - "crypto-mac 0.11.1", -] - [[package]] name = "peg" version = "0.7.0" @@ -5383,7 +4742,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" dependencies = [ "peg-runtime", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", ] @@ -5433,7 +4792,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -5535,7 +4894,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "syn 1.0.95", ] @@ -5563,15 +4922,6 @@ dependencies = [ "uint", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -5582,50 +4932,17 @@ dependencies = [ "toml", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.95", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "version_check", -] - [[package]] name = "proc-macro-warning" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.69" @@ -5643,7 +4960,7 @@ checksum = "78c2f43e8969d51935d2a7284878ae053ba30034cd563f673cde37ba5205685e" dependencies = [ "dtoa", "itoa 1.0.10", - "parking_lot 0.12.0", + "parking_lot", "prometheus-client-derive-encode", ] @@ -5653,7 +4970,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -5698,7 +5015,7 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -5749,15 +5066,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "qstring" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d464fae65fff2680baf48019211ce37aaec0c78e9264c84a3e484717f965104e" -dependencies = [ - "percent-encoding", -] - [[package]] name = "quanta" version = "0.11.1" @@ -5818,22 +5126,13 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", ] [[package]] @@ -6025,7 +5324,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ - "cloudabi 0.0.3", + "cloudabi", "fuchsia-cprng", "libc", "rand_core 0.4.2", @@ -6072,35 +5371,10 @@ dependencies = [ ] [[package]] -name = "rayon" -version = "1.5.1" +name = "rcgen" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" -dependencies = [ - "autocfg 1.1.0", - "crossbeam-deque 0.8.1", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" -dependencies = [ - "crossbeam-channel 0.5.1", - "crossbeam-deque 0.8.1", - "crossbeam-utils 0.8.16", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" +checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring 0.16.20", @@ -6168,7 +5442,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c523ccaed8ac4b0288948849a350b37d3035827413c458b6a40ddb614bb4f72" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -6329,16 +5603,6 @@ dependencies = [ "serde", ] -[[package]] -name = "rpassword" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "rpc" version = "0.1.0" @@ -6381,7 +5645,7 @@ dependencies = [ "log", "netlink-packet-route", "netlink-proto", - "nix 0.24.3", + "nix", "thiserror", "tokio", ] @@ -6598,14 +5862,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "satomic-swap" -version = "0.1.0" -source = "git+https://github.com/KomodoPlatform/satomic-swap.git?rev=413e472#413e4725a97f2c4d5d34101b3d2c49009c95cb28" -dependencies = [ - "solana-program", -] - [[package]] name = "scale-info" version = "2.1.2" @@ -6624,8 +5880,8 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" dependencies = [ - "proc-macro-crate 1.1.3", - "proc-macro2 1.0.69", + "proc-macro-crate", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -6809,7 +6065,7 @@ dependencies = [ name = "ser_error_derive" version = "0.1.0" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "ser_error", "syn 1.0.95", @@ -6850,7 +6106,7 @@ version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -6873,7 +6129,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dc6b7951b17b051f3210b063f12cc17320e2fe30ae05b0fe2a3abb068551c76" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -6907,23 +6163,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" dependencies = [ "darling", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] -[[package]] -name = "serde_yaml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0" -dependencies = [ - "indexmap 1.9.3", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "serialization" version = "0.1.0" @@ -7077,725 +6321,112 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1" -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" - -[[package]] -name = "smol" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" -dependencies = [ - "async-task", - "blocking", - "concurrent-queue 1.1.1", - "fastrand", - "futures-io", - "futures-util", - "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2 0.3.19", - "wepoll-sys-stjepang", - "winapi", -] - -[[package]] -name = "snow" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" -dependencies = [ - "aes-gcm", - "blake2", - "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", - "rand_core 0.6.4", - "ring 0.16.20", - "rustc_version 0.4.0", - "sha2 0.10.7", - "subtle", -] - -[[package]] -name = "socket2" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "soketto" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083624472e8817d44d02c0e55df043737ff11f279af924abdf93845717c2b75c" -dependencies = [ - "base64 0.13.0", - "bytes 1.4.0", - "futures 0.3.28", - "httparse", - "log", - "rand 0.8.4", - "sha-1", -] - -[[package]] -name = "solana-account-decoder" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea8c1862fc46c6ab40d83d15ced24a7afb1f3422da5824f1e9260f5ac10141f" -dependencies = [ - "Inflector", - "base64 0.12.3", - "bincode", - "bs58 0.4.0", - "bv", - "lazy_static", - "serde", - "serde_derive", - "serde_json", - "solana-config-program", - "solana-sdk", - "solana-vote-program", - "spl-token", - "thiserror", - "zstd", -] - -[[package]] -name = "solana-address-lookup-table-program" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c60728aec35d772e6614319558cdccbe3f845102699b65ba5ac7497da0b626a" -dependencies = [ - "bincode", - "bytemuck", - "log", - "num-derive", - "num-traits", - "rustc_version 0.4.0", - "serde", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-program-runtime", - "solana-sdk", - "thiserror", -] - -[[package]] -name = "solana-bloom" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ddcd7c6adb802bc812a5a80c8de06ba0f0e8df0cca296a8b4e67cd04c16218f" -dependencies = [ - "bv", - "fnv", - "log", - "rand 0.7.3", - "rayon", - "rustc_version 0.4.0", - "serde", - "serde_derive", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-sdk", -] - -[[package]] -name = "solana-bucket-map" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3435b145894971a58a08a7b6be997ec782239fdecd5edd9846cd1d6aa5986" -dependencies = [ - "fs_extra", - "log", - "memmap2", - "rand 0.7.3", - "rayon", - "solana-logger", - "solana-measure", - "solana-sdk", - "tempfile", -] - -[[package]] -name = "solana-clap-utils" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8417a89c377728dbfbf1966b6493544f6e5e168ebc5bb444f3526481fae94e31" -dependencies = [ - "chrono", - "clap", - "rpassword", - "solana-perf", - "solana-remote-wallet", - "solana-sdk", - "thiserror", - "tiny-bip39", - "uriparse", - "url", -] - -[[package]] -name = "solana-cli-config" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e8b011d36369ef2bc3dff63fee078bf2916a4fd21f3aa702ee731c7ddf83d28" -dependencies = [ - "dirs-next", - "lazy_static", - "serde", - "serde_derive", - "serde_yaml", - "url", -] - -[[package]] -name = "solana-client" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e20f4df8cee4a1819f1c5b0d3d85d50c30f27133b2ae68c2fd92655e4aede34a" -dependencies = [ - "base64 0.13.0", - "bincode", - "bs58 0.4.0", - "clap", - "indicatif", - "jsonrpc-core", - "log", - "rayon", - "reqwest", - "semver 1.0.6", - "serde", - "serde_derive", - "serde_json", - "solana-account-decoder", - "solana-clap-utils", - "solana-faucet", - "solana-measure", - "solana-net-utils", - "solana-sdk", - "solana-transaction-status", - "solana-version", - "solana-vote-program", - "thiserror", - "tokio", - "tungstenite", - "url", -] - -[[package]] -name = "solana-compute-budget-program" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685567c221f6bb5b64387f7b45d03036ad112b2ecbcd0f94b11204efab9f891e" -dependencies = [ - "solana-program-runtime", - "solana-sdk", -] - -[[package]] -name = "solana-config-program" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f4b04403ff77f09eba5cf94078c1178161e26d346245b06180866ab5286fe6b" -dependencies = [ - "bincode", - "chrono", - "serde", - "serde_derive", - "solana-program-runtime", - "solana-sdk", -] - -[[package]] -name = "solana-faucet" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a11e1b6d5ce435bb3df95f2a970cd80500a8abf94ea87558c35fe0cce8456ab" -dependencies = [ - "bincode", - "byteorder", - "clap", - "log", - "serde", - "serde_derive", - "solana-clap-utils", - "solana-cli-config", - "solana-logger", - "solana-metrics", - "solana-sdk", - "solana-version", - "spl-memo", - "thiserror", - "tokio", -] - -[[package]] -name = "solana-frozen-abi" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f69a79200f5ba439eb8b790c5e00beab4d1fae4da69ce023c69c6ac1b55bf1" -dependencies = [ - "bs58 0.4.0", - "bv", - "generic-array", - "log", - "memmap2", - "rustc_version 0.4.0", - "serde", - "serde_derive", - "sha2 0.9.9", - "solana-frozen-abi-macro", - "solana-logger", - "thiserror", -] - -[[package]] -name = "solana-frozen-abi-macro" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402fffb54bf5d335e6df26fc1719feecfbd7a22fafdf6649fe78380de3c47384" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "rustc_version 0.4.0", - "syn 1.0.95", -] - -[[package]] -name = "solana-logger" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942dc59fc9da66d178362051b658646b65dc11cea0bc804e4ecd2528d3c1279f" -dependencies = [ - "env_logger", - "lazy_static", - "log", -] - -[[package]] -name = "solana-measure" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ccd5b1278b115249d6ca5a203fd852f7d856e048488c24442222ee86e682bd9" -dependencies = [ - "log", - "solana-sdk", -] - -[[package]] -name = "solana-metrics" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9774cd8309f599797b1612731fbc56df6c612879ab4923a3dc7234400eea419" -dependencies = [ - "env_logger", - "gethostname", - "lazy_static", - "log", - "reqwest", - "solana-sdk", -] - -[[package]] -name = "solana-net-utils" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cb530af085d8aab563530ed39703096aa526249d350082823882fdd59cdf839" -dependencies = [ - "bincode", - "clap", - "log", - "nix 0.23.1", - "rand 0.7.3", - "serde", - "serde_derive", - "socket2 0.4.9", - "solana-logger", - "solana-sdk", - "solana-version", - "tokio", - "url", -] - -[[package]] -name = "solana-perf" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4117c0cf7753bc18f3a09f4973175c3f2c7c5d8e3c9bc15cab09060b06f3434f" -dependencies = [ - "ahash 0.7.6", - "bincode", - "bv", - "caps", - "curve25519-dalek 3.2.0", - "dlopen", - "dlopen_derive", - "fnv", - "lazy_static", - "libc", - "log", - "nix 0.23.1", - "rand 0.7.3", - "rayon", - "serde", - "solana-bloom", - "solana-logger", - "solana-metrics", - "solana-rayon-threadlimit", - "solana-sdk", - "solana-vote-program", -] - -[[package]] -name = "solana-program" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a463f546a2f5842d35974bd4691ae5ceded6785ec24db440f773723f6ce4e11" -dependencies = [ - "base64 0.13.0", - "bincode", - "bitflags", - "blake3", - "borsh", - "borsh-derive", - "bs58 0.4.0", - "bv", - "bytemuck", - "console_error_panic_hook", - "console_log", - "curve25519-dalek 3.2.0", - "getrandom 0.1.14", - "itertools", - "js-sys", - "lazy_static", - "libsecp256k1 0.6.0", - "log", - "num-derive", - "num-traits", - "parking_lot 0.11.1", - "rand 0.7.3", - "rustc_version 0.4.0", - "rustversion", - "serde", - "serde_bytes", - "serde_derive", - "sha2 0.9.9", - "sha3 0.9.1", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-sdk-macro", - "thiserror", - "wasm-bindgen", -] - -[[package]] -name = "solana-program-runtime" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09841673334eab958d5bedab9c9d75ed2ff7a7ef70e7dfd6b239c6838a3d79ec" -dependencies = [ - "base64 0.13.0", - "bincode", - "itertools", - "libc", - "libloading", - "log", - "num-derive", - "num-traits", - "rustc_version 0.4.0", - "serde", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-measure", - "solana-sdk", - "thiserror", -] - -[[package]] -name = "solana-rayon-threadlimit" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92893e3129dfabb703cd045e1367f3ced91202a2d0b6179a3dcd62ad6bead3b" -dependencies = [ - "lazy_static", - "num_cpus", -] - -[[package]] -name = "solana-remote-wallet" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "315534baecaae3f804548ccc4738d73ae01bf6523219787ebe55ee66d8db9a85" -dependencies = [ - "base32", - "console", - "dialoguer", - "hidapi", - "log", - "num-derive", - "num-traits", - "parking_lot 0.11.1", - "qstring", - "semver 1.0.6", - "solana-sdk", - "thiserror", - "uriparse", -] - -[[package]] -name = "solana-runtime" -version = "1.9.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bd06e905260433f7e8d18bccb2e2eb2aa5cc53379d104d331ddeb12e13230a0" -dependencies = [ - "arrayref", - "bincode", - "blake3", - "bv", - "bytemuck", - "byteorder", - "bzip2", - "crossbeam-channel 0.5.1", - "dashmap", - "dir-diff", - "flate2", - "fnv", - "index_list", - "itertools", - "lazy_static", - "log", - "memmap2", - "num-derive", - "num-traits", - "num_cpus", - "ouroboros", - "rand 0.7.3", - "rayon", - "regex", - "rustc_version 0.4.0", - "serde", - "serde_derive", - "solana-address-lookup-table-program", - "solana-bloom", - "solana-bucket-map", - "solana-compute-budget-program", - "solana-config-program", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-measure", - "solana-metrics", - "solana-program-runtime", - "solana-rayon-threadlimit", - "solana-sdk", - "solana-stake-program", - "solana-vote-program", - "symlink", - "tar", - "tempfile", - "thiserror", - "zstd", +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg 1.1.0", ] [[package]] -name = "solana-sdk" -version = "1.9.20" +name = "smallvec" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6560e605c68fa1e3e66a9d3c8529d097d402e1183f80dd06a2c870d0ecb795c2" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" dependencies = [ - "assert_matches", - "base64 0.13.0", - "bincode", - "bitflags", - "borsh", - "bs58 0.4.0", - "bytemuck", - "byteorder", - "chrono", - "derivation-path 0.1.3", - "digest 0.9.0", - "ed25519-dalek", - "ed25519-dalek-bip32 0.1.1", - "generic-array", - "hmac 0.11.0", - "itertools", - "js-sys", - "lazy_static", - "libsecp256k1 0.6.0", - "log", - "memmap2", - "num-derive", - "num-traits", - "pbkdf2 0.9.0", - "qstring", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rustc_version 0.4.0", - "rustversion", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "sha2 0.9.9", - "sha3 0.9.1", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-program", - "solana-sdk-macro", - "thiserror", - "uriparse", - "wasm-bindgen", + "maybe-uninit", ] [[package]] -name = "solana-sdk-macro" -version = "1.9.20" +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "smol" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c834b4e02ac911b13c13aed08b3f847e722f6be79d31b1c660c1dbd2dee83cdb" +checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" dependencies = [ - "bs58 0.4.0", - "proc-macro2 1.0.69", - "quote 1.0.33", - "rustversion", - "syn 1.0.95", + "async-task", + "blocking", + "concurrent-queue 1.1.1", + "fastrand", + "futures-io", + "futures-util", + "libc", + "once_cell", + "scoped-tls", + "slab", + "socket2 0.3.19", + "wepoll-sys-stjepang", + "winapi", ] [[package]] -name = "solana-stake-program" -version = "1.9.20" +name = "snow" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92597c0ed16d167d5ee48e5b13e92dfaed9c55b23a13ec261440136cd418649" +checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" dependencies = [ - "bincode", - "log", - "num-derive", - "num-traits", + "aes-gcm", + "blake2", + "chacha20poly1305", + "curve25519-dalek 4.0.0-rc.1", + "rand_core 0.6.4", + "ring 0.16.20", "rustc_version 0.4.0", - "serde", - "serde_derive", - "solana-config-program", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-metrics", - "solana-program-runtime", - "solana-sdk", - "solana-vote-program", - "thiserror", + "sha2 0.10.7", + "subtle", ] [[package]] -name = "solana-transaction-status" -version = "1.9.20" +name = "socket2" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612a51efa19380992e81fc64a2fb55d42aed32c67d795848d980cbe1f9693250" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "Inflector", - "base64 0.12.3", - "bincode", - "bs58 0.4.0", - "lazy_static", - "log", - "serde", - "serde_derive", - "serde_json", - "solana-account-decoder", - "solana-measure", - "solana-metrics", - "solana-runtime", - "solana-sdk", - "solana-vote-program", - "spl-associated-token-account", - "spl-memo", - "spl-token", - "thiserror", + "cfg-if 1.0.0", + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", ] [[package]] -name = "solana-version" -version = "1.9.20" +name = "socket2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222e2c91640d45cd9617dfc07121555a9bdac10e6e105f6931b758f46db6faaa" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" dependencies = [ - "log", - "rustc_version 0.4.0", - "serde", - "serde_derive", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-sdk", + "libc", + "windows-sys 0.48.0", ] [[package]] -name = "solana-vote-program" -version = "1.9.20" +name = "soketto" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4cc64945010e9e76d368493ad091aa5cf43ee16f69296290ebb5c815e433232" +checksum = "083624472e8817d44d02c0e55df043737ff11f279af924abdf93845717c2b75c" dependencies = [ - "bincode", + "base64 0.13.0", + "bytes 1.4.0", + "futures 0.3.28", + "httparse", "log", - "num-derive", - "num-traits", - "rustc_version 0.4.0", - "serde", - "serde_derive", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-metrics", - "solana-program-runtime", - "solana-sdk", - "thiserror", + "rand 0.8.4", + "sha-1", ] [[package]] @@ -7829,7 +6460,7 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d676664972e22a0796176e81e7bec41df461d1edf52090955cdab55f2c956ff2" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -7858,8 +6489,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ecb916b9664ed9f90abef0ff5a3e61454c1efea5861b2997e03f39b59b955f" dependencies = [ "Inflector", - "proc-macro-crate 1.1.3", - "proc-macro2 1.0.69", + "proc-macro-crate", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", ] @@ -7943,39 +6574,6 @@ dependencies = [ "der", ] -[[package]] -name = "spl-associated-token-account" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "393e2240d521c3dd770806bff25c2c00d761ac962be106e14e22dd912007f428" -dependencies = [ - "solana-program", - "spl-token", -] - -[[package]] -name = "spl-memo" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325" -dependencies = [ - "solana-program", -] - -[[package]] -name = "spl-token" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93bfdd5bd7c869cb565c7d7635c4fafe189b988a0bdef81063cd9585c6b8dc01" -dependencies = [ - "arrayref", - "num-derive", - "num-traits", - "num_enum", - "solana-program", - "thiserror", -] - [[package]] name = "spv_validation" version = "0.1.0" @@ -8013,31 +6611,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f9799e6d412271cb2414597581128b03f3285f260ea49f5363d07df6a332b3e" dependencies = [ "Inflector", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "serde", "serde_json", "unicode-xid 0.2.0", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -8065,12 +6651,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "symlink" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" - [[package]] name = "syn" version = "0.11.11" @@ -8082,24 +6662,13 @@ dependencies = [ "unicode-xid 0.0.4", ] -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - [[package]] name = "syn" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "unicode-ident", ] @@ -8110,7 +6679,7 @@ version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "unicode-ident", ] @@ -8136,7 +6705,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", "unicode-xid 0.2.0", @@ -8169,17 +6738,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tar" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" -dependencies = [ - "filetime", - "libc", - "xattr", -] - [[package]] name = "tempfile" version = "3.4.0" @@ -8293,16 +6851,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "test_helpers" version = "0.1.0" @@ -8327,15 +6875,6 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -8351,7 +6890,7 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -8394,25 +6933,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tiny-bip39" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" -dependencies = [ - "anyhow", - "hmac 0.8.1", - "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", - "rustc-hash", - "sha2 0.9.9", - "thiserror", - "unicode-normalization", - "wasm-bindgen", - "zeroize", -] - [[package]] name = "tiny-keccak" version = "1.4.4" @@ -8457,7 +6977,6 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.0", "pin-project-lite 0.2.9", "signal-hook-registry", "socket2 0.4.9", @@ -8491,7 +7010,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -8624,7 +7143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" dependencies = [ "prettyplease", - "proc-macro2 1.0.69", + "proc-macro2", "prost-build", "quote 1.0.33", "syn 1.0.95", @@ -8680,7 +7199,7 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", ] @@ -8790,7 +7309,7 @@ dependencies = [ "ipconfig", "lazy_static", "lru-cache", - "parking_lot 0.12.0", + "parking_lot", "resolv-conf", "smallvec 1.6.1", "thiserror", @@ -8824,7 +7343,6 @@ dependencies = [ "url", "utf-8", "webpki", - "webpki-roots 0.22.3", ] [[package]] @@ -8886,12 +7404,6 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -8930,16 +7442,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "uriparse" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e515b1ada404168e145ac55afba3c42f04cf972201a8552d42e2abb17c1b7221" -dependencies = [ - "fnv", - "lazy_static", -] - [[package]] name = "url" version = "2.2.2" @@ -9006,12 +7508,6 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -9132,7 +7628,7 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", "wasm-bindgen-shared", @@ -9166,7 +7662,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 2.0.38", "wasm-bindgen-backend", @@ -9199,7 +7695,7 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c2e18093f11c19ca4e188c177fecc7c372304c311189f12c2f9bea5b7324ac7" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", ] @@ -9233,7 +7729,7 @@ dependencies = [ "js-sys", "jsonrpc-core", "log", - "parking_lot 0.12.0", + "parking_lot", "pin-project", "rand 0.8.4", "reqwest", @@ -9605,24 +8101,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "xattr" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" -dependencies = [ - "libc", -] - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yamux" version = "0.12.1" @@ -9632,7 +8110,7 @@ dependencies = [ "futures 0.3.28", "log", "nohash-hasher", - "parking_lot 0.12.0", + "parking_lot", "pin-project", "rand 0.8.4", "static_assertions", @@ -9648,7 +8126,7 @@ dependencies = [ "instant", "log", "nohash-hasher", - "parking_lot 0.12.0", + "parking_lot", "pin-project", "rand 0.8.4", "static_assertions", @@ -9809,37 +8287,8 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ - "proc-macro2 1.0.69", + "proc-macro2", "quote 1.0.33", "syn 1.0.95", "synstructure", ] - -[[package]] -name = "zstd" -version = "0.9.2+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2390ea1bf6c038c39674f22d95f0564725fc06034a47129179810b2fc58caa54" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "4.1.3+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e99d81b99fb3c2c2c794e3fe56c305c63d5173a16a46b5850b07c935ffc7db79" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "1.6.2+zstd.1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2daf2f248d9ea44454bfcb2516534e8b8ad2fc91bf818a1885495fc42bc8ac9f" -dependencies = [ - "cc", - "libc", -] diff --git a/mm2src/coins/Cargo.toml b/mm2src/coins/Cargo.toml index c870e9baf0..62c0e24ea0 100644 --- a/mm2src/coins/Cargo.toml +++ b/mm2src/coins/Cargo.toml @@ -5,17 +5,6 @@ edition = "2018" [features] zhtlc-native-tests = [] -# TODO -enable-solana = [ - "dep:bincode", - "dep:ed25519-dalek-bip32", - "dep:solana-client", - "dep:solana-sdk", - "dep:solana-transaction-status", - "dep:spl-token", - "dep:spl-associated-token-account", - "dep:satomic-swap" -] enable-sia = [ "dep:reqwest", "dep:blake2b_simd", @@ -96,7 +85,6 @@ rlp = { version = "0.5" } rmp-serde = "0.14.3" rpc = { path = "../mm2_bitcoin/rpc" } rpc_task = { path = "../rpc_task" } -satomic-swap = { git = "https://github.com/KomodoPlatform/satomic-swap.git", rev = "413e472", optional = true } script = { path = "../mm2_bitcoin/script" } secp256k1 = { version = "0.20" } ser_error = { path = "../derives/ser_error" } @@ -125,15 +113,6 @@ zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.g zcash_extras = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.4.1" } zcash_primitives = {features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.4.1" } -[target.'cfg(all(not(target_os = "ios"), not(target_os = "android"), not(target_arch = "wasm32")))'.dependencies] -bincode = { version = "1.3.3", default-features = false, optional = true } -ed25519-dalek-bip32 = { version = "0.2.0", default-features = false, optional = true } -solana-client = { version = "1", default-features = false, optional = true } -solana-sdk = { version = "1", default-features = false, optional = true } -solana-transaction-status = { version = "1", optional = true } -spl-token = { version = "3", optional = true } -spl-associated-token-account = { version = "1", optional = true } - [target.'cfg(target_arch = "wasm32")'.dependencies] blake2b_simd = "0.5" ff = "0.8" diff --git a/mm2src/coins/lp_coins.rs b/mm2src/coins/lp_coins.rs index 500963fba8..3e5f55ce41 100644 --- a/mm2src/coins/lp_coins.rs +++ b/mm2src/coins/lp_coins.rs @@ -124,29 +124,6 @@ macro_rules! try_f { }; } -#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] -macro_rules! try_tx_fus_err { - ($err: expr) => { - return Box::new(futures01::future::err(crate::TransactionErr::Plain(ERRL!( - "{:?}", $err - )))) - }; -} - -#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] -macro_rules! try_tx_fus_opt { - ($e: expr, $err: expr) => { - match $e { - Some(ok) => ok, - None => { - return Box::new(futures01::future::err(crate::TransactionErr::Plain(ERRL!( - "{:?}", $err - )))) - }, - } - }; -} - /// `TransactionErr` compatible `try_fus` macro. macro_rules! try_tx_fus { ($e: expr) => { @@ -280,30 +257,6 @@ pub mod tx_history_storage; #[cfg(feature = "enable-sia")] pub mod siacoin; #[cfg(feature = "enable-sia")] use siacoin::SiaCoin; -#[doc(hidden)] -#[allow(unused_variables)] -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -pub mod solana; -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -pub use solana::spl::SplToken; -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -pub use solana::{SolTransaction, SolanaActivationParams, SolanaCoin, SolanaFeeDetails}; - pub mod utxo; use utxo::bch::{bch_coin_with_policy, BchActivationRequest, BchCoin}; use utxo::qtum::{self, qtum_coin_with_policy, Qrc20AddressError, QtumCoin, QtumDelegationOps, QtumDelegationRequest, @@ -631,8 +584,6 @@ pub trait Transaction: fmt::Debug + 'static { pub enum TransactionEnum { UtxoTx(UtxoTx), SignedEthTx(SignedEthTx), - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - SolTransaction(SolTransaction), ZTransaction(ZTransaction), CosmosTransaction(CosmosTransaction), #[cfg(not(target_arch = "wasm32"))] @@ -641,8 +592,6 @@ pub enum TransactionEnum { ifrom!(TransactionEnum, UtxoTx); ifrom!(TransactionEnum, SignedEthTx); -#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] -ifrom!(TransactionEnum, SolTransaction); ifrom!(TransactionEnum, ZTransaction); #[cfg(not(target_arch = "wasm32"))] ifrom!(TransactionEnum, LightningPayment); @@ -666,8 +615,6 @@ impl Deref for TransactionEnum { TransactionEnum::CosmosTransaction(ref t) => t, #[cfg(not(target_arch = "wasm32"))] TransactionEnum::LightningPayment(ref p) => p, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - TransactionEnum::SolTransaction(ref s) => s, } } } @@ -2271,13 +2218,6 @@ pub enum TxFeeDetails { Qrc20(Qrc20FeeDetails), Slp(SlpFeeDetails), Tendermint(TendermintFeeDetails), - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - Solana(SolanaFeeDetails), } /// Deserialize the TxFeeDetails as an untagged enum. @@ -2292,13 +2232,6 @@ impl<'de> Deserialize<'de> for TxFeeDetails { Utxo(UtxoFeeDetails), Eth(EthTxFeeDetails), Qrc20(Qrc20FeeDetails), - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - Solana(SolanaFeeDetails), Tendermint(TendermintFeeDetails), } @@ -2306,13 +2239,6 @@ impl<'de> Deserialize<'de> for TxFeeDetails { TxFeeDetailsUnTagged::Utxo(f) => Ok(TxFeeDetails::Utxo(f)), TxFeeDetailsUnTagged::Eth(f) => Ok(TxFeeDetails::Eth(f)), TxFeeDetailsUnTagged::Qrc20(f) => Ok(TxFeeDetails::Qrc20(f)), - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - TxFeeDetailsUnTagged::Solana(f) => Ok(TxFeeDetails::Solana(f)), TxFeeDetailsUnTagged::Tendermint(f) => Ok(TxFeeDetails::Tendermint(f)), } } @@ -2330,16 +2256,6 @@ impl From for TxFeeDetails { fn from(qrc20_details: Qrc20FeeDetails) -> Self { TxFeeDetails::Qrc20(qrc20_details) } } -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -impl From for TxFeeDetails { - fn from(solana_details: SolanaFeeDetails) -> Self { TxFeeDetails::Solana(solana_details) } -} - impl From for TxFeeDetails { fn from(tendermint_details: TendermintFeeDetails) -> Self { TxFeeDetails::Tendermint(tendermint_details) } } @@ -3544,20 +3460,6 @@ pub enum MmCoinEnum { SlpToken(SlpToken), Tendermint(TendermintCoin), TendermintToken(TendermintToken), - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - SolanaCoin(SolanaCoin), - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - SplToken(SplToken), #[cfg(not(target_arch = "wasm32"))] LightningCoin(LightningCoin), #[cfg(feature = "enable-sia")] @@ -3577,26 +3479,6 @@ impl From for MmCoinEnum { fn from(c: TestCoin) -> MmCoinEnum { MmCoinEnum::Test(c) } } -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -impl From for MmCoinEnum { - fn from(c: SolanaCoin) -> MmCoinEnum { MmCoinEnum::SolanaCoin(c) } -} - -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -impl From for MmCoinEnum { - fn from(c: SplToken) -> MmCoinEnum { MmCoinEnum::SplToken(c) } -} - impl From for MmCoinEnum { fn from(coin: QtumCoin) -> Self { MmCoinEnum::QtumCoin(coin) } } @@ -3654,20 +3536,6 @@ impl Deref for MmCoinEnum { #[cfg(feature = "enable-sia")] MmCoinEnum::SiaCoin(ref c) => c, MmCoinEnum::Test(ref c) => c, - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - MmCoinEnum::SolanaCoin(ref c) => c, - #[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") - ))] - MmCoinEnum::SplToken(ref c) => c, } } } @@ -4377,14 +4245,6 @@ pub enum CoinProtocol { network: BlockchainNetwork, confirmation_targets: PlatformCoinConfirmationTargets, }, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - SOLANA, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - SPLTOKEN { - platform: String, - token_contract_address: String, - decimals: u8, - }, ZHTLC(ZcoinProtocolInfo), #[cfg(feature = "enable-sia")] SIA, @@ -4646,14 +4506,6 @@ pub async fn lp_coininit(ctx: &MmArc, ticker: &str, req: &Json) -> Result return ERR!("NFT protocol is not supported by lp_coininit"), #[cfg(not(target_arch = "wasm32"))] CoinProtocol::LIGHTNING { .. } => return ERR!("Lightning protocol is not supported by lp_coininit"), - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - CoinProtocol::SOLANA => { - return ERR!("Solana protocol is not supported by lp_coininit - use enable_solana_with_tokens instead") - }, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - CoinProtocol::SPLTOKEN { .. } => { - return ERR!("SplToken protocol is not supported by lp_coininit - use enable_spl instead") - }, #[cfg(feature = "enable-sia")] CoinProtocol::SIA { .. } => { return ERR!("SIA protocol is not supported by lp_coininit. Use task::enable_sia::init"); @@ -5238,10 +5090,6 @@ pub fn address_by_coin_conf_and_pubkey_str( CoinProtocol::LIGHTNING { .. } => { ERR!("address_by_coin_conf_and_pubkey_str is not implemented for lightning protocol yet!") }, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - CoinProtocol::SOLANA | CoinProtocol::SPLTOKEN { .. } => { - ERR!("Solana pubkey is the public address - you do not need to use this rpc call.") - }, CoinProtocol::ZHTLC { .. } => ERR!("address_by_coin_conf_and_pubkey_str is not supported for ZHTLC protocol!"), #[cfg(feature = "enable-sia")] CoinProtocol::SIA { .. } => ERR!("address_by_coin_conf_and_pubkey_str is not supported for SIA protocol!"), // TODO Alright diff --git a/mm2src/coins/solana.rs b/mm2src/coins/solana.rs deleted file mode 100644 index 2b9abef1ca..0000000000 --- a/mm2src/coins/solana.rs +++ /dev/null @@ -1,1098 +0,0 @@ -use std::{collections::HashMap, - convert::{TryFrom, TryInto}, - fmt::Debug, - ops::Deref, - str::FromStr, - sync::{Arc, Mutex}}; - -use async_trait::async_trait; -use base58::ToBase58; -use bincode::{deserialize, serialize}; -use bitcrypto::sha256; -use common::{async_blocking, - executor::{abortable_queue::AbortableQueue, AbortableSystem, AbortedError}, - log::error, - now_sec}; -use crypto::HDPathToCoin; -use derive_more::Display; -use futures::{compat::Future01CompatExt, - {FutureExt, TryFutureExt}}; -use futures01::Future; -use keys::KeyPair; -use mm2_core::mm_ctx::MmArc; -use mm2_err_handle::prelude::*; -use mm2_number::{BigDecimal, MmNumber}; -use num_traits::ToPrimitive; -use rpc::v1::types::Bytes as BytesJson; -pub use satomic_swap::{instruction::AtomicSwapInstruction, STORAGE_SPACE_ALLOCATED}; -use serde_json::{self as json, Value as Json}; -use solana_client::{client_error::{ClientError, ClientErrorKind}, - rpc_client::RpcClient, - rpc_request::TokenAccountsFilter}; -pub use solana_sdk::transaction::Transaction as SolTransaction; -use solana_sdk::{commitment_config::{CommitmentConfig, CommitmentLevel}, - instruction::{AccountMeta, Instruction}, - native_token::sol_to_lamports, - program_error::ProgramError, - pubkey::{ParsePubkeyError, Pubkey}, - signature::{Keypair as SolKeypair, Signer}}; -use spl_token::solana_program; - -use super::{CoinBalance, HistorySyncState, MarketCoinOps, MmCoin, SwapOps, TradeFee, Transaction, TransactionEnum, - TransactionErr, WatcherOps}; -use crate::coin_errors::{MyAddressError, ValidatePaymentResult}; -use crate::hd_wallet::HDPathAccountToAddressId; -use crate::solana::{solana_common::{lamports_to_sol, PrepareTransferData, SufficientBalanceError}, - spl::SplTokenInfo}; -use crate::{BalanceError, BalanceFut, CheckIfMyPaymentSentArgs, CoinFutSpawner, ConfirmPaymentInput, DexFee, - FeeApproxStage, FoundSwapTxSpend, MakerSwapTakerCoin, MmCoinEnum, NegotiateSwapContractAddrErr, - PaymentInstructionArgs, PaymentInstructions, PaymentInstructionsErr, PrivKeyBuildPolicy, - PrivKeyPolicyNotAllowed, RawTransactionError, RawTransactionFut, RawTransactionRequest, - RawTransactionResult, RefundError, RefundPaymentArgs, RefundResult, SearchForSwapTxSpendInput, - SendMakerPaymentSpendPreimageInput, SendPaymentArgs, SignRawTransactionRequest, SignatureResult, - SpendPaymentArgs, TakerSwapMakerCoin, TradePreimageFut, TradePreimageResult, TradePreimageValue, - TransactionData, TransactionDetails, TransactionFut, TransactionResult, TransactionType, TxMarshalingErr, - UnexpectedDerivationMethod, ValidateAddressResult, ValidateFeeArgs, ValidateInstructionsErr, - ValidateOtherPubKeyErr, ValidatePaymentError, ValidatePaymentFut, ValidatePaymentInput, - ValidateWatcherSpendInput, VerificationResult, WaitForHTLCTxSpendArgs, WatcherReward, WatcherRewardError, - WatcherSearchForSwapTxSpendInput, WatcherValidatePaymentInput, WatcherValidateTakerFeeInput, - WithdrawError, WithdrawFut, WithdrawRequest, WithdrawResult}; - -pub mod solana_common; -mod solana_decode_tx_helpers; -pub mod spl; - -#[cfg(test)] mod solana_common_tests; -#[cfg(test)] mod solana_tests; -#[cfg(test)] mod spl_tests; - -pub const SOLANA_DEFAULT_DECIMALS: u64 = 9; -pub const LAMPORTS_DUMMY_AMOUNT: u64 = 10; - -#[async_trait] -pub trait SolanaCommonOps { - fn rpc(&self) -> &RpcClient; - - fn is_token(&self) -> bool; - - async fn check_balance_and_prepare_transfer( - &self, - max: bool, - amount: BigDecimal, - fees: u64, - ) -> Result>; -} - -impl From for BalanceError { - fn from(e: ClientError) -> Self { - match e.kind { - ClientErrorKind::Io(e) => BalanceError::Transport(e.to_string()), - ClientErrorKind::Reqwest(e) => BalanceError::Transport(e.to_string()), - ClientErrorKind::RpcError(e) => BalanceError::Transport(format!("{:?}", e)), - ClientErrorKind::SerdeJson(e) => BalanceError::InvalidResponse(e.to_string()), - ClientErrorKind::Custom(e) => BalanceError::Internal(e), - ClientErrorKind::SigningError(_) - | ClientErrorKind::TransactionError(_) - | ClientErrorKind::FaucetError(_) => BalanceError::Internal("not_reacheable".to_string()), - } - } -} - -impl From for BalanceError { - fn from(e: ParsePubkeyError) -> Self { BalanceError::Internal(format!("{:?}", e)) } -} - -impl From for WithdrawError { - fn from(e: ClientError) -> Self { - match e.kind { - ClientErrorKind::Io(e) => WithdrawError::Transport(e.to_string()), - ClientErrorKind::Reqwest(e) => WithdrawError::Transport(e.to_string()), - ClientErrorKind::RpcError(e) => WithdrawError::Transport(format!("{:?}", e)), - ClientErrorKind::SerdeJson(e) => WithdrawError::InternalError(e.to_string()), - ClientErrorKind::Custom(e) => WithdrawError::InternalError(e), - ClientErrorKind::SigningError(_) - | ClientErrorKind::TransactionError(_) - | ClientErrorKind::FaucetError(_) => WithdrawError::InternalError("not_reacheable".to_string()), - } - } -} - -impl From for WithdrawError { - fn from(e: ParsePubkeyError) -> Self { WithdrawError::InvalidAddress(format!("{:?}", e)) } -} - -impl From for WithdrawError { - fn from(e: ProgramError) -> Self { WithdrawError::InternalError(format!("{:?}", e)) } -} - -#[derive(Debug)] -pub enum AccountError { - NotFundedError(String), - ParsePubKeyError(String), - ClientError(ClientErrorKind), -} - -impl From for AccountError { - fn from(e: ClientError) -> Self { AccountError::ClientError(e.kind) } -} - -impl From for AccountError { - fn from(e: ParsePubkeyError) -> Self { AccountError::ParsePubKeyError(format!("{:?}", e)) } -} - -impl From for WithdrawError { - fn from(e: AccountError) -> Self { - match e { - AccountError::NotFundedError(_) => WithdrawError::ZeroBalanceToWithdrawMax, - AccountError::ParsePubKeyError(err) => WithdrawError::InternalError(err), - AccountError::ClientError(e) => WithdrawError::Transport(format!("{:?}", e)), - } - } -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct SolanaActivationParams { - confirmation_commitment: CommitmentLevel, - client_url: String, - #[serde(default)] - path_to_address: HDPathAccountToAddressId, -} - -#[derive(Debug, Display)] -pub enum SolanaFromLegacyReqErr { - InvalidCommitmentLevel(String), - InvalidClientParsing(json::Error), - ClientNoAvailableNodes(String), -} - -#[derive(Debug, Display)] -pub enum KeyPairCreationError { - #[display(fmt = "Signature error: {}", _0)] - SignatureError(ed25519_dalek::SignatureError), - #[display(fmt = "KeyPairFromSeed error: {}", _0)] - KeyPairFromSeed(String), -} - -impl From for KeyPairCreationError { - fn from(e: ed25519_dalek::SignatureError) -> Self { KeyPairCreationError::SignatureError(e) } -} - -fn generate_keypair_from_slice(priv_key: &[u8]) -> Result> { - let secret_key = ed25519_dalek::SecretKey::from_bytes(priv_key)?; - let public_key = ed25519_dalek::PublicKey::from(&secret_key); - let key_pair = ed25519_dalek::Keypair { - secret: secret_key, - public: public_key, - }; - solana_sdk::signature::keypair_from_seed(key_pair.to_bytes().as_ref()) - .map_to_mm(|e| KeyPairCreationError::KeyPairFromSeed(e.to_string())) -} - -pub async fn solana_coin_with_policy( - ctx: &MmArc, - ticker: &str, - conf: &Json, - params: SolanaActivationParams, - priv_key_policy: PrivKeyBuildPolicy, -) -> Result { - let client = RpcClient::new_with_commitment(params.client_url.clone(), CommitmentConfig { - commitment: params.confirmation_commitment, - }); - let decimals = conf["decimals"].as_u64().unwrap_or(SOLANA_DEFAULT_DECIMALS) as u8; - - let priv_key = match priv_key_policy { - PrivKeyBuildPolicy::IguanaPrivKey(priv_key) => priv_key, - PrivKeyBuildPolicy::GlobalHDAccount(global_hd) => { - let path_to_coin: HDPathToCoin = try_s!(json::from_value(conf["derivation_path"].clone())); - let derivation_path = try_s!(params.path_to_address.to_derivation_path(&path_to_coin)); - try_s!(global_hd.derive_secp256k1_secret(&derivation_path)) - }, - PrivKeyBuildPolicy::Trezor => return ERR!("{}", PrivKeyPolicyNotAllowed::HardwareWalletNotSupported), - }; - - let key_pair = try_s!(generate_keypair_from_slice(priv_key.as_slice())); - let my_address = key_pair.pubkey().to_string(); - let spl_tokens_infos = Arc::new(Mutex::new(HashMap::new())); - - // Create an abortable system linked to the `MmCtx` so if the context is stopped via `MmArc::stop`, - // all spawned futures related to `SolanaCoin` will be aborted as well. - let abortable_system: AbortableQueue = try_s!(ctx.abortable_system.create_subsystem()); - - let solana_coin = SolanaCoin(Arc::new(SolanaCoinImpl { - my_address, - key_pair, - ticker: ticker.to_string(), - client, - decimals, - spl_tokens_infos, - abortable_system, - })); - Ok(solana_coin) -} - -/// pImpl idiom. -pub struct SolanaCoinImpl { - ticker: String, - key_pair: SolKeypair, - client: RpcClient, - decimals: u8, - my_address: String, - spl_tokens_infos: Arc>>, - /// This spawner is used to spawn coin's related futures that should be aborted on coin deactivation - /// and on [`MmArc::stop`]. - pub abortable_system: AbortableQueue, -} - -#[derive(Clone)] -pub struct SolanaCoin(Arc); -impl Deref for SolanaCoin { - type Target = SolanaCoinImpl; - fn deref(&self) -> &SolanaCoinImpl { &self.0 } -} - -#[async_trait] -impl SolanaCommonOps for SolanaCoin { - fn rpc(&self) -> &RpcClient { &self.client } - - fn is_token(&self) -> bool { false } - - async fn check_balance_and_prepare_transfer( - &self, - max: bool, - amount: BigDecimal, - fees: u64, - ) -> Result> { - solana_common::check_balance_and_prepare_transfer(self, max, amount, fees).await - } -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct SolanaFeeDetails { - pub amount: BigDecimal, -} - -async fn withdraw_base_coin_impl(coin: SolanaCoin, req: WithdrawRequest) -> WithdrawResult { - let (hash, fees) = coin.estimate_withdraw_fees().await?; - let res = coin - .check_balance_and_prepare_transfer(req.max, req.amount.clone(), fees) - .await?; - let to = solana_sdk::pubkey::Pubkey::try_from(&*req.to)?; - let tx = solana_sdk::system_transaction::transfer(&coin.key_pair, &to, res.lamports_to_send, hash); - let serialized_tx = serialize(&tx).map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?; - let total_amount = lamports_to_sol(res.lamports_to_send); - let received_by_me = if req.to == coin.my_address { - total_amount.clone() - } else { - 0.into() - }; - let spent_by_me = &total_amount + &res.sol_required; - Ok(TransactionDetails { - tx: TransactionData::new_signed(serialized_tx.into(), tx.signatures[0].to_string()), - from: vec![coin.my_address.clone()], - to: vec![req.to], - total_amount: spent_by_me.clone(), - my_balance_change: &received_by_me - &spent_by_me, - spent_by_me, - received_by_me, - block_height: 0, - timestamp: now_sec(), - fee_details: Some( - SolanaFeeDetails { - amount: res.sol_required, - } - .into(), - ), - coin: coin.ticker.clone(), - internal_id: vec![].into(), - kmd_rewards: None, - transaction_type: TransactionType::StandardTransfer, - memo: None, - }) -} - -async fn withdraw_impl(coin: SolanaCoin, req: WithdrawRequest) -> WithdrawResult { - let validate_address_result = coin.validate_address(&req.to); - if !validate_address_result.is_valid { - return MmError::err(WithdrawError::InvalidAddress( - validate_address_result.reason.unwrap_or_else(|| "Unknown".to_string()), - )); - } - withdraw_base_coin_impl(coin, req).await -} - -type SolTxFut = Box + Send + 'static>; - -impl Transaction for SolTransaction { - fn tx_hex(&self) -> Vec { - serialize(self).unwrap_or_else(|e| { - error!("Error serializing SolTransaction: {}", e); - vec![] - }) - } - - fn tx_hash_as_bytes(&self) -> BytesJson { - let hash = match self.signatures.get(0) { - Some(signature) => signature, - None => { - error!("No signature found in SolTransaction"); - return BytesJson(Vec::new()); - }, - }; - BytesJson(Vec::from(hash.as_ref())) - } -} - -impl SolanaCoin { - pub async fn estimate_withdraw_fees(&self) -> Result<(solana_sdk::hash::Hash, u64), MmError> { - let hash = async_blocking({ - let coin = self.clone(); - move || coin.rpc().get_latest_blockhash() - }) - .await?; - let to = self.key_pair.pubkey(); - - let tx = solana_sdk::system_transaction::transfer(&self.key_pair, &to, LAMPORTS_DUMMY_AMOUNT, hash); - let fees = async_blocking({ - let coin = self.clone(); - move || coin.rpc().get_fee_for_message(tx.message()) - }) - .await?; - Ok((hash, fees)) - } - - pub async fn my_balance_spl(&self, infos: SplTokenInfo) -> Result> { - let token_accounts = async_blocking({ - let coin = self.clone(); - move || { - coin.rpc().get_token_accounts_by_owner( - &coin.key_pair.pubkey(), - TokenAccountsFilter::Mint(infos.token_contract_address), - ) - } - }) - .await?; - if token_accounts.is_empty() { - return Ok(CoinBalance { - spendable: Default::default(), - unspendable: Default::default(), - }); - } - let actual_token_pubkey = - Pubkey::from_str(&token_accounts[0].pubkey).map_err(|e| BalanceError::Internal(format!("{:?}", e)))?; - let amount = async_blocking({ - let coin = self.clone(); - move || coin.rpc().get_token_account_balance(&actual_token_pubkey) - }) - .await?; - let balance = - BigDecimal::from_str(&amount.ui_amount_string).map_to_mm(|e| BalanceError::Internal(e.to_string()))?; - Ok(CoinBalance { - spendable: balance, - unspendable: Default::default(), - }) - } - - fn my_balance_impl(&self) -> BalanceFut { - let coin = self.clone(); - let fut = async_blocking(move || { - // this is blocking IO - let res = coin.rpc().get_balance(&coin.key_pair.pubkey())?; - Ok(lamports_to_sol(res)) - }); - Box::new(fut.boxed().compat()) - } - - pub fn add_spl_token_info(&self, ticker: String, info: SplTokenInfo) { - self.spl_tokens_infos.lock().unwrap().insert(ticker, info); - } - - /// WARNING - /// Be very careful using this function since it returns dereferenced clone - /// of value behind the MutexGuard and makes it non-thread-safe. - pub fn get_spl_tokens_infos(&self) -> HashMap { - let guard = self.spl_tokens_infos.lock().unwrap(); - (*guard).clone() - } - - fn send_hash_time_locked_payment(&self, args: SendPaymentArgs<'_>) -> SolTxFut { - let receiver = Pubkey::new(args.other_pubkey); - let swap_program_id = Pubkey::new(try_tx_fus_opt!( - args.swap_contract_address, - format!( - "Unable to extract Bytes from args.swap_contract_address ( {:?} )", - args.swap_contract_address - ) - )); - let amount = sol_to_lamports(try_tx_fus_opt!( - args.amount.to_f64(), - format!("Unable to extract value from args.amount ( {:?} )", args.amount) - )); - let secret_hash: [u8; 32] = try_tx_fus!(<[u8; 32]>::try_from(args.secret_hash)); - let (vault_pda, vault_pda_data, vault_bump_seed, vault_bump_seed_data, rent_exemption_lamports) = - try_tx_fus!(self.create_vaults(args.time_lock, secret_hash, swap_program_id, STORAGE_SPACE_ALLOCATED)); - let swap_instruction = AtomicSwapInstruction::LamportsPayment { - secret_hash, - lock_time: args.time_lock, - amount, - receiver, - rent_exemption_lamports, - vault_bump_seed, - vault_bump_seed_data, - }; - - let accounts = vec![ - AccountMeta::new(self.key_pair.pubkey(), true), - AccountMeta::new(vault_pda_data, false), - AccountMeta::new(vault_pda, false), - AccountMeta::new(solana_program::system_program::id(), false), - ]; - self.sign_and_send_swap_transaction_fut(swap_program_id, accounts, swap_instruction.pack()) - } - - fn spend_hash_time_locked_payment(&self, args: SpendPaymentArgs) -> SolTxFut { - let sender = Pubkey::new(args.other_pubkey); - let swap_program_id = Pubkey::new(try_tx_fus_opt!( - args.swap_contract_address.as_ref(), - format!( - "Unable to extract Bytes from args.swap_contract_address ( {:?} )", - args.swap_contract_address - ) - )); - let secret: [u8; 32] = try_tx_fus!(<[u8; 32]>::try_from(args.secret)); - let secret_hash = sha256(secret.as_slice()).take(); - let (lock_time, tx_secret_hash, amount, token_program) = - try_tx_fus!(self.get_swap_transaction_details(args.other_payment_tx)); - if secret_hash != tx_secret_hash { - try_tx_fus_err!(format!( - "Provided secret_hash {:?} does not match transaction secret_hash {:?}", - secret_hash, tx_secret_hash - )); - } - let (vault_pda, vault_pda_data, vault_bump_seed, vault_bump_seed_data, _rent_exemption_lamports) = - try_tx_fus!(self.create_vaults(lock_time, secret_hash, swap_program_id, STORAGE_SPACE_ALLOCATED)); - let swap_instruction = AtomicSwapInstruction::ReceiverSpend { - secret, - lock_time, - amount, - sender, - token_program, - vault_bump_seed, - vault_bump_seed_data, - }; - let accounts = vec![ - AccountMeta::new(self.key_pair.pubkey(), true), - AccountMeta::new(vault_pda_data, false), - AccountMeta::new(vault_pda, false), - AccountMeta::new(solana_program::system_program::id(), false), - ]; - self.sign_and_send_swap_transaction_fut(swap_program_id, accounts, swap_instruction.pack()) - } - - fn refund_hash_time_locked_payment(&self, args: RefundPaymentArgs) -> SolTxFut { - let receiver = Pubkey::new(args.other_pubkey); - let swap_program_id = Pubkey::new(try_tx_fus_opt!( - args.swap_contract_address.as_ref(), - format!( - "Unable to extract Bytes from args.swap_contract_address ( {:?} )", - args.swap_contract_address - ) - )); - let (lock_time, secret_hash, amount, token_program) = - try_tx_fus!(self.get_swap_transaction_details(args.payment_tx)); - let (vault_pda, vault_pda_data, vault_bump_seed, vault_bump_seed_data, _rent_exemption_lamports) = - try_tx_fus!(self.create_vaults(lock_time, secret_hash, swap_program_id, STORAGE_SPACE_ALLOCATED)); - let swap_instruction = AtomicSwapInstruction::SenderRefund { - secret_hash, - lock_time, - amount, - receiver, - token_program, - vault_bump_seed, - vault_bump_seed_data, - }; - let accounts = vec![ - AccountMeta::new(self.key_pair.pubkey(), true), // Marked as signer - AccountMeta::new(vault_pda_data, false), // Not a signer - AccountMeta::new(vault_pda, false), // Not a signer - AccountMeta::new(solana_program::system_program::id(), false), //system_program must be included - ]; - self.sign_and_send_swap_transaction_fut(swap_program_id, accounts, swap_instruction.pack()) - } - - fn get_swap_transaction_details(&self, tx_hex: &[u8]) -> Result<(u64, [u8; 32], u64, Pubkey), Box> { - let transaction: SolTransaction = deserialize(tx_hex) - .map_err(|e| Box::new(TransactionErr::Plain(ERRL!("error deserializing tx_hex: {:?}", e))))?; - - let instruction = transaction - .message - .instructions - .get(0) - .ok_or_else(|| Box::new(TransactionErr::Plain(ERRL!("Instruction not found in message"))))?; - - let instruction_data = &instruction.data[..]; - let instruction = AtomicSwapInstruction::unpack(instruction_data[0], instruction_data) - .map_err(|e| Box::new(TransactionErr::Plain(ERRL!("error unpacking tx data: {:?}", e))))?; - - match instruction { - AtomicSwapInstruction::LamportsPayment { - secret_hash, - lock_time, - amount, - .. - } => Ok((lock_time, secret_hash, amount, Pubkey::new_from_array([0; 32]))), - AtomicSwapInstruction::SPLTokenPayment { - secret_hash, - lock_time, - amount, - token_program, - .. - } => Ok((lock_time, secret_hash, amount, token_program)), - AtomicSwapInstruction::ReceiverSpend { - secret, - lock_time, - amount, - token_program, - .. - } => Ok((lock_time, sha256(&secret).take(), amount, token_program)), - AtomicSwapInstruction::SenderRefund { - secret_hash, - lock_time, - amount, - token_program, - .. - } => Ok((lock_time, secret_hash, amount, token_program)), - } - } - - fn sign_and_send_swap_transaction_fut( - &self, - program_id: Pubkey, - accounts: Vec, - data: Vec, - ) -> SolTxFut { - let coin = self.clone(); - Box::new( - async move { coin.sign_and_send_swap_transaction(program_id, accounts, data).await } - .boxed() - .compat(), - ) - } - - pub async fn sign_and_send_swap_transaction( - &self, - program_id: Pubkey, - accounts: Vec, - data: Vec, - ) -> Result { - // Construct the instruction to send to the program - // The parameters here depend on your specific program's requirements - let instruction = Instruction { - program_id, - accounts, // Specify account metas here - data, // Pass data to the program here - }; - - // Create a transaction - let recent_blockhash = self - .client - .get_latest_blockhash() - .map_err(|e| TransactionErr::Plain(format!("Failed to get recent blockhash: {:?}", e)))?; - - let transaction: SolTransaction = SolTransaction::new_signed_with_payer( - &[instruction], - Some(&self.key_pair.pubkey()), //payer pubkey - &[&self.key_pair], //payer - recent_blockhash, - ); - - // Send the transaction - let tx = self - .client - .send_and_confirm_transaction(&transaction) - .map(|_signature| transaction) - .map_err(|e| TransactionErr::Plain(ERRL!("Solana ClientError: {:?}", e)))?; - - Ok(tx) - } - - fn create_vaults( - &self, - lock_time: u64, - secret_hash: [u8; 32], - program_id: Pubkey, - space: u64, - ) -> Result<(Pubkey, Pubkey, u8, u8, u64), Box> { - let seeds: &[&[u8]] = &[b"swap", &lock_time.to_le_bytes()[..], &secret_hash[..]]; - let (vault_pda, bump_seed) = Pubkey::find_program_address(seeds, &program_id); - - let seeds_data: &[&[u8]] = &[b"swap_data", &lock_time.to_le_bytes()[..], &secret_hash[..]]; - let (vault_pda_data, bump_seed_data) = Pubkey::find_program_address(seeds_data, &program_id); - - let rent_exemption_lamports = self - .client - .get_minimum_balance_for_rent_exemption( - space - .try_into() - .map_err(|e| Box::new(TransactionErr::Plain(ERRL!("unable to convert space: {:?}", e))))?, - ) - .map_err(|e| { - Box::new(TransactionErr::Plain(ERRL!( - "error get_minimum_balance_for_rent_exemption: {:?}", - e - ))) - })?; - - Ok(( - vault_pda, - vault_pda_data, - bump_seed, - bump_seed_data, - rent_exemption_lamports, - )) - } -} - -#[async_trait] -impl MarketCoinOps for SolanaCoin { - fn ticker(&self) -> &str { &self.ticker } - - fn my_address(&self) -> MmResult { Ok(self.my_address.clone()) } - - async fn get_public_key(&self) -> Result> { - Ok(self.key_pair.pubkey().to_string()) - } - - fn sign_message_hash(&self, _message: &str) -> Option<[u8; 32]> { unimplemented!() } - - fn sign_message(&self, message: &str) -> SignatureResult { solana_common::sign_message(self, message) } - - fn verify_message(&self, signature: &str, message: &str, pubkey_bs58: &str) -> VerificationResult { - solana_common::verify_message(self, signature, message, pubkey_bs58) - } - - fn my_balance(&self) -> BalanceFut { - let decimals = self.decimals as u64; - let fut = self.my_balance_impl().and_then(move |result| { - Ok(CoinBalance { - spendable: result.with_prec(decimals), - unspendable: 0.into(), - }) - }); - Box::new(fut) - } - - fn base_coin_balance(&self) -> BalanceFut { - let decimals = self.decimals as u64; - let fut = self - .my_balance_impl() - .and_then(move |result| Ok(result.with_prec(decimals))); - Box::new(fut) - } - - fn platform_ticker(&self) -> &str { self.ticker() } - - fn send_raw_tx(&self, tx: &str) -> Box + Send> { - let coin = self.clone(); - let tx = tx.to_owned(); - let fut = async_blocking(move || { - let bytes = hex::decode(tx).map_to_mm(|e| e).map_err(|e| format!("{:?}", e))?; - let tx: SolTransaction = deserialize(bytes.as_slice()) - .map_to_mm(|e| e) - .map_err(|e| format!("{:?}", e))?; - // this is blocking IO - let signature = coin.rpc().send_transaction(&tx).map_err(|e| format!("{:?}", e))?; - Ok(signature.to_string()) - }); - Box::new(fut.boxed().compat()) - } - - fn send_raw_tx_bytes(&self, tx: &[u8]) -> Box + Send> { - let coin = self.clone(); - let tx = tx.to_owned(); - let fut = async_blocking(move || { - let tx = try_s!(deserialize(tx.as_slice())); - // this is blocking IO - let signature = coin.rpc().send_transaction(&tx).map_err(|e| format!("{:?}", e))?; - Ok(signature.to_string()) - }); - Box::new(fut.boxed().compat()) - } - - #[inline(always)] - async fn sign_raw_tx(&self, _args: &SignRawTransactionRequest) -> RawTransactionResult { - MmError::err(RawTransactionError::NotImplemented { - coin: self.ticker().to_string(), - }) - } - - fn wait_for_confirmations(&self, _input: ConfirmPaymentInput) -> Box + Send> { - unimplemented!() - } - - fn wait_for_htlc_tx_spend(&self, args: WaitForHTLCTxSpendArgs<'_>) -> TransactionFut { unimplemented!() } - - fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result> { - MmError::err(TxMarshalingErr::NotSupported( - "tx_enum_from_bytes is not supported for Solana yet.".to_string(), - )) - } - - fn current_block(&self) -> Box + Send> { - let coin = self.clone(); - let fut = async_blocking(move || coin.rpc().get_block_height().map_err(|e| format!("{:?}", e))); - Box::new(fut.boxed().compat()) - } - - fn display_priv_key(&self) -> Result { Ok(self.key_pair.secret().to_bytes()[..].to_base58()) } - - fn min_tx_amount(&self) -> BigDecimal { BigDecimal::from(0) } - - fn min_trading_vol(&self) -> MmNumber { MmNumber::from("0.00777") } - - fn is_trezor(&self) -> bool { unimplemented!() } -} - -#[async_trait] -impl SwapOps for SolanaCoin { - fn send_taker_fee(&self, _fee_addr: &[u8], dex_fee: DexFee, _uuid: &[u8], _expire_at: u64) -> TransactionFut { - unimplemented!() - } - - fn send_maker_payment(&self, maker_payment: SendPaymentArgs) -> TransactionFut { - Box::new( - self.send_hash_time_locked_payment(maker_payment) - .map(TransactionEnum::from), - ) - } - - fn send_taker_payment(&self, taker_payment: SendPaymentArgs) -> TransactionFut { - Box::new( - self.send_hash_time_locked_payment(taker_payment) - .map(TransactionEnum::from), - ) - } - - async fn send_maker_spends_taker_payment( - &self, - maker_spends_payment_args: SpendPaymentArgs<'_>, - ) -> TransactionResult { - self.spend_hash_time_locked_payment(maker_spends_payment_args) - .compat() - .await - .map(TransactionEnum::from) - } - - async fn send_taker_spends_maker_payment( - &self, - taker_spends_payment_args: SpendPaymentArgs<'_>, - ) -> TransactionResult { - self.spend_hash_time_locked_payment(taker_spends_payment_args) - .compat() - .await - .map(TransactionEnum::from) - } - - async fn send_taker_refunds_payment(&self, taker_refunds_payment_args: RefundPaymentArgs<'_>) -> TransactionResult { - self.refund_hash_time_locked_payment(taker_refunds_payment_args) - .map(TransactionEnum::from) - .compat() - .await - } - - async fn send_maker_refunds_payment(&self, maker_refunds_payment_args: RefundPaymentArgs<'_>) -> TransactionResult { - self.refund_hash_time_locked_payment(maker_refunds_payment_args) - .map(TransactionEnum::from) - .compat() - .await - } - - fn validate_fee(&self, _validate_fee_args: ValidateFeeArgs) -> ValidatePaymentFut<()> { unimplemented!() } - - async fn validate_maker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { - unimplemented!() - } - - async fn validate_taker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { - unimplemented!() - } - - fn check_if_my_payment_sent( - &self, - _if_my_payment_sent_args: CheckIfMyPaymentSentArgs, - ) -> Box, Error = String> + Send> { - unimplemented!() - } - - async fn search_for_swap_tx_spend_my( - &self, - _: SearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!() - } - - async fn search_for_swap_tx_spend_other( - &self, - _: SearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!() - } - - fn check_tx_signed_by_pub(&self, tx: &[u8], expected_pub: &[u8]) -> Result> { - unimplemented!(); - } - - async fn extract_secret( - &self, - secret_hash: &[u8], - spend_tx: &[u8], - watcher_reward: bool, - ) -> Result, String> { - unimplemented!() - } - - fn is_auto_refundable(&self) -> bool { false } - - async fn wait_for_htlc_refund(&self, _tx: &[u8], _locktime: u64) -> RefundResult<()> { - MmError::err(RefundError::Internal( - "wait_for_htlc_refund is not supported for this coin!".into(), - )) - } - - fn negotiate_swap_contract_addr( - &self, - _other_side_address: Option<&[u8]>, - ) -> Result, MmError> { - unimplemented!() - } - - #[inline] - fn derive_htlc_key_pair(&self, _swap_unique_data: &[u8]) -> KeyPair { todo!() } - - #[inline] - fn derive_htlc_pubkey(&self, swap_unique_data: &[u8]) -> Vec { - self.derive_htlc_key_pair(swap_unique_data).public_slice().to_vec() - } - - fn validate_other_pubkey(&self, _raw_pubkey: &[u8]) -> MmResult<(), ValidateOtherPubKeyErr> { unimplemented!() } - - async fn maker_payment_instructions( - &self, - _args: PaymentInstructionArgs<'_>, - ) -> Result>, MmError> { - unimplemented!() - } - - async fn taker_payment_instructions( - &self, - _args: PaymentInstructionArgs<'_>, - ) -> Result>, MmError> { - unimplemented!() - } - - fn validate_maker_payment_instructions( - &self, - _instructions: &[u8], - _args: PaymentInstructionArgs<'_>, - ) -> Result> { - unimplemented!() - } - - fn validate_taker_payment_instructions( - &self, - _instructions: &[u8], - _args: PaymentInstructionArgs<'_>, - ) -> Result> { - unimplemented!() - } -} - -#[async_trait] -impl TakerSwapMakerCoin for SolanaCoin { - async fn on_taker_payment_refund_start(&self, _maker_payment: &[u8]) -> RefundResult<()> { Ok(()) } - - async fn on_taker_payment_refund_success(&self, _maker_payment: &[u8]) -> RefundResult<()> { Ok(()) } -} - -#[async_trait] -impl MakerSwapTakerCoin for SolanaCoin { - async fn on_maker_payment_refund_start(&self, _taker_payment: &[u8]) -> RefundResult<()> { Ok(()) } - - async fn on_maker_payment_refund_success(&self, _taker_payment: &[u8]) -> RefundResult<()> { Ok(()) } -} - -#[async_trait] -impl WatcherOps for SolanaCoin { - fn create_maker_payment_spend_preimage( - &self, - _maker_payment_tx: &[u8], - _time_lock: u64, - _maker_pub: &[u8], - _secret_hash: &[u8], - _swap_unique_data: &[u8], - ) -> TransactionFut { - unimplemented!(); - } - - fn send_maker_payment_spend_preimage(&self, _input: SendMakerPaymentSpendPreimageInput) -> TransactionFut { - unimplemented!(); - } - - fn create_taker_payment_refund_preimage( - &self, - _taker_payment_tx: &[u8], - _time_lock: u64, - _maker_pub: &[u8], - _secret_hash: &[u8], - _swap_contract_address: &Option, - _swap_unique_data: &[u8], - ) -> TransactionFut { - unimplemented!(); - } - - fn send_taker_payment_refund_preimage(&self, _watcher_refunds_payment_args: RefundPaymentArgs) -> TransactionFut { - unimplemented!(); - } - - fn watcher_validate_taker_fee(&self, input: WatcherValidateTakerFeeInput) -> ValidatePaymentFut<()> { - unimplemented!(); - } - - fn watcher_validate_taker_payment(&self, _input: WatcherValidatePaymentInput) -> ValidatePaymentFut<()> { - unimplemented!(); - } - - fn taker_validates_payment_spend_or_refund(&self, _input: ValidateWatcherSpendInput) -> ValidatePaymentFut<()> { - unimplemented!() - } - - async fn watcher_search_for_swap_tx_spend( - &self, - input: WatcherSearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!(); - } - - async fn get_taker_watcher_reward( - &self, - other_coin: &MmCoinEnum, - coin_amount: Option, - other_coin_amount: Option, - reward_amount: Option, - wait_until: u64, - ) -> Result> { - unimplemented!(); - } - - async fn get_maker_watcher_reward( - &self, - other_coin: &MmCoinEnum, - reward_amount: Option, - wait_until: u64, - ) -> Result, MmError> { - unimplemented!(); - } -} - -#[async_trait] -impl MmCoin for SolanaCoin { - fn is_asset_chain(&self) -> bool { false } - - fn spawner(&self) -> CoinFutSpawner { CoinFutSpawner::new(&self.abortable_system) } - - fn withdraw(&self, req: WithdrawRequest) -> WithdrawFut { - Box::new(Box::pin(withdraw_impl(self.clone(), req)).compat()) - } - - fn get_raw_transaction(&self, _req: RawTransactionRequest) -> RawTransactionFut { unimplemented!() } - - fn get_tx_hex_by_hash(&self, tx_hash: Vec) -> RawTransactionFut { unimplemented!() } - - fn decimals(&self) -> u8 { self.decimals } - - fn convert_to_address(&self, _from: &str, _to_address_format: Json) -> Result { unimplemented!() } - - fn validate_address(&self, address: &str) -> ValidateAddressResult { - if address.len() != 44 { - return ValidateAddressResult { - is_valid: false, - reason: Some("Invalid address length".to_string()), - }; - } - let result = Pubkey::try_from(address); - match result { - Ok(pubkey) => { - if pubkey.is_on_curve() { - ValidateAddressResult { - is_valid: true, - reason: None, - } - } else { - ValidateAddressResult { - is_valid: false, - reason: Some("not_on_curve".to_string()), - } - } - }, - Err(err) => ValidateAddressResult { - is_valid: false, - reason: Some(format!("{:?}", err)), - }, - } - } - - fn process_history_loop(&self, _ctx: MmArc) -> Box + Send> { unimplemented!() } - - fn history_sync_status(&self) -> HistorySyncState { unimplemented!() } - - /// Get fee to be paid per 1 swap transaction - fn get_trade_fee(&self) -> Box + Send> { unimplemented!() } - - async fn get_sender_trade_fee( - &self, - _value: TradePreimageValue, - _stage: FeeApproxStage, - _include_refund_fee: bool, - ) -> TradePreimageResult { - unimplemented!() - } - - fn get_receiver_trade_fee(&self, _stage: FeeApproxStage) -> TradePreimageFut { unimplemented!() } - - async fn get_fee_to_send_taker_fee( - &self, - _dex_fee_amount: DexFee, - _stage: FeeApproxStage, - ) -> TradePreimageResult { - unimplemented!() - } - - fn required_confirmations(&self) -> u64 { 1 } - - fn requires_notarization(&self) -> bool { false } - - fn set_required_confirmations(&self, _confirmations: u64) { unimplemented!() } - - fn set_requires_notarization(&self, _requires_nota: bool) { unimplemented!() } - - fn swap_contract_address(&self) -> Option { unimplemented!() } - - fn fallback_swap_contract(&self) -> Option { unimplemented!() } - - fn mature_confirmations(&self) -> Option { None } - - fn coin_protocol_info(&self, _amount_to_receive: Option) -> Vec { Vec::new() } - - fn is_coin_protocol_supported( - &self, - _info: &Option>, - _amount_to_send: Option, - _locktime: u64, - _is_maker: bool, - ) -> bool { - true - } - - fn on_disabled(&self) -> Result<(), AbortedError> { AbortableSystem::abort_all(&self.abortable_system) } - - fn on_token_deactivated(&self, _ticker: &str) { unimplemented!() } -} diff --git a/mm2src/coins/solana/solana_common.rs b/mm2src/coins/solana/solana_common.rs deleted file mode 100644 index 3f74c1caff..0000000000 --- a/mm2src/coins/solana/solana_common.rs +++ /dev/null @@ -1,181 +0,0 @@ -use crate::solana::SolanaCommonOps; -use crate::{BalanceError, MarketCoinOps, NumConversError, SignatureError, SignatureResult, SolanaCoin, - UnexpectedDerivationMethod, VerificationError, VerificationResult, WithdrawError}; -use base58::FromBase58; -use derive_more::Display; -use futures::compat::Future01CompatExt; -use mm2_err_handle::prelude::*; -use mm2_number::bigdecimal::{BigDecimal, ToPrimitive}; -use solana_sdk::native_token::LAMPORTS_PER_SOL; -use solana_sdk::signature::{Signature, Signer}; -use std::str::FromStr; - -#[derive(Debug, Display)] -pub enum SufficientBalanceError { - #[display( - fmt = "Not enough {} to withdraw: available {}, required at least {}", - coin, - available, - required - )] - NotSufficientBalance { - coin: String, - available: BigDecimal, - required: BigDecimal, - }, - #[display(fmt = "The amount {} is too small, required at least {}", amount, threshold)] - AmountTooLow { amount: BigDecimal, threshold: BigDecimal }, - #[display(fmt = "{}", _0)] - UnexpectedDerivationMethod(UnexpectedDerivationMethod), - #[display(fmt = "Wallet storage error: {}", _0)] - WalletStorageError(String), - #[display(fmt = "Invalid response: {}", _0)] - InvalidResponse(String), - #[display(fmt = "Transport: {}", _0)] - Transport(String), - #[display(fmt = "Internal: {}", _0)] - Internal(String), -} - -impl From for SufficientBalanceError { - fn from(e: NumConversError) -> Self { SufficientBalanceError::Internal(e.to_string()) } -} - -impl From for SufficientBalanceError { - fn from(e: BalanceError) -> Self { - match e { - BalanceError::Transport(e) => SufficientBalanceError::Transport(e), - BalanceError::InvalidResponse(e) => SufficientBalanceError::InvalidResponse(e), - BalanceError::UnexpectedDerivationMethod(e) => SufficientBalanceError::UnexpectedDerivationMethod(e), - BalanceError::Internal(e) => SufficientBalanceError::Internal(e), - BalanceError::WalletStorageError(e) => SufficientBalanceError::WalletStorageError(e), - } - } -} -impl From for WithdrawError { - fn from(e: SufficientBalanceError) -> Self { - match e { - SufficientBalanceError::NotSufficientBalance { - coin, - available, - required, - } => WithdrawError::NotSufficientBalance { - coin, - available, - required, - }, - SufficientBalanceError::UnexpectedDerivationMethod(e) => WithdrawError::from(e), - SufficientBalanceError::InvalidResponse(e) | SufficientBalanceError::Transport(e) => { - WithdrawError::Transport(e) - }, - SufficientBalanceError::Internal(e) | SufficientBalanceError::WalletStorageError(e) => { - WithdrawError::InternalError(e) - }, - SufficientBalanceError::AmountTooLow { amount, threshold } => { - WithdrawError::AmountTooLow { amount, threshold } - }, - } - } -} - -pub struct PrepareTransferData { - pub to_send: BigDecimal, - pub my_balance: BigDecimal, - pub sol_required: BigDecimal, - pub lamports_to_send: u64, -} - -pub fn lamports_to_sol(lamports: u64) -> BigDecimal { BigDecimal::from(lamports) / BigDecimal::from(LAMPORTS_PER_SOL) } - -pub fn sol_to_lamports(sol: &BigDecimal) -> Result> { - let maybe_lamports = (sol * BigDecimal::from(LAMPORTS_PER_SOL)).to_u64(); - match maybe_lamports { - None => MmError::err(NumConversError("Error when converting sol to lamports".to_string())), - Some(lamports) => Ok(lamports), - } -} - -pub fn ui_amount_to_amount(ui_amount: BigDecimal, decimals: u8) -> Result> { - let maybe_amount = (ui_amount * BigDecimal::from(10_u64.pow(decimals as u32))).to_u64(); - match maybe_amount { - None => MmError::err(NumConversError("Error when converting ui amount to amount".to_string())), - Some(amount) => Ok(amount), - } -} - -pub fn amount_to_ui_amount(amount: u64, decimals: u8) -> BigDecimal { - BigDecimal::from(amount) / BigDecimal::from(10_u64.pow(decimals as u32)) -} - -pub fn sign_message(coin: &SolanaCoin, message: &str) -> SignatureResult { - let signature = coin - .key_pair - .try_sign_message(message.as_bytes()) - .map_err(|e| SignatureError::InternalError(e.to_string()))?; - Ok(signature.to_string()) -} - -pub fn verify_message( - coin: &SolanaCoin, - signature: &str, - message: &str, - pubkey_bs58: &str, -) -> VerificationResult { - let pubkey = pubkey_bs58.from_base58()?; - let signature = - Signature::from_str(signature).map_err(|e| VerificationError::SignatureDecodingError(e.to_string()))?; - let is_valid = signature.verify(&pubkey, message.as_bytes()); - Ok(is_valid) -} - -pub async fn check_balance_and_prepare_transfer( - coin: &T, - max: bool, - amount: BigDecimal, - fees: u64, -) -> Result> -where - T: SolanaCommonOps + MarketCoinOps, -{ - let base_balance = coin.base_coin_balance().compat().await?; - let sol_required = lamports_to_sol(fees); - if base_balance < sol_required { - return MmError::err(SufficientBalanceError::NotSufficientBalance { - coin: coin.platform_ticker().to_string(), - available: base_balance.clone(), - required: sol_required.clone(), - }); - } - - let my_balance = coin.my_balance().compat().await?.spendable; - let to_send = if max { my_balance.clone() } else { amount.clone() }; - let to_check = if max || coin.is_token() { - to_send.clone() - } else { - &to_send + &sol_required - }; - if to_check > my_balance { - return MmError::err(SufficientBalanceError::NotSufficientBalance { - coin: coin.ticker().to_string(), - available: my_balance, - required: to_check, - }); - } - - let lamports_to_send = if !coin.is_token() { - if max { - sol_to_lamports(&my_balance)? - sol_to_lamports(&sol_required)? - } else { - sol_to_lamports(&amount)? - } - } else { - 0_u64 - }; - - Ok(PrepareTransferData { - to_send, - my_balance, - sol_required, - lamports_to_send, - }) -} diff --git a/mm2src/coins/solana/solana_common_tests.rs b/mm2src/coins/solana/solana_common_tests.rs deleted file mode 100644 index 6bb5b833d1..0000000000 --- a/mm2src/coins/solana/solana_common_tests.rs +++ /dev/null @@ -1,96 +0,0 @@ -use super::*; -use crate::solana::spl::{SplToken, SplTokenFields}; -use crypto::privkey::{bip39_seed_from_passphrase, key_pair_from_seed}; -use ed25519_dalek_bip32::{DerivationPath, ExtendedSecretKey}; -use mm2_core::mm_ctx::MmCtxBuilder; -use solana_client::rpc_client::RpcClient; -use solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel}; -use std::str::FromStr; - -pub enum SolanaNet { - //Mainnet, - Testnet, - Devnet, -} - -pub fn solana_net_to_url(net_type: SolanaNet) -> String { - match net_type { - //SolanaNet::Mainnet => "https://api.mainnet-beta.solana.com".to_string(), - SolanaNet::Testnet => "https://api.testnet.solana.com/".to_string(), - SolanaNet::Devnet => "https://api.devnet.solana.com".to_string(), - } -} - -pub fn generate_key_pair_from_seed(seed: &str) -> SolKeypair { - let derivation_path = DerivationPath::from_str("m/44'/501'/0'").unwrap(); - let seed = bip39_seed_from_passphrase(seed).unwrap(); - - let ext = ExtendedSecretKey::from_seed(&seed.0) - .unwrap() - .derive(&derivation_path) - .unwrap(); - let pub_key = ext.public_key(); - let pair = ed25519_dalek::Keypair { - secret: ext.secret_key, - public: pub_key, - }; - - solana_sdk::signature::keypair_from_seed(pair.to_bytes().as_ref()).unwrap() -} - -pub fn generate_key_pair_from_iguana_seed(seed: String) -> SolKeypair { - let key_pair = key_pair_from_seed(seed.as_str()).unwrap(); - let secret_key = ed25519_dalek::SecretKey::from_bytes(key_pair.private().secret.as_slice()).unwrap(); - let public_key = ed25519_dalek::PublicKey::from(&secret_key); - let other_key_pair = ed25519_dalek::Keypair { - secret: secret_key, - public: public_key, - }; - solana_sdk::signature::keypair_from_seed(other_key_pair.to_bytes().as_ref()).unwrap() -} - -pub fn spl_coin_for_test( - solana_coin: SolanaCoin, - ticker: String, - decimals: u8, - token_contract_address: Pubkey, -) -> SplToken { - SplToken { - conf: Arc::new(SplTokenFields { - decimals, - ticker, - token_contract_address, - abortable_system: AbortableQueue::default(), - }), - platform_coin: solana_coin, - } -} - -pub fn solana_coin_for_test(seed: String, net_type: SolanaNet) -> (MmArc, SolanaCoin) { - let url = solana_net_to_url(net_type); - let client = RpcClient::new_with_commitment(url, CommitmentConfig { - commitment: CommitmentLevel::Finalized, - }); - let conf = json!({ - "coins":[ - {"coin":"SOL","name":"solana","protocol":{"type":"SOL"},"rpcport":80,"mm2":1} - ] - }); - let ctx = MmCtxBuilder::new().with_conf(conf).into_mm_arc(); - let (ticker, decimals) = ("SOL".to_string(), 8); - let key_pair = generate_key_pair_from_iguana_seed(seed); - let my_address = key_pair.pubkey().to_string(); - let spl_tokens_infos = Arc::new(Mutex::new(HashMap::new())); - let spawner = AbortableQueue::default(); - - let solana_coin = SolanaCoin(Arc::new(SolanaCoinImpl { - decimals, - my_address, - key_pair, - ticker, - client, - spl_tokens_infos, - abortable_system: spawner, - })); - (ctx, solana_coin) -} diff --git a/mm2src/coins/solana/solana_decode_tx_helpers.rs b/mm2src/coins/solana/solana_decode_tx_helpers.rs deleted file mode 100644 index bd22fc044e..0000000000 --- a/mm2src/coins/solana/solana_decode_tx_helpers.rs +++ /dev/null @@ -1,222 +0,0 @@ -extern crate serde_derive; - -use crate::{NumConversResult, SolanaCoin, SolanaFeeDetails, TransactionData, TransactionDetails, TransactionType}; -use mm2_number::BigDecimal; -use solana_sdk::native_token::lamports_to_sol; -use std::convert::TryFrom; - -#[derive(Debug, Serialize, Deserialize)] -pub struct SolanaConfirmedTransaction { - slot: u64, - transaction: Transaction, - meta: Meta, - #[serde(rename = "blockTime")] - block_time: u64, -} - -#[allow(dead_code)] -impl SolanaConfirmedTransaction { - pub fn extract_account_index(&self, address: String) -> usize { - // find the equivalent of index_of(needle) in rust, and return result later - let mut idx = 0_usize; - for account in self.transaction.message.account_keys.iter() { - if account.pubkey == address { - return idx; - } - idx += 1; - } - idx - } - - pub fn extract_solana_transactions(&self, solana_coin: &SolanaCoin) -> NumConversResult> { - let mut transactions = Vec::new(); - let account_idx = self.extract_account_index(solana_coin.my_address.clone()); - for instruction in self.transaction.message.instructions.iter() { - if instruction.is_solana_transfer() { - let lamports = instruction.parsed.info.lamports.unwrap_or_default(); - let amount = BigDecimal::try_from(lamports_to_sol(lamports))?; - let is_self_transfer = instruction.parsed.info.source == instruction.parsed.info.destination; - let am_i_sender = instruction.parsed.info.source == solana_coin.my_address; - let spent_by_me = if am_i_sender && !is_self_transfer { - amount.clone() - } else { - 0.into() - }; - let received_by_me = if is_self_transfer { amount.clone() } else { 0.into() }; - let my_balance_change = if am_i_sender { - BigDecimal::try_from(lamports_to_sol( - self.meta.pre_balances[account_idx] - self.meta.post_balances[account_idx], - ))? - } else { - BigDecimal::try_from(lamports_to_sol( - self.meta.post_balances[account_idx] - self.meta.pre_balances[account_idx], - ))? - }; - let fee = BigDecimal::try_from(lamports_to_sol(self.meta.fee))?; - let tx = TransactionDetails { - tx: TransactionData::new_signed(Default::default(), self.transaction.signatures[0].to_string()), - from: vec![instruction.parsed.info.source.clone()], - to: vec![instruction.parsed.info.destination.clone()], - total_amount: amount, - spent_by_me, - received_by_me, - my_balance_change, - block_height: self.slot, - timestamp: self.block_time, - fee_details: Some(SolanaFeeDetails { amount: fee }.into()), - coin: solana_coin.ticker.clone(), - internal_id: Default::default(), - kmd_rewards: None, - transaction_type: TransactionType::StandardTransfer, - memo: None, - }; - transactions.push(tx); - } - } - Ok(transactions) - } -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Meta { - err: Option, - status: Status, - fee: u64, - #[serde(rename = "preBalances")] - pre_balances: Vec, - #[serde(rename = "postBalances")] - post_balances: Vec, - #[serde(rename = "innerInstructions")] - inner_instructions: Vec>, - #[serde(rename = "logMessages")] - log_messages: Vec, - #[serde(rename = "preTokenBalances")] - pre_token_balances: Vec, - #[serde(rename = "postTokenBalances")] - post_token_balances: Vec, - rewards: Vec>, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct TokenBalance { - #[serde(rename = "accountIndex")] - account_index: u64, - mint: String, - #[serde(rename = "uiTokenAmount")] - ui_token_amount: TokenAmount, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct TokenAmount { - #[serde(rename = "uiAmount")] - ui_amount: f64, - decimals: u64, - amount: String, - #[serde(rename = "uiAmountString")] - ui_amount_string: String, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Status { - #[serde(rename = "Ok")] - ok: Option, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Transaction { - signatures: Vec, - message: Message, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Message { - #[serde(rename = "accountKeys")] - account_keys: Vec, - #[serde(rename = "recentBlockhash")] - recent_blockhash: String, - instructions: Vec, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct AccountKey { - pubkey: String, - writable: bool, - signer: bool, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Instruction { - program: Program, - #[serde(rename = "programId")] - program_id: String, - parsed: Parsed, -} - -#[allow(dead_code)] -impl Instruction { - pub fn is_solana_transfer(&self) -> bool { - let is_system = match self.program { - Program::SplToken => return false, - Program::System => true, - }; - let is_transfer = match self.parsed.parsed_type { - Type::Transfer => true, - Type::TransferChecked => true, - Type::Unknown => false, - }; - is_system && is_transfer && self.parsed.info.lamports.is_some() - } - - // Will be used later - pub fn is_spl_transfer(&self) -> bool { - let is_spl_token = match self.program { - Program::SplToken => true, - Program::System => return false, - }; - let is_transfer = match self.parsed.parsed_type { - Type::Transfer => true, - Type::TransferChecked => true, - Type::Unknown => false, - }; - is_spl_token && is_transfer - } -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Parsed { - info: Info, - #[serde(rename = "type")] - parsed_type: Type, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct Info { - destination: String, - lamports: Option, - source: String, - mint: Option, - #[serde(rename = "multisigAuthority")] - multisig_authority: Option, - signers: Option>, - #[serde(rename = "tokenAmount")] - token_amount: Option, - authority: Option, - amount: Option, -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum Type { - #[serde(rename = "transfer")] - Transfer, - #[serde(rename = "transferChecked")] - TransferChecked, - Unknown, -} - -#[derive(Debug, Serialize, Deserialize)] -pub enum Program { - #[serde(rename = "spl-token")] - SplToken, - #[serde(rename = "system")] - System, -} diff --git a/mm2src/coins/solana/solana_tests.rs b/mm2src/coins/solana/solana_tests.rs deleted file mode 100644 index d4126f35c0..0000000000 --- a/mm2src/coins/solana/solana_tests.rs +++ /dev/null @@ -1,436 +0,0 @@ -use base58::ToBase58; -use common::{block_on, block_on_f01, Future01CompatExt}; -use rpc::v1::types::Bytes; -use solana_client::rpc_request::TokenAccountsFilter; -use solana_sdk::{bs58, - signature::{Signature, Signer}}; -use solana_transaction_status::UiTransactionEncoding; -use std::{ops::Neg, str::FromStr}; - -use super::solana_common_tests::{generate_key_pair_from_iguana_seed, generate_key_pair_from_seed, - solana_coin_for_test, SolanaNet}; -use super::solana_decode_tx_helpers::SolanaConfirmedTransaction; -use super::*; -use crate::{MarketCoinOps, SwapTxTypeWithSecretHash}; - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_keypair_from_secp() { - let solana_key_pair = generate_key_pair_from_iguana_seed("federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string()); - assert_eq!( - "FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf", - solana_key_pair.pubkey().to_string() - ); - - let other_solana_keypair = generate_key_pair_from_iguana_seed("bob passphrase".to_string()); - assert_eq!( - "B7KMMHyc3eYguUMneXRznY1NWh91HoVA2muVJetstYKE", - other_solana_keypair.pubkey().to_string() - ); -} - -// Research tests -// TODO remove `ignore` attribute once the test is stable. -#[test] -#[ignore] -#[cfg(not(target_arch = "wasm32"))] -fn solana_prerequisites() { - // same test as trustwallet - { - let fin = - generate_key_pair_from_seed("hood vacant left trim hard mushroom device flavor ask better arrest again"); - let public_address = fin.pubkey().to_string(); - let priv_key = &fin.secret().to_bytes()[..].to_base58(); - assert_eq!(public_address.len(), 44); - assert_eq!(public_address, "4rmosKwMH7zeaXGbej1PFybZBUyuUNQLf8RfyzCcYvkx"); - assert_eq!(priv_key, "CZtxt17aTfDrJrzwBWdVqcmFwVVptW8EX7RRnth9tT3M"); - let client = solana_client::rpc_client::RpcClient::new("https://api.testnet.solana.com/".to_string()); - let balance = client.get_balance(&fin.pubkey()).expect("Expect to retrieve balance"); - assert_eq!(balance, 0); - } - - { - let key_pair = generate_key_pair_from_iguana_seed("passphrase not really secure".to_string()); - let public_address = key_pair.pubkey().to_string(); - assert_eq!(public_address.len(), 44); - assert_eq!(public_address, "2jTgfhf98GosnKSCXjL5YSiEa3MLrmR42yy9kZZq1i2c"); - let client = solana_client::rpc_client::RpcClient::new("https://api.testnet.solana.com/".to_string()); - let balance = client - .get_balance(&key_pair.pubkey()) - .expect("Expect to retrieve balance"); - assert_eq!(lamports_to_sol(balance), BigDecimal::from(0)); - assert_eq!(balance, 0); - - // This will fetch all the balance from all tokens - let token_accounts = client - .get_token_accounts_by_owner(&key_pair.pubkey(), TokenAccountsFilter::ProgramId(spl_token::id())) - .expect(""); - log!("{:?}", token_accounts); - let actual_token_pubkey = solana_sdk::pubkey::Pubkey::from_str(token_accounts[0].pubkey.as_str()).unwrap(); - let amount = client.get_token_account_balance(&actual_token_pubkey).unwrap(); - assert_ne!(amount.ui_amount_string.as_str(), "0"); - } -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_coin_creation() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - assert_eq!( - sol_coin.my_address().unwrap(), - "FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf" - ); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_my_balance() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let res = block_on(sol_coin.my_balance().compat()).unwrap(); - assert_ne!(res.spendable, BigDecimal::from(0)); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_block_height() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let res = block_on(sol_coin.current_block().compat()).unwrap(); - log!("block is : {}", res); - assert!(res > 0); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_validate_address() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - - // invalid len - let res = sol_coin.validate_address("invalidaddressobviously"); - assert!(!res.is_valid); - let res = sol_coin.validate_address("GMtMFbuVgjDnzsBd3LLBfM4X8RyYcDGCM92tPq2PG6B2"); - assert!(res.is_valid); - - // Typo - let res = sol_coin.validate_address("Fr8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riH"); - assert!(!res.is_valid); - - // invalid len - let res = sol_coin.validate_address("r8fraJXAe1cFU81mF7NhHTrUzXjZAJkQE1gUQ11riHn"); - assert!(!res.is_valid); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn test_sign_message() { - let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let signature = sol_coin.sign_message("test").unwrap(); - assert_eq!( - signature, - "4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF" - ); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn test_verify_message() { - let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let is_valid = sol_coin - .verify_message( - "4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF", - "test", - "8UF6jSVE1jW8mSiGqt8Hft1rLwPjdKLaTfhkNozFwoAG", - ) - .unwrap(); - assert!(is_valid); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_transaction_simulations() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let request_amount = BigDecimal::try_from(0.0001).unwrap(); - let valid_tx_details = block_on( - sol_coin - .withdraw(WithdrawRequest { - coin: "SOL".to_string(), - from: None, - to: sol_coin.my_address.clone(), - amount: request_amount.clone(), - max: false, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ) - .unwrap(); - let (_, fees) = block_on(sol_coin.estimate_withdraw_fees()).unwrap(); - let sol_required = lamports_to_sol(fees); - let expected_spent_by_me = &request_amount + &sol_required; - assert_eq!(valid_tx_details.spent_by_me, expected_spent_by_me); - assert_eq!(valid_tx_details.received_by_me, request_amount); - assert_eq!(valid_tx_details.total_amount, expected_spent_by_me); - assert_eq!(valid_tx_details.my_balance_change, sol_required.neg()); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_transaction_zero_balance() { - let passphrase = "fake passphrase".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let invalid_tx_details = block_on( - sol_coin - .withdraw(WithdrawRequest { - coin: "SOL".to_string(), - from: None, - to: sol_coin.my_address.clone(), - amount: BigDecimal::from_str("0.000001").unwrap(), - max: false, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ); - let error = invalid_tx_details.unwrap_err(); - let (_, fees) = block_on(sol_coin.estimate_withdraw_fees()).unwrap(); - let sol_required = lamports_to_sol(fees); - match error.into_inner() { - WithdrawError::NotSufficientBalance { required, .. } => { - assert_eq!(required, sol_required); - }, - e => panic!("Unexpected err {:?}", e), - }; -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_transaction_simulations_not_enough_for_fees() { - let passphrase = "non existent passphrase".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let invalid_tx_details = block_on( - sol_coin - .withdraw(WithdrawRequest { - coin: "SOL".to_string(), - from: None, - to: sol_coin.my_address.clone(), - amount: BigDecimal::from(1), - max: false, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ); - let error = invalid_tx_details.unwrap_err(); - let (_, fees) = block_on(sol_coin.estimate_withdraw_fees()).unwrap(); - let sol_required = lamports_to_sol(fees); - match error.into_inner() { - WithdrawError::NotSufficientBalance { - coin: _, - available, - required, - } => { - assert_eq!(available, 0.into()); - assert_eq!(required, sol_required); - }, - e => panic!("Unexpected err {:?}", e), - }; -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_transaction_simulations_max() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let valid_tx_details = block_on( - sol_coin - .withdraw(WithdrawRequest { - coin: "SOL".to_string(), - from: None, - to: sol_coin.my_address.clone(), - amount: BigDecimal::from(0), - max: true, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ) - .unwrap(); - let balance = block_on(sol_coin.my_balance().compat()).unwrap().spendable; - let (_, fees) = block_on(sol_coin.estimate_withdraw_fees()).unwrap(); - let sol_required = lamports_to_sol(fees); - assert_eq!(valid_tx_details.my_balance_change, sol_required.clone().neg()); - assert_eq!(valid_tx_details.total_amount, balance); - assert_eq!(valid_tx_details.spent_by_me, balance); - assert_eq!(valid_tx_details.received_by_me, &balance - &sol_required); - log!("{:?}", valid_tx_details); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn solana_test_transactions() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let valid_tx_details = block_on( - sol_coin - .withdraw(WithdrawRequest { - coin: "SOL".to_string(), - from: None, - to: sol_coin.my_address.clone(), - amount: BigDecimal::try_from(0.0001).unwrap(), - max: false, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ) - .unwrap(); - log!("{:?}", valid_tx_details); - - let tx_str = hex::encode(&*valid_tx_details.tx.tx_hex().unwrap().0); - let res = block_on(sol_coin.send_raw_tx(&tx_str).compat()).unwrap(); - - let res2 = block_on( - sol_coin - .send_raw_tx_bytes(&valid_tx_details.tx.tx_hex().unwrap().0) - .compat(), - ) - .unwrap(); - assert_eq!(res, res2); - - //log!("{:?}", res); -} - -// This test is just a unit test for brainstorming around tx_history for base_coin. -#[test] -#[ignore] -#[cfg(not(target_arch = "wasm32"))] -fn solana_test_tx_history() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let res = sol_coin - .client - .get_signatures_for_address(&sol_coin.key_pair.pubkey()) - .unwrap(); - let mut history = Vec::new(); - for cur in res.iter() { - let signature = Signature::from_str(cur.signature.clone().as_str()).unwrap(); - let res = sol_coin - .client - .get_transaction(&signature, UiTransactionEncoding::JsonParsed) - .unwrap(); - log!("{}", serde_json::to_string(&res).unwrap()); - let parsed = serde_json::to_value(&res).unwrap(); - let tx_infos: SolanaConfirmedTransaction = serde_json::from_value(parsed).unwrap(); - let mut txs = tx_infos.extract_solana_transactions(&sol_coin).unwrap(); - history.append(&mut txs); - } - log!("{}", serde_json::to_string(&history).unwrap()); -} - -#[test] -fn solana_coin_send_and_refund_maker_payment() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let solana_program_id = "3fystoi7pB1cnDEbRRpSjFJA4fG3W2vQQZ21jSrBc11B"; - let solana_program_id = bs58::decode(solana_program_id).into_vec().unwrap_or_else(|e| { - log!("Failed to decode program ID: {}", e); - Vec::new() - }); - - let pk_data = [1; 32]; - let time_lock = now_sec() - 3600; - let taker_pub = coin.key_pair.pubkey().to_string(); - let taker_pub = Pubkey::from_str(taker_pub.as_str()).unwrap(); - let secret = [0; 32]; - let secret_hash = sha256(&secret); - - let args = SendPaymentArgs { - time_lock_duration: 0, - time_lock, - other_pubkey: taker_pub.as_ref(), - secret_hash: secret_hash.as_slice(), - amount: "0.01".parse().unwrap(), - swap_contract_address: &Some(Bytes::from(solana_program_id.clone())), - swap_unique_data: &[], - payment_instructions: &None, - watcher_reward: None, - wait_for_confirmation_until: 0, - }; - let tx = block_on_f01(coin.send_maker_payment(args)).unwrap(); - log!("swap tx {:?}", tx); - - let refund_args = RefundPaymentArgs { - payment_tx: &tx.tx_hex(), - time_lock, - other_pubkey: taker_pub.as_ref(), - tx_type_with_secret_hash: SwapTxTypeWithSecretHash::TakerOrMakerPayment { - maker_secret_hash: secret_hash.as_slice(), - }, - swap_contract_address: &Some(Bytes::from(solana_program_id)), - swap_unique_data: pk_data.as_slice(), - watcher_reward: false, - }; - let refund_tx = block_on(coin.send_maker_refunds_payment(refund_args)).unwrap(); - log!("refund tx {:?}", refund_tx); -} - -#[test] -fn solana_coin_send_and_spend_maker_payment() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, coin) = solana_coin_for_test(passphrase, SolanaNet::Devnet); - let solana_program_id = "3fystoi7pB1cnDEbRRpSjFJA4fG3W2vQQZ21jSrBc11B"; - let solana_program_id = bs58::decode(solana_program_id).into_vec().unwrap_or_else(|e| { - log!("Failed to decode program ID: {}", e); - Vec::new() - }); - - let pk_data = [1; 32]; - let lock_time = now_sec() - 1000; - let taker_pub = coin.key_pair.pubkey().to_string(); - let taker_pub = Pubkey::from_str(taker_pub.as_str()).unwrap(); - let secret = [0; 32]; - let secret_hash = sha256(&secret); - - let maker_payment_args = SendPaymentArgs { - time_lock_duration: 0, - time_lock: lock_time, - other_pubkey: taker_pub.as_ref(), - secret_hash: secret_hash.as_slice(), - amount: "0.01".parse().unwrap(), - swap_contract_address: &Some(Bytes::from(solana_program_id.clone())), - swap_unique_data: &[], - payment_instructions: &None, - watcher_reward: None, - wait_for_confirmation_until: 0, - }; - - let tx = block_on_f01(coin.send_maker_payment(maker_payment_args)).unwrap(); - log!("swap tx {:?}", tx); - - let maker_pub = taker_pub; - - let spends_payment_args = SpendPaymentArgs { - other_payment_tx: &tx.tx_hex(), - time_lock: lock_time, - other_pubkey: maker_pub.as_ref(), - secret: &secret, - secret_hash: secret_hash.as_slice(), - swap_contract_address: &Some(Bytes::from(solana_program_id)), - swap_unique_data: pk_data.as_slice(), - watcher_reward: false, - }; - - let spend_tx = block_on(coin.send_taker_spends_maker_payment(spends_payment_args)).unwrap(); - log!("spend tx {}", hex::encode(spend_tx.tx_hash_as_bytes().0)); -} diff --git a/mm2src/coins/solana/spl.rs b/mm2src/coins/solana/spl.rs deleted file mode 100644 index 7bc720e5e7..0000000000 --- a/mm2src/coins/solana/spl.rs +++ /dev/null @@ -1,600 +0,0 @@ -use super::{CoinBalance, HistorySyncState, MarketCoinOps, MmCoin, SwapOps, TradeFee, TransactionEnum, WatcherOps}; -use crate::coin_errors::{MyAddressError, ValidatePaymentResult}; -use crate::solana::solana_common::{ui_amount_to_amount, PrepareTransferData, SufficientBalanceError}; -use crate::solana::{solana_common, AccountError, SolanaCommonOps, SolanaFeeDetails}; -use crate::{BalanceFut, CheckIfMyPaymentSentArgs, CoinFutSpawner, ConfirmPaymentInput, DexFee, FeeApproxStage, - FoundSwapTxSpend, MakerSwapTakerCoin, MmCoinEnum, NegotiateSwapContractAddrErr, PaymentInstructionArgs, - PaymentInstructions, PaymentInstructionsErr, RawTransactionError, RawTransactionFut, - RawTransactionRequest, RawTransactionResult, RefundError, RefundPaymentArgs, RefundResult, - SearchForSwapTxSpendInput, SendMakerPaymentSpendPreimageInput, SendPaymentArgs, SignRawTransactionRequest, - SignatureResult, SolanaCoin, SpendPaymentArgs, TakerSwapMakerCoin, TradePreimageFut, TradePreimageResult, - TradePreimageValue, TransactionData, TransactionDetails, TransactionFut, TransactionResult, - TransactionType, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidateFeeArgs, - ValidateInstructionsErr, ValidateOtherPubKeyErr, ValidatePaymentError, ValidatePaymentFut, - ValidatePaymentInput, ValidateWatcherSpendInput, VerificationResult, WaitForHTLCTxSpendArgs, - WatcherReward, WatcherRewardError, WatcherSearchForSwapTxSpendInput, WatcherValidatePaymentInput, - WatcherValidateTakerFeeInput, WithdrawError, WithdrawFut, WithdrawRequest, WithdrawResult}; -use async_trait::async_trait; -use bincode::serialize; -use common::executor::{abortable_queue::AbortableQueue, AbortableSystem, AbortedError}; -use common::{async_blocking, now_sec}; -use futures::{FutureExt, TryFutureExt}; -use futures01::Future; -use keys::KeyPair; -use mm2_core::mm_ctx::MmArc; -use mm2_err_handle::prelude::*; -use mm2_number::{BigDecimal, MmNumber}; -use rpc::v1::types::Bytes as BytesJson; -use serde_json::Value as Json; -use solana_client::{rpc_client::RpcClient, rpc_request::TokenAccountsFilter}; -use solana_sdk::message::Message; -use solana_sdk::transaction::Transaction; -use solana_sdk::{pubkey::Pubkey, signature::Signer}; -use spl_associated_token_account::{create_associated_token_account, get_associated_token_address}; -use std::{convert::TryFrom, - fmt::{Debug, Formatter, Result as FmtResult}, - str::FromStr, - sync::Arc}; - -#[derive(Debug)] -pub enum SplTokenCreationError { - InvalidPubkey(String), - Internal(String), -} - -impl From for SplTokenCreationError { - fn from(e: AbortedError) -> Self { SplTokenCreationError::Internal(e.to_string()) } -} - -pub struct SplTokenFields { - pub decimals: u8, - pub ticker: String, - pub token_contract_address: Pubkey, - pub abortable_system: AbortableQueue, -} - -#[derive(Clone, Debug)] -pub struct SplTokenInfo { - pub token_contract_address: Pubkey, - pub decimals: u8, -} - -#[derive(Debug)] -pub struct SplProtocolConf { - pub platform_coin_ticker: String, - pub decimals: u8, - pub token_contract_address: String, -} - -#[derive(Clone)] -pub struct SplToken { - pub conf: Arc, - pub platform_coin: SolanaCoin, -} - -impl Debug for SplToken { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { f.write_str(&self.conf.ticker) } -} - -impl SplToken { - pub fn new( - decimals: u8, - ticker: String, - token_address: String, - platform_coin: SolanaCoin, - ) -> MmResult { - let token_contract_address = solana_sdk::pubkey::Pubkey::from_str(&token_address) - .map_err(|e| MmError::new(SplTokenCreationError::InvalidPubkey(format!("{:?}", e))))?; - - // Create an abortable system linked to the `platform_coin` so if the platform coin is disabled, - // all spawned futures related to `SplToken` will be aborted as well. - let abortable_system = platform_coin.abortable_system.create_subsystem()?; - - let conf = Arc::new(SplTokenFields { - decimals, - ticker, - token_contract_address, - abortable_system, - }); - Ok(SplToken { conf, platform_coin }) - } - - pub fn get_info(&self) -> SplTokenInfo { - SplTokenInfo { - token_contract_address: self.conf.token_contract_address, - decimals: self.decimals(), - } - } -} - -async fn withdraw_spl_token_impl(coin: SplToken, req: WithdrawRequest) -> WithdrawResult { - let (hash, fees) = coin.platform_coin.estimate_withdraw_fees().await?; - let res = coin - .check_balance_and_prepare_transfer(req.max, req.amount.clone(), fees) - .await?; - let system_destination_pubkey = solana_sdk::pubkey::Pubkey::try_from(&*req.to)?; - let contract_key = coin.get_underlying_contract_pubkey(); - let auth_key = coin.platform_coin.key_pair.pubkey(); - let funding_address = coin.get_pubkey().await?; - let dest_token_address = get_associated_token_address(&system_destination_pubkey, &contract_key); - let mut instructions = Vec::with_capacity(1); - let account_info = async_blocking({ - let coin = coin.clone(); - move || coin.rpc().get_account(&dest_token_address) - }) - .await; - if account_info.is_err() { - let instruction_creation = create_associated_token_account(&auth_key, &dest_token_address, &contract_key); - instructions.push(instruction_creation); - } - let amount = ui_amount_to_amount(req.amount, coin.conf.decimals)?; - let instruction_transfer_checked = spl_token::instruction::transfer_checked( - &spl_token::id(), - &funding_address, - &contract_key, - &dest_token_address, - &auth_key, - &[&auth_key], - amount, - coin.conf.decimals, - )?; - instructions.push(instruction_transfer_checked); - let msg = Message::new(&instructions, Some(&auth_key)); - let signers = vec![&coin.platform_coin.key_pair]; - let tx = Transaction::new(&signers, msg, hash); - let serialized_tx = serialize(&tx).map_to_mm(|e| WithdrawError::InternalError(e.to_string()))?; - let received_by_me = if req.to == coin.platform_coin.my_address { - res.to_send.clone() - } else { - 0.into() - }; - Ok(TransactionDetails { - tx: TransactionData::new_signed(serialized_tx.into(), tx.signatures[0].to_string()), - from: vec![coin.platform_coin.my_address.clone()], - to: vec![req.to], - total_amount: res.to_send.clone(), - spent_by_me: res.to_send.clone(), - my_balance_change: &received_by_me - &res.to_send, - received_by_me, - block_height: 0, - timestamp: now_sec(), - fee_details: Some( - SolanaFeeDetails { - amount: res.sol_required, - } - .into(), - ), - coin: coin.conf.ticker.clone(), - internal_id: vec![].into(), - kmd_rewards: None, - transaction_type: TransactionType::StandardTransfer, - memo: None, - }) -} - -async fn withdraw_impl(coin: SplToken, req: WithdrawRequest) -> WithdrawResult { - let validate_address_result = coin.validate_address(&req.to); - if !validate_address_result.is_valid { - return MmError::err(WithdrawError::InvalidAddress( - validate_address_result.reason.unwrap_or_else(|| "Unknown".to_string()), - )); - } - withdraw_spl_token_impl(coin, req).await -} - -#[async_trait] -impl SolanaCommonOps for SplToken { - fn rpc(&self) -> &RpcClient { &self.platform_coin.client } - - fn is_token(&self) -> bool { true } - - async fn check_balance_and_prepare_transfer( - &self, - max: bool, - amount: BigDecimal, - fees: u64, - ) -> Result> { - solana_common::check_balance_and_prepare_transfer(self, max, amount, fees).await - } -} - -impl SplToken { - fn get_underlying_contract_pubkey(&self) -> Pubkey { self.conf.token_contract_address } - - async fn get_pubkey(&self) -> Result> { - let coin = self.clone(); - let token_accounts = async_blocking(move || { - coin.rpc().get_token_accounts_by_owner( - &coin.platform_coin.key_pair.pubkey(), - TokenAccountsFilter::Mint(coin.get_underlying_contract_pubkey()), - ) - }) - .await?; - if token_accounts.is_empty() { - return MmError::err(AccountError::NotFundedError("account_not_funded".to_string())); - } - Ok(Pubkey::from_str(&token_accounts[0].pubkey)?) - } - - fn my_balance_impl(&self) -> BalanceFut { - let coin = self.clone(); - let fut = async move { - coin.platform_coin - .my_balance_spl(SplTokenInfo { - token_contract_address: coin.conf.token_contract_address, - decimals: coin.conf.decimals, - }) - .await - }; - Box::new(fut.boxed().compat()) - } -} - -#[async_trait] -impl MarketCoinOps for SplToken { - fn ticker(&self) -> &str { &self.conf.ticker } - - fn my_address(&self) -> MmResult { Ok(self.platform_coin.my_address.clone()) } - - async fn get_public_key(&self) -> Result> { unimplemented!() } - - fn sign_message_hash(&self, _message: &str) -> Option<[u8; 32]> { unimplemented!() } - - fn sign_message(&self, message: &str) -> SignatureResult { - solana_common::sign_message(&self.platform_coin, message) - } - - fn verify_message(&self, signature: &str, message: &str, pubkey_bs58: &str) -> VerificationResult { - solana_common::verify_message(&self.platform_coin, signature, message, pubkey_bs58) - } - - fn my_balance(&self) -> BalanceFut { - let fut = self.my_balance_impl().and_then(Ok); - Box::new(fut) - } - - fn base_coin_balance(&self) -> BalanceFut { self.platform_coin.base_coin_balance() } - - fn platform_ticker(&self) -> &str { self.platform_coin.ticker() } - - #[inline(always)] - fn send_raw_tx(&self, tx: &str) -> Box + Send> { - self.platform_coin.send_raw_tx(tx) - } - - #[inline(always)] - fn send_raw_tx_bytes(&self, tx: &[u8]) -> Box + Send> { - self.platform_coin.send_raw_tx_bytes(tx) - } - - #[inline(always)] - async fn sign_raw_tx(&self, _args: &SignRawTransactionRequest) -> RawTransactionResult { - MmError::err(RawTransactionError::NotImplemented { - coin: self.ticker().to_string(), - }) - } - - fn wait_for_confirmations(&self, _input: ConfirmPaymentInput) -> Box + Send> { - unimplemented!() - } - - fn wait_for_htlc_tx_spend(&self, args: WaitForHTLCTxSpendArgs<'_>) -> TransactionFut { unimplemented!() } - - fn tx_enum_from_bytes(&self, _bytes: &[u8]) -> Result> { - MmError::err(TxMarshalingErr::NotSupported( - "tx_enum_from_bytes is not supported for Spl yet.".to_string(), - )) - } - - fn current_block(&self) -> Box + Send> { self.platform_coin.current_block() } - - fn display_priv_key(&self) -> Result { self.platform_coin.display_priv_key() } - - fn min_tx_amount(&self) -> BigDecimal { BigDecimal::from(0) } - - fn min_trading_vol(&self) -> MmNumber { MmNumber::from("0.00777") } - - fn is_trezor(&self) -> bool { self.platform_coin.is_trezor() } -} - -#[async_trait] -impl SwapOps for SplToken { - fn send_taker_fee(&self, _fee_addr: &[u8], dex_fee: DexFee, _uuid: &[u8], _expire_at: u64) -> TransactionFut { - unimplemented!() - } - - fn send_maker_payment(&self, _maker_payment_args: SendPaymentArgs) -> TransactionFut { unimplemented!() } - - fn send_taker_payment(&self, _taker_payment_args: SendPaymentArgs) -> TransactionFut { unimplemented!() } - - async fn send_maker_spends_taker_payment( - &self, - _maker_spends_payment_args: SpendPaymentArgs<'_>, - ) -> TransactionResult { - unimplemented!() - } - - async fn send_taker_spends_maker_payment( - &self, - _taker_spends_payment_args: SpendPaymentArgs<'_>, - ) -> TransactionResult { - unimplemented!() - } - - async fn send_taker_refunds_payment( - &self, - _taker_refunds_payment_args: RefundPaymentArgs<'_>, - ) -> TransactionResult { - unimplemented!() - } - - async fn send_maker_refunds_payment( - &self, - _maker_refunds_payment_args: RefundPaymentArgs<'_>, - ) -> TransactionResult { - todo!() - } - - fn validate_fee(&self, _validate_fee_args: ValidateFeeArgs) -> ValidatePaymentFut<()> { unimplemented!() } - - async fn validate_maker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { - unimplemented!() - } - - async fn validate_taker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { - unimplemented!() - } - - fn check_if_my_payment_sent( - &self, - _if_my_payment_sent_args: CheckIfMyPaymentSentArgs, - ) -> Box, Error = String> + Send> { - unimplemented!() - } - - async fn search_for_swap_tx_spend_my( - &self, - _: SearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!() - } - - async fn search_for_swap_tx_spend_other( - &self, - _: SearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!() - } - - fn check_tx_signed_by_pub(&self, tx: &[u8], expected_pub: &[u8]) -> Result> { - unimplemented!(); - } - - async fn extract_secret( - &self, - secret_hash: &[u8], - spend_tx: &[u8], - watcher_reward: bool, - ) -> Result, String> { - unimplemented!() - } - - fn is_auto_refundable(&self) -> bool { false } - - async fn wait_for_htlc_refund(&self, _tx: &[u8], _locktime: u64) -> RefundResult<()> { - MmError::err(RefundError::Internal( - "wait_for_htlc_refund is not supported for this coin!".into(), - )) - } - - fn negotiate_swap_contract_addr( - &self, - _other_side_address: Option<&[u8]>, - ) -> Result, MmError> { - unimplemented!() - } - - #[inline] - fn derive_htlc_key_pair(&self, _swap_unique_data: &[u8]) -> KeyPair { todo!() } - - #[inline] - fn derive_htlc_pubkey(&self, swap_unique_data: &[u8]) -> Vec { - self.derive_htlc_key_pair(swap_unique_data).public_slice().to_vec() - } - - fn validate_other_pubkey(&self, _raw_pubkey: &[u8]) -> MmResult<(), ValidateOtherPubKeyErr> { unimplemented!() } - - async fn maker_payment_instructions( - &self, - _args: PaymentInstructionArgs<'_>, - ) -> Result>, MmError> { - unimplemented!() - } - - async fn taker_payment_instructions( - &self, - _args: PaymentInstructionArgs<'_>, - ) -> Result>, MmError> { - unimplemented!() - } - - fn validate_maker_payment_instructions( - &self, - _instructions: &[u8], - _args: PaymentInstructionArgs<'_>, - ) -> Result> { - unimplemented!() - } - - fn validate_taker_payment_instructions( - &self, - _instructions: &[u8], - _args: PaymentInstructionArgs<'_>, - ) -> Result> { - unimplemented!() - } -} - -#[async_trait] -impl TakerSwapMakerCoin for SplToken { - async fn on_taker_payment_refund_start(&self, _maker_payment: &[u8]) -> RefundResult<()> { Ok(()) } - - async fn on_taker_payment_refund_success(&self, _maker_payment: &[u8]) -> RefundResult<()> { Ok(()) } -} - -#[async_trait] -impl MakerSwapTakerCoin for SplToken { - async fn on_maker_payment_refund_start(&self, _taker_payment: &[u8]) -> RefundResult<()> { Ok(()) } - - async fn on_maker_payment_refund_success(&self, _taker_payment: &[u8]) -> RefundResult<()> { Ok(()) } -} - -#[async_trait] -impl WatcherOps for SplToken { - fn send_maker_payment_spend_preimage(&self, _input: SendMakerPaymentSpendPreimageInput) -> TransactionFut { - unimplemented!(); - } - - fn create_taker_payment_refund_preimage( - &self, - _taker_payment_tx: &[u8], - _time_lock: u64, - _maker_pub: &[u8], - _secret_hash: &[u8], - _swap_contract_address: &Option, - _swap_unique_data: &[u8], - ) -> TransactionFut { - unimplemented!(); - } - - fn create_maker_payment_spend_preimage( - &self, - _maker_payment_tx: &[u8], - _time_lock: u64, - _maker_pub: &[u8], - _secret_hash: &[u8], - _swap_unique_data: &[u8], - ) -> TransactionFut { - unimplemented!(); - } - - fn send_taker_payment_refund_preimage(&self, _watcher_refunds_payment_args: RefundPaymentArgs) -> TransactionFut { - unimplemented!(); - } - - fn watcher_validate_taker_fee(&self, _input: WatcherValidateTakerFeeInput) -> ValidatePaymentFut<()> { - unimplemented!(); - } - - fn watcher_validate_taker_payment(&self, _input: WatcherValidatePaymentInput) -> ValidatePaymentFut<()> { - unimplemented!(); - } - - fn taker_validates_payment_spend_or_refund(&self, _input: ValidateWatcherSpendInput) -> ValidatePaymentFut<()> { - unimplemented!() - } - - async fn watcher_search_for_swap_tx_spend( - &self, - input: WatcherSearchForSwapTxSpendInput<'_>, - ) -> Result, String> { - unimplemented!(); - } - - async fn get_taker_watcher_reward( - &self, - other_coin: &MmCoinEnum, - coin_amount: Option, - other_coin_amount: Option, - reward_amount: Option, - wait_until: u64, - ) -> Result> { - unimplemented!(); - } - - async fn get_maker_watcher_reward( - &self, - other_coin: &MmCoinEnum, - reward_amount: Option, - wait_until: u64, - ) -> Result, MmError> { - unimplemented!(); - } -} - -#[async_trait] -impl MmCoin for SplToken { - fn is_asset_chain(&self) -> bool { false } - - fn spawner(&self) -> CoinFutSpawner { CoinFutSpawner::new(&self.conf.abortable_system) } - - fn withdraw(&self, req: WithdrawRequest) -> WithdrawFut { - Box::new(Box::pin(withdraw_impl(self.clone(), req)).compat()) - } - - fn get_raw_transaction(&self, _req: RawTransactionRequest) -> RawTransactionFut { unimplemented!() } - - fn get_tx_hex_by_hash(&self, tx_hash: Vec) -> RawTransactionFut { unimplemented!() } - - fn decimals(&self) -> u8 { self.conf.decimals } - - fn convert_to_address(&self, _from: &str, _to_address_format: Json) -> Result { unimplemented!() } - - fn validate_address(&self, address: &str) -> ValidateAddressResult { self.platform_coin.validate_address(address) } - - fn process_history_loop(&self, _ctx: MmArc) -> Box + Send> { unimplemented!() } - - fn history_sync_status(&self) -> HistorySyncState { unimplemented!() } - - /// Get fee to be paid per 1 swap transaction - fn get_trade_fee(&self) -> Box + Send> { unimplemented!() } - - async fn get_sender_trade_fee( - &self, - _value: TradePreimageValue, - _stage: FeeApproxStage, - _include_refund_fee: bool, - ) -> TradePreimageResult { - unimplemented!() - } - - fn get_receiver_trade_fee(&self, _stage: FeeApproxStage) -> TradePreimageFut { unimplemented!() } - - async fn get_fee_to_send_taker_fee( - &self, - _dex_fee_amount: DexFee, - _stage: FeeApproxStage, - ) -> TradePreimageResult { - unimplemented!() - } - - fn required_confirmations(&self) -> u64 { 1 } - - fn requires_notarization(&self) -> bool { false } - - fn set_required_confirmations(&self, _confirmations: u64) { unimplemented!() } - - fn set_requires_notarization(&self, _requires_nota: bool) { unimplemented!() } - - fn swap_contract_address(&self) -> Option { unimplemented!() } - - fn fallback_swap_contract(&self) -> Option { unimplemented!() } - - fn mature_confirmations(&self) -> Option { Some(1) } - - fn coin_protocol_info(&self, _amount_to_receive: Option) -> Vec { Vec::new() } - - fn is_coin_protocol_supported( - &self, - _info: &Option>, - _amount_to_send: Option, - _locktime: u64, - _is_maker: bool, - ) -> bool { - true - } - - fn on_disabled(&self) -> Result<(), AbortedError> { self.conf.abortable_system.abort_all() } - - fn on_token_deactivated(&self, _ticker: &str) {} -} diff --git a/mm2src/coins/solana/spl_tests.rs b/mm2src/coins/solana/spl_tests.rs deleted file mode 100644 index 10943e6e33..0000000000 --- a/mm2src/coins/solana/spl_tests.rs +++ /dev/null @@ -1,138 +0,0 @@ -use super::*; -use crate::{solana::solana_common_tests::solana_coin_for_test, - solana::solana_common_tests::{spl_coin_for_test, SolanaNet}}; -use common::{block_on, Future01CompatExt}; -use std::ops::Neg; -use std::str::FromStr; - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn spl_coin_creation() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let sol_spl_usdc_coin = spl_coin_for_test( - sol_coin, - "USDC".to_string(), - 6, - solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(), - ); - - log!("address: {}", sol_spl_usdc_coin.my_address().unwrap()); - assert_eq!( - sol_spl_usdc_coin.my_address().unwrap(), - "FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf" - ); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn test_sign_message() { - let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let sol_spl_usdc_coin = spl_coin_for_test( - sol_coin, - "USDC".to_string(), - 6, - solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(), - ); - let signature = sol_spl_usdc_coin.sign_message("test").unwrap(); - assert_eq!( - signature, - "4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF" - ); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn test_verify_message() { - let passphrase = "spice describe gravity federal blast come thank unfair canal monkey style afraid".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let sol_spl_usdc_coin = spl_coin_for_test( - sol_coin, - "USDC".to_string(), - 6, - solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(), - ); - let is_valid = sol_spl_usdc_coin - .verify_message( - "4dzKwEteN8nch76zPMEjPX19RsaQwGTxsbtfg2bwGTkGenLfrdm31zvn9GH5rvaJBwivp6ESXx1KYR672ngs3UfF", - "test", - "8UF6jSVE1jW8mSiGqt8Hft1rLwPjdKLaTfhkNozFwoAG", - ) - .unwrap(); - assert!(is_valid); -} - -#[test] -#[cfg(not(target_arch = "wasm32"))] -fn spl_my_balance() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let sol_spl_usdc_coin = spl_coin_for_test( - sol_coin.clone(), - "USDC".to_string(), - 6, - solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(), - ); - - let res = block_on(sol_spl_usdc_coin.my_balance().compat()).unwrap(); - assert_ne!(res.spendable, BigDecimal::from(0)); - assert!(res.spendable < BigDecimal::from(10)); - - let sol_spl_wsol_coin = spl_coin_for_test( - sol_coin, - "WSOL".to_string(), - 8, - solana_sdk::pubkey::Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(), - ); - let res = block_on(sol_spl_wsol_coin.my_balance().compat()).unwrap(); - assert_eq!(res.spendable, BigDecimal::from(0)); -} - -// Stop ignoring when Solana is released -#[test] -#[ignore] -#[cfg(not(target_arch = "wasm32"))] -fn test_spl_transactions() { - let passphrase = "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron".to_string(); - let (_, sol_coin) = solana_coin_for_test(passphrase, SolanaNet::Testnet); - let usdc_sol_coin = spl_coin_for_test( - sol_coin, - "USDC".to_string(), - 6, - solana_sdk::pubkey::Pubkey::from_str("CpMah17kQEL2wqyMKt3mZBdTnZbkbfx4nqmQMFDP5vwp").unwrap(), - ); - let withdraw_amount = BigDecimal::from_str("0.0001").unwrap(); - let valid_tx_details = block_on( - usdc_sol_coin - .withdraw(WithdrawRequest { - coin: "USDC".to_string(), - from: None, - to: "AYJmtzc9D4KU6xsDzhKShFyYKUNXY622j9QoQEo4LfpX".to_string(), - amount: withdraw_amount.clone(), - max: false, - fee: None, - memo: None, - ibc_source_channel: None, - }) - .compat(), - ) - .unwrap(); - log!("{:?}", valid_tx_details); - assert_eq!(valid_tx_details.total_amount, withdraw_amount); - assert_eq!(valid_tx_details.my_balance_change, withdraw_amount.neg()); - assert_eq!(valid_tx_details.coin, "USDC".to_string()); - assert_ne!(valid_tx_details.timestamp, 0); - - let tx_str = hex::encode(&*valid_tx_details.tx.tx_hex().unwrap().0); - let res = block_on(usdc_sol_coin.send_raw_tx(&tx_str).compat()).unwrap(); - log!("{:?}", res); - - let res2 = block_on( - usdc_sol_coin - .send_raw_tx_bytes(&valid_tx_details.tx.tx_hex().unwrap().0) - .compat(), - ) - .unwrap(); - assert_eq!(res, res2); -} diff --git a/mm2src/coins_activation/Cargo.toml b/mm2src/coins_activation/Cargo.toml index aef4b9b557..be951c67d4 100644 --- a/mm2src/coins_activation/Cargo.toml +++ b/mm2src/coins_activation/Cargo.toml @@ -8,7 +8,6 @@ doctest = false [features] enable-sia = [] -enable-solana = [] default = [] for-tests = [] diff --git a/mm2src/coins_activation/src/lib.rs b/mm2src/coins_activation/src/lib.rs index 8a779b80f4..8020f91f27 100644 --- a/mm2src/coins_activation/src/lib.rs +++ b/mm2src/coins_activation/src/lib.rs @@ -10,20 +10,6 @@ mod platform_coin_with_tokens; mod prelude; #[cfg(feature = "enable-sia")] mod sia_coin_activation; mod slp_token_activation; -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -mod solana_with_tokens_activation; -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -mod spl_token_activation; mod standalone_coin; mod tendermint_token_activation; mod tendermint_with_assets_activation; diff --git a/mm2src/coins_activation/src/solana_with_tokens_activation.rs b/mm2src/coins_activation/src/solana_with_tokens_activation.rs deleted file mode 100644 index f411995779..0000000000 --- a/mm2src/coins_activation/src/solana_with_tokens_activation.rs +++ /dev/null @@ -1,327 +0,0 @@ -use crate::context::CoinsActivationContext; -use crate::platform_coin_with_tokens::{EnablePlatformCoinWithTokensError, GetPlatformBalance, - InitPlatformCoinWithTokensAwaitingStatus, - InitPlatformCoinWithTokensInProgressStatus, InitPlatformCoinWithTokensTask, - InitPlatformCoinWithTokensTaskManagerShared, - InitPlatformCoinWithTokensUserAction, InitTokensAsMmCoinsError, - PlatformCoinWithTokensActivationOps, RegisterTokenInfo, TokenActivationParams, - TokenActivationRequest, TokenAsMmCoinInitializer, TokenInitializer, TokenOf}; -use crate::prelude::*; -use crate::prelude::{CoinAddressInfo, TokenBalances, TryFromCoinProtocol, TxHistory}; -use crate::spl_token_activation::SplActivationRequest; -use async_trait::async_trait; -use coins::coin_errors::MyAddressError; -use coins::my_tx_history_v2::TxHistoryStorage; -use coins::solana::solana_coin_with_policy; -use coins::solana::spl::{SplProtocolConf, SplTokenCreationError}; -use coins::{BalanceError, CoinBalance, CoinProtocol, DerivationMethodResponse, MarketCoinOps, MmCoinEnum, - PrivKeyBuildPolicy, SolanaActivationParams, SolanaCoin, SplToken}; -use common::Future01CompatExt; -use common::{drop_mutability, true_f}; -use crypto::CryptoCtxError; -use futures::future::try_join_all; -use mm2_core::mm_ctx::MmArc; -use mm2_err_handle::prelude::*; -use mm2_event_stream::EventStreamConfiguration; -use mm2_number::BigDecimal; -use rpc_task::RpcTaskHandleShared; -use serde_derive::{Deserialize, Serialize}; -use serde_json::Value as Json; -use std::collections::HashMap; - -pub struct SplTokenInitializer { - platform_coin: SolanaCoin, -} - -impl TokenOf for SplToken { - type PlatformCoin = SolanaCoin; -} - -pub struct SplTokenInitializerErr { - ticker: String, - inner: SplTokenCreationError, -} - -#[async_trait] -impl TokenInitializer for SplTokenInitializer { - type Token = SplToken; - type TokenActivationRequest = SplActivationRequest; - type TokenProtocol = SplProtocolConf; - type InitTokensError = SplTokenInitializerErr; - - fn tokens_requests_from_platform_request( - platform_params: &SolanaWithTokensActivationRequest, - ) -> Vec> { - platform_params.spl_tokens_requests.clone() - } - - async fn enable_tokens( - &self, - activation_params: Vec>, - ) -> Result, MmError> { - let tokens = activation_params - .into_iter() - .map(|param| { - let ticker = param.ticker.clone(); - SplToken::new( - param.protocol.decimals, - param.ticker, - param.protocol.token_contract_address, - self.platform_coin.clone(), - ) - .mm_err(|inner| SplTokenInitializerErr { ticker, inner }) - }) - .collect::, _>>()?; - Ok(tokens) - } - - fn platform_coin(&self) -> &SolanaCoin { &self.platform_coin } -} - -impl RegisterTokenInfo for SolanaCoin { - fn register_token_info(&self, token: &SplToken) { self.add_spl_token_info(token.ticker().into(), token.get_info()) } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SolanaWithTokensActivationRequest { - #[serde(flatten)] - platform_request: SolanaActivationParams, - spl_tokens_requests: Vec>, - #[serde(default = "true_f")] - pub get_balances: bool, -} - -impl TxHistory for SolanaWithTokensActivationRequest { - fn tx_history(&self) -> bool { false } -} - -impl ActivationRequestInfo for SolanaWithTokensActivationRequest { - fn is_hw_policy(&self) -> bool { false } // TODO: fix when device policy is added -} - -#[derive(Debug, Serialize, Clone)] -pub struct SolanaWithTokensActivationResult { - current_block: u64, - solana_addresses_infos: HashMap>, - spl_addresses_infos: HashMap>, -} - -impl GetPlatformBalance for SolanaWithTokensActivationResult { - fn get_platform_balance(&self) -> Option { - self.solana_addresses_infos - .iter() - .fold(Some(BigDecimal::from(0)), |total, (_, addr_info)| { - total.and_then(|t| addr_info.balances.as_ref().map(|b| t + b.get_total())) - }) - } -} - -impl CurrentBlock for SolanaWithTokensActivationResult { - fn current_block(&self) -> u64 { self.current_block } -} - -#[derive(Debug, Clone)] -pub enum SolanaWithTokensActivationError { - PlatformCoinCreationError { ticker: String, error: String }, - UnableToRetrieveMyAddress(String), - GetBalanceError(BalanceError), - Transport(String), - Internal(String), -} - -impl From for SolanaWithTokensActivationError { - fn from(err: MyAddressError) -> Self { Self::UnableToRetrieveMyAddress(err.to_string()) } -} - -impl From for EnablePlatformCoinWithTokensError { - fn from(e: SolanaWithTokensActivationError) -> Self { - match e { - SolanaWithTokensActivationError::PlatformCoinCreationError { ticker, error } => { - EnablePlatformCoinWithTokensError::PlatformCoinCreationError { ticker, error } - }, - SolanaWithTokensActivationError::UnableToRetrieveMyAddress(e) => { - EnablePlatformCoinWithTokensError::Internal(e) - }, - SolanaWithTokensActivationError::GetBalanceError(e) => { - EnablePlatformCoinWithTokensError::Internal(format!("{:?}", e)) - }, - SolanaWithTokensActivationError::Transport(e) => EnablePlatformCoinWithTokensError::Transport(e), - SolanaWithTokensActivationError::Internal(e) => EnablePlatformCoinWithTokensError::Internal(e), - } - } -} - -impl From for SolanaWithTokensActivationError { - fn from(e: BalanceError) -> Self { SolanaWithTokensActivationError::GetBalanceError(e) } -} - -impl From for SolanaWithTokensActivationError { - fn from(e: CryptoCtxError) -> Self { SolanaWithTokensActivationError::Internal(e.to_string()) } -} - -pub struct SolanaProtocolInfo {} - -impl TryFromCoinProtocol for SolanaProtocolInfo { - fn try_from_coin_protocol(proto: CoinProtocol) -> Result> - where - Self: Sized, - { - match proto { - CoinProtocol::SOLANA {} => Ok(SolanaProtocolInfo {}), - protocol => MmError::err(protocol), - } - } -} - -impl From for InitTokensAsMmCoinsError { - fn from(err: SplTokenInitializerErr) -> Self { - match err.inner { - SplTokenCreationError::InvalidPubkey(error) => InitTokensAsMmCoinsError::TokenProtocolParseError { - ticker: err.ticker, - error, - }, - SplTokenCreationError::Internal(internal) => InitTokensAsMmCoinsError::Internal(internal), - } - } -} - -#[async_trait] -impl PlatformCoinWithTokensActivationOps for SolanaCoin { - type ActivationRequest = SolanaWithTokensActivationRequest; - type PlatformProtocolInfo = SolanaProtocolInfo; - type ActivationResult = SolanaWithTokensActivationResult; - type ActivationError = SolanaWithTokensActivationError; - - type InProgressStatus = InitPlatformCoinWithTokensInProgressStatus; - type AwaitingStatus = InitPlatformCoinWithTokensAwaitingStatus; - type UserAction = InitPlatformCoinWithTokensUserAction; - - async fn enable_platform_coin( - ctx: MmArc, - ticker: String, - platform_conf: &Json, - activation_request: Self::ActivationRequest, - _protocol_conf: Self::PlatformProtocolInfo, - ) -> Result> { - let priv_key_policy = PrivKeyBuildPolicy::detect_priv_key_policy(&ctx)?; - solana_coin_with_policy( - &ctx, - &ticker, - platform_conf, - activation_request.platform_request, - priv_key_policy, - ) - .await - .map_to_mm(|error| SolanaWithTokensActivationError::PlatformCoinCreationError { ticker, error }) - } - - async fn enable_global_nft( - &self, - _activation_request: &Self::ActivationRequest, - ) -> Result, MmError> { - Ok(None) - } - - fn try_from_mm_coin(coin: MmCoinEnum) -> Option - where - Self: Sized, - { - match coin { - MmCoinEnum::SolanaCoin(coin) => Some(coin), - _ => None, - } - } - - fn token_initializers( - &self, - ) -> Vec>> { - vec![Box::new(SplTokenInitializer { - platform_coin: self.clone(), - })] - } - - async fn get_activation_result( - &self, - _task_handle: Option>>, - activation_request: &Self::ActivationRequest, - _nft_global: &Option, - ) -> Result> { - let current_block = self - .current_block() - .compat() - .await - .map_to_mm(Self::ActivationError::Internal)?; - - let my_address = self.my_address()?; - - let mut solana_address_info = CoinAddressInfo { - derivation_method: DerivationMethodResponse::Iguana, - pubkey: my_address.clone(), - balances: None, - tickers: None, - }; - - let mut spl_address_info = CoinAddressInfo { - derivation_method: DerivationMethodResponse::Iguana, - pubkey: my_address.clone(), - balances: None, - tickers: None, - }; - - if !activation_request.get_balances { - drop_mutability!(solana_address_info); - let tickers = self.get_spl_tokens_infos().into_keys().collect(); - spl_address_info.tickers = Some(tickers); - drop_mutability!(spl_address_info); - - return Ok(SolanaWithTokensActivationResult { - current_block, - solana_addresses_infos: HashMap::from([(my_address.clone(), solana_address_info)]), - spl_addresses_infos: HashMap::from([(my_address, spl_address_info)]), - }); - } - - let solana_balance = self - .my_balance() - .compat() - .await - .map_err(|e| Self::ActivationError::GetBalanceError(e.into_inner()))?; - solana_address_info.balances = Some(solana_balance); - drop_mutability!(solana_address_info); - - let (token_tickers, requests): (Vec<_>, Vec<_>) = self - .get_spl_tokens_infos() - .into_iter() - .map(|(ticker, info)| (ticker, self.my_balance_spl(info))) - .unzip(); - spl_address_info.balances = Some(token_tickers.into_iter().zip(try_join_all(requests).await?).collect()); - drop_mutability!(spl_address_info); - - Ok(SolanaWithTokensActivationResult { - current_block, - solana_addresses_infos: HashMap::from([(my_address.clone(), solana_address_info)]), - spl_addresses_infos: HashMap::from([(my_address, spl_address_info)]), - }) - } - - fn start_history_background_fetching( - &self, - _ctx: MmArc, - _storage: impl TxHistoryStorage + Send + 'static, - _initial_balance: Option, - ) { - } - - async fn handle_balance_streaming( - &self, - _config: &EventStreamConfiguration, - ) -> Result<(), MmError> { - Ok(()) - } - - fn rpc_task_manager( - _activation_ctx: &CoinsActivationContext, - ) -> &InitPlatformCoinWithTokensTaskManagerShared { - unimplemented!() - } -} diff --git a/mm2src/coins_activation/src/spl_token_activation.rs b/mm2src/coins_activation/src/spl_token_activation.rs deleted file mode 100644 index 2bf40b6a89..0000000000 --- a/mm2src/coins_activation/src/spl_token_activation.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::prelude::{TryFromCoinProtocol, TryPlatformCoinFromMmCoinEnum}; -use crate::token::{EnableTokenError, TokenActivationOps, TokenProtocolParams}; -use async_trait::async_trait; -use coins::coin_errors::MyAddressError; -use coins::solana::spl::{SplProtocolConf, SplTokenCreationError}; -use coins::{BalanceError, CoinBalance, CoinProtocol, MarketCoinOps, MmCoinEnum, SolanaCoin, SplToken}; -use common::Future01CompatExt; -use mm2_err_handle::prelude::*; -use serde_derive::{Deserialize, Serialize}; -use std::collections::HashMap; - -impl TryPlatformCoinFromMmCoinEnum for SolanaCoin { - fn try_from_mm_coin(coin: MmCoinEnum) -> Option - where - Self: Sized, - { - match coin { - MmCoinEnum::SolanaCoin(coin) => Some(coin), - _ => None, - } - } -} - -#[derive(Clone, Debug, Deserialize)] -pub struct SplActivationRequest {} - -impl TryFromCoinProtocol for SplProtocolConf { - fn try_from_coin_protocol(proto: CoinProtocol) -> Result> - where - Self: Sized, - { - match proto { - CoinProtocol::SPLTOKEN { - platform, - token_contract_address, - decimals, - } => Ok(SplProtocolConf { - platform_coin_ticker: platform, - decimals, - token_contract_address, - }), - proto => MmError::err(proto), - } - } -} - -impl TokenProtocolParams for SplProtocolConf { - fn platform_coin_ticker(&self) -> &str { &self.platform_coin_ticker } -} - -#[derive(Debug, Serialize)] -pub struct SplInitResult { - balances: HashMap, - token_contract_address: String, - platform_coin: String, -} - -#[derive(Debug)] -#[allow(clippy::large_enum_variant)] -pub enum SplInitError { - GetBalanceError(BalanceError), - TokenCreationFailed(SplTokenCreationError), - MyAddressError(String), -} - -impl From for SplInitError { - fn from(err: MyAddressError) -> Self { Self::MyAddressError(err.to_string()) } -} - -impl From for SplInitError { - fn from(e: SplTokenCreationError) -> Self { SplInitError::TokenCreationFailed(e) } -} - -impl From for EnableTokenError { - fn from(err: SplInitError) -> Self { - match err { - SplInitError::GetBalanceError(rpc_err) => rpc_err.into(), - SplInitError::TokenCreationFailed(e) => EnableTokenError::Internal(format! {"{:?}", e}), - SplInitError::MyAddressError(e) => EnableTokenError::Internal(e), - } - } -} - -#[async_trait] -impl TokenActivationOps for SplToken { - type ActivationParams = SplActivationRequest; - type ProtocolInfo = SplProtocolConf; - type ActivationResult = SplInitResult; - type ActivationError = SplInitError; - - async fn enable_token( - ticker: String, - platform_coin: Self::PlatformCoin, - _activation_params: Self::ActivationParams, - protocol_conf: Self::ProtocolInfo, - ) -> Result<(Self, Self::ActivationResult), MmError> { - let token = Self::new( - protocol_conf.decimals, - ticker, - protocol_conf.token_contract_address, - platform_coin, - )?; - let balance = token - .my_balance() - .compat() - .await - .map_err(|e| SplInitError::GetBalanceError(e.into_inner()))?; - let my_address = token.my_address()?; - let balances = HashMap::from([(my_address, balance)]); - let init_result = SplInitResult { - balances, - token_contract_address: token.conf.token_contract_address.to_string(), - platform_coin: token.platform_coin.ticker().to_owned(), - }; - Ok((token, init_result)) - } -} diff --git a/mm2src/mm2_main/Cargo.toml b/mm2src/mm2_main/Cargo.toml index 07091e2631..5458c853be 100644 --- a/mm2src/mm2_main/Cargo.toml +++ b/mm2src/mm2_main/Cargo.toml @@ -18,8 +18,6 @@ native = [] # Deprecated track-ctx-pointer = ["common/track-ctx-pointer"] zhtlc-native-tests = ["coins/zhtlc-native-tests"] run-docker-tests = ["coins/run-docker-tests"] -# TODO -enable-solana = ["coins/enable-solana", "coins_activation/enable-solana"] default = [] trezor-udp = ["crypto/trezor-udp"] # use for tests to connect to trezor emulator over udp run-device-tests = [] diff --git a/mm2src/mm2_main/src/lp_ordermatch.rs b/mm2src/mm2_main/src/lp_ordermatch.rs index dc9b85082b..df1a35d946 100644 --- a/mm2src/mm2_main/src/lp_ordermatch.rs +++ b/mm2src/mm2_main/src/lp_ordermatch.rs @@ -5808,7 +5808,7 @@ pub enum OrderbookAddress { #[derive(Debug, Display)] enum OrderbookAddrErr { AddrFromPubkeyError(String), - #[cfg(any(all(feature = "enable-solana", not(target_arch = "wasm32")), feature = "enable-sia"))] + #[cfg(feature = "enable-sia")] CoinIsNotSupported(String), DeserializationError(json::Error), InvalidPlatformCoinProtocol(String), @@ -5882,10 +5882,6 @@ fn orderbook_address( ))), } }, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - CoinProtocol::SOLANA | CoinProtocol::SPLTOKEN { .. } => { - MmError::err(OrderbookAddrErr::CoinIsNotSupported(coin.to_owned())) - }, CoinProtocol::ZHTLC { .. } => Ok(OrderbookAddress::Shielded), #[cfg(not(target_arch = "wasm32"))] // Todo: Shielded address is used for lightning for now, the lightning node public key can be used for the orderbook entry pubkey diff --git a/mm2src/mm2_main/src/lp_swap.rs b/mm2src/mm2_main/src/lp_swap.rs index c7665da02e..295e847132 100644 --- a/mm2src/mm2_main/src/lp_swap.rs +++ b/mm2src/mm2_main/src/lp_swap.rs @@ -1665,12 +1665,8 @@ pub fn detect_secret_hash_algo(maker_coin: &MmCoinEnum, taker_coin: &MmCoinEnum) (MmCoinEnum::Tendermint(_) | MmCoinEnum::TendermintToken(_) | MmCoinEnum::LightningCoin(_), _) => { SecretHashAlgo::SHA256 }, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - (MmCoinEnum::SolanaCoin(_), _) => SecretHashAlgo::SHA256, // If taker is lightning coin the SHA256 of the secret will be sent as part of the maker signed invoice (_, MmCoinEnum::Tendermint(_) | MmCoinEnum::TendermintToken(_)) => SecretHashAlgo::SHA256, - #[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))] - (_, MmCoinEnum::SolanaCoin(_)) => SecretHashAlgo::SHA256, (_, _) => SecretHashAlgo::DHASH160, } } diff --git a/mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs b/mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs index 5a480a0a2e..ba99379892 100644 --- a/mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs +++ b/mm2src/mm2_main/src/rpc/dispatcher/dispatcher.rs @@ -39,13 +39,6 @@ use coins::z_coin::ZCoin; use coins::{add_delegation, get_my_address, get_raw_transaction, get_staking_infos, get_swap_transaction_fee_policy, nft, remove_delegation, set_swap_transaction_fee_policy, sign_message, sign_raw_transaction, verify_message, withdraw}; -#[cfg(all( - feature = "enable-solana", - not(target_os = "ios"), - not(target_os = "android"), - not(target_arch = "wasm32") -))] -use coins::{SolanaCoin, SplToken}; use coins_activation::{cancel_init_l2, cancel_init_platform_coin_with_tokens, cancel_init_standalone_coin, cancel_init_token, enable_platform_coin_with_tokens, enable_token, init_l2, init_l2_status, init_l2_user_action, init_platform_coin_with_tokens, init_platform_coin_with_tokens_status, @@ -224,17 +217,6 @@ async fn dispatcher_v2(request: MmRpcRequest, ctx: MmArc) -> DispatcherResult handle_mmrpc(ctx, request, set_swap_transaction_fee_policy).await, "send_asked_data" => handle_mmrpc(ctx, request, send_asked_data_rpc).await, "z_coin_tx_history" => handle_mmrpc(ctx, request, coins::my_tx_history_v2::z_coin_tx_history_rpc).await, - #[cfg(not(target_arch = "wasm32"))] - native_only_methods => match native_only_methods { - #[cfg(all(feature = "enable-solana", not(target_os = "ios"), not(target_os = "android")))] - "enable_solana_with_tokens" => { - handle_mmrpc(ctx, request, enable_platform_coin_with_tokens::).await - }, - #[cfg(all(feature = "enable-solana", not(target_os = "ios"), not(target_os = "android")))] - "enable_spl" => handle_mmrpc(ctx, request, enable_token::).await, - _ => MmError::err(DispatcherError::NoSuchMethod), - }, - #[cfg(target_arch = "wasm32")] _ => MmError::err(DispatcherError::NoSuchMethod), } } diff --git a/mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs b/mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs index 49150fab55..998cbc243a 100644 --- a/mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs +++ b/mm2src/mm2_main/tests/docker_tests/docker_tests_common.rs @@ -1068,29 +1068,6 @@ pub fn slp_supplied_node() -> MarketMakerIt { .unwrap() } -pub fn _solana_supplied_node() -> MarketMakerIt { - let coins = json! ([ - {"coin": "SOL-DEVNET","name": "solana","fname": "Solana","rpcport": 80,"mm2": 1,"required_confirmations": 1,"avg_blocktime": 0.25,"protocol": {"type": "SOLANA"}}, - {"coin":"USDC-SOL-DEVNET","protocol":{"type":"SPLTOKEN","protocol_data":{"decimals":6,"token_contract_address":"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU","platform":"SOL-DEVNET"}},"mm2": 1}, - {"coin":"ADEX-SOL-DEVNET","protocol":{"type":"SPLTOKEN","protocol_data":{"decimals":9,"token_contract_address":"5tSm6PqMosy1rz1AqV3kD28yYT5XqZW3QYmZommuFiPJ","platform":"SOL-DEVNET"}},"mm2": 1}, - ]); - - MarketMakerIt::start( - json! ({ - "gui": "nogui", - "netid": 9000, - "dht": "on", // Enable DHT without delay. - "passphrase": "federal stay trigger hour exist success game vapor become comfort action phone bright ill target wild nasty crumble dune close rare fabric hen iron", - "coins": coins, - "rpc_password": "pass", - "i_am_seed": true, - }), - "pass".to_string(), - None, - ) - .unwrap() -} - pub fn get_balance(mm: &MarketMakerIt, coin: &str) -> BalanceResponse { let rc = block_on(mm.rpc(&json!({ "userpass": mm.userpass, diff --git a/mm2src/mm2_main/tests/docker_tests/mod.rs b/mm2src/mm2_main/tests/docker_tests/mod.rs index 685f1bcad8..4b969b9fec 100644 --- a/mm2src/mm2_main/tests/docker_tests/mod.rs +++ b/mm2src/mm2_main/tests/docker_tests/mod.rs @@ -6,7 +6,6 @@ mod eth_docker_tests; pub mod qrc20_tests; #[cfg(feature = "enable-sia")] mod sia_docker_tests; mod slp_tests; -#[cfg(feature = "enable-solana")] mod solana_tests; mod swap_proto_v2_tests; mod swap_watcher_tests; mod swaps_confs_settings_sync_tests; diff --git a/mm2src/mm2_main/tests/docker_tests/solana_tests.rs b/mm2src/mm2_main/tests/docker_tests/solana_tests.rs deleted file mode 100644 index d1faa5d2a7..0000000000 --- a/mm2src/mm2_main/tests/docker_tests/solana_tests.rs +++ /dev/null @@ -1,144 +0,0 @@ -use crate::docker_tests::docker_tests_common::*; -use mm2_number::bigdecimal::Zero; -use mm2_test_helpers::for_tests::{disable_coin, enable_solana_with_tokens, enable_spl, sign_message, verify_message}; -use mm2_test_helpers::structs::{EnableSolanaWithTokensResponse, EnableSplResponse, RpcV2Response, SignatureResponse, - VerificationResponse}; -use serde_json as json; - -#[test] -fn test_solana_and_spl_balance_enable_spl_v2() { - let mm = _solana_supplied_node(); - let tx_history = false; - let enable_solana_with_tokens = block_on(enable_solana_with_tokens( - &mm, - "SOL-DEVNET", - &["USDC-SOL-DEVNET"], - "https://api.devnet.solana.com", - tx_history, - )); - let enable_solana_with_tokens: RpcV2Response = - json::from_value(enable_solana_with_tokens).unwrap(); - - let (_, solana_balance) = enable_solana_with_tokens - .result - .solana_addresses_infos - .into_iter() - .next() - .unwrap(); - assert!(solana_balance.balances.unwrap().spendable > 0.into()); - - let spl_balances = enable_solana_with_tokens - .result - .spl_addresses_infos - .into_iter() - .next() - .unwrap() - .1 - .balances - .unwrap(); - let usdc_spl = spl_balances.get("USDC-SOL-DEVNET").unwrap(); - assert!(usdc_spl.spendable.is_zero()); - - let enable_spl = block_on(enable_spl(&mm, "ADEX-SOL-DEVNET")); - let enable_spl: RpcV2Response = json::from_value(enable_spl).unwrap(); - assert_eq!(1, enable_spl.result.balances.len()); - - let (_, balance) = enable_spl.result.balances.into_iter().next().unwrap(); - assert!(balance.spendable > 0.into()); -} - -#[test] -fn test_sign_verify_message_solana() { - let mm = _solana_supplied_node(); - let tx_history = false; - block_on(enable_solana_with_tokens( - &mm, - "SOL-DEVNET", - &["USDC-SOL-DEVNET"], - "https://api.devnet.solana.com", - tx_history, - )); - - let response = block_on(sign_message(&mm, "SOL-DEVNET")); - let response: RpcV2Response = json::from_value(response).unwrap(); - let response = response.result; - - assert_eq!( - response.signature, - "3AoWCXHq3ACYHYEHUsCzPmRNiXn5c6kodXn9KDd1tz52e1da3dZKYXD5nrJW31XLtN6zzJiwHWtDta52w7Cd7qyE" - ); - - let response = block_on(verify_message( - &mm, - "SOL-DEVNET", - "3AoWCXHq3ACYHYEHUsCzPmRNiXn5c6kodXn9KDd1tz52e1da3dZKYXD5nrJW31XLtN6zzJiwHWtDta52w7Cd7qyE", - "FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf", - )); - let response: RpcV2Response = json::from_value(response).unwrap(); - let response = response.result; - - assert!(response.is_valid); -} - -#[test] -fn test_sign_verify_message_spl() { - let mm = _solana_supplied_node(); - let tx_history = false; - block_on(enable_solana_with_tokens( - &mm, - "SOL-DEVNET", - &["USDC-SOL-DEVNET"], - "https://api.devnet.solana.com", - tx_history, - )); - - block_on(enable_spl(&mm, "ADEX-SOL-DEVNET")); - - let response = block_on(sign_message(&mm, "ADEX-SOL-DEVNET")); - let response: RpcV2Response = json::from_value(response).unwrap(); - let response = response.result; - - assert_eq!( - response.signature, - "3AoWCXHq3ACYHYEHUsCzPmRNiXn5c6kodXn9KDd1tz52e1da3dZKYXD5nrJW31XLtN6zzJiwHWtDta52w7Cd7qyE" - ); - - let response = block_on(verify_message( - &mm, - "ADEX-SOL-DEVNET", - "3AoWCXHq3ACYHYEHUsCzPmRNiXn5c6kodXn9KDd1tz52e1da3dZKYXD5nrJW31XLtN6zzJiwHWtDta52w7Cd7qyE", - "FJktmyjV9aBHEShT4hfnLpr9ELywdwVtEL1w1rSWgbVf", - )); - let response: RpcV2Response = json::from_value(response).unwrap(); - let response = response.result; - - assert!(response.is_valid); -} - -#[test] -fn test_disable_solana_platform_coin_with_tokens() { - let mm = _solana_supplied_node(); - block_on(enable_solana_with_tokens( - &mm, - "SOL-DEVNET", - &["USDC-SOL-DEVNET"], - "https://api.devnet.solana.com", - false, - )); - block_on(enable_spl(&mm, "ADEX-SOL-DEVNET")); - - // Try to passive platform coin, SOL-DEVNET. - let res = block_on(disable_coin(&mm, "SOL-DEVNET", false)); - assert!(res.passivized); - - // Try to disable ADEX-SOL-DEVNET and USDC-SOL-DEVNET - // This should work, because platform coin is still in the memory. - let res = block_on(disable_coin(&mm, "ADEX-SOL-DEVNET", false)); - assert!(!res.passivized); - let res = block_on(disable_coin(&mm, "USDC-SOL-DEVNET", false)); - assert!(!res.passivized); - - // Then try to force disable SOL-DEVNET platform coin. - let res = block_on(disable_coin(&mm, "SOL-DEVNET", true)); - assert!(!res.passivized); -} diff --git a/mm2src/mm2_test_helpers/src/for_tests.rs b/mm2src/mm2_test_helpers/src/for_tests.rs index ffe7659a43..25ebef2df5 100644 --- a/mm2src/mm2_test_helpers/src/for_tests.rs +++ b/mm2src/mm2_test_helpers/src/for_tests.rs @@ -2029,21 +2029,6 @@ pub async fn enable_eth_coin( json::from_str(&enable.1).unwrap() } -pub async fn enable_spl(mm: &MarketMakerIt, coin: &str) -> Json { - let req = json!({ - "userpass": mm.userpass, - "method": "enable_spl", - "mmrpc": "2.0", - "params": { - "ticker": coin, - "activation_params": {} - } - }); - let enable = mm.rpc(&req).await.unwrap(); - assert_eq!(enable.0, StatusCode::OK, "'enable_spl' failed: {}", enable.1); - json::from_str(&enable.1).unwrap() -} - pub async fn enable_slp(mm: &MarketMakerIt, coin: &str) -> Json { let enable = mm .rpc(&json!({ @@ -2141,38 +2126,6 @@ pub async fn enable_bch_with_tokens( json::from_str(&enable.1).unwrap() } -pub async fn enable_solana_with_tokens( - mm: &MarketMakerIt, - platform_coin: &str, - tokens: &[&str], - solana_client_url: &str, - tx_history: bool, -) -> Json { - let spl_requests: Vec<_> = tokens.iter().map(|ticker| json!({ "ticker": ticker })).collect(); - let req = json!({ - "userpass": mm.userpass, - "method": "enable_solana_with_tokens", - "mmrpc": "2.0", - "params": { - "ticker": platform_coin, - "confirmation_commitment": "finalized", - "allow_slp_unsafe_conf": true, - "client_url": solana_client_url, - "tx_history": tx_history, - "spl_tokens_requests": spl_requests, - } - }); - - let enable = mm.rpc(&req).await.unwrap(); - assert_eq!( - enable.0, - StatusCode::OK, - "'enable_bch_with_tokens' failed: {}", - enable.1 - ); - json::from_str(&enable.1).unwrap() -} - pub async fn my_tx_history_v2( mm: &MarketMakerIt, coin: &str, diff --git a/mm2src/mm2_test_helpers/src/structs.rs b/mm2src/mm2_test_helpers/src/structs.rs index 8bdcfec722..2dd72a8435 100644 --- a/mm2src/mm2_test_helpers/src/structs.rs +++ b/mm2src/mm2_test_helpers/src/structs.rs @@ -919,14 +919,6 @@ pub struct EnableBchWithTokensResponse { pub slp_addresses_infos: HashMap>, } -#[derive(Debug, Deserialize)] -#[serde(deny_unknown_fields)] -pub struct EnableSolanaWithTokensResponse { - pub current_block: u64, - pub solana_addresses_infos: HashMap>, - pub spl_addresses_infos: HashMap>, -} - #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct HistoryTransactionDetails { From 4e8bc50a7d0657cf37d68601bde2e76d280032ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Thu, 10 Oct 2024 21:24:51 +0300 Subject: [PATCH 2/2] fix(cosmos): fix tx broadcasting error (#2238) This commit upgrades cosmrs to version 15 along with other required dependency upgrades to fix the broadcast_tx_commit failure. --- Cargo.lock | 162 ++++++++---------- mm2src/coins/Cargo.toml | 14 +- mm2src/coins/tendermint/htlc/iris/htlc.rs | 15 +- mm2src/coins/tendermint/htlc/nucleus/htlc.rs | 15 +- mm2src/coins/tendermint/ibc/mod.rs | 1 - mm2src/coins/tendermint/ibc/transfer_v1.rs | 8 +- mm2src/coins/tendermint/tendermint_coin.rs | 8 +- mm2src/coins/utxo/pb.rs | 1 + mm2src/mm2_main/Cargo.toml | 4 +- .../src/lp_swap/komodefi.swap_v2.pb.rs | 1 + mm2src/mm2_net/Cargo.toml | 4 +- mm2src/trezor/Cargo.toml | 2 +- mm2src/trezor/src/error.rs | 4 +- mm2src/trezor/src/response.rs | 9 +- mm2src/trezor/src/transport/protocol.rs | 9 +- mm2src/trezor/src/utxo/sign_utxo.rs | 6 +- 16 files changed, 131 insertions(+), 132 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf62d3f115..99227202a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -928,7 +928,7 @@ dependencies = [ "tower-service", "url", "utxo_signer", - "uuid 1.2.2", + "uuid", "wagyu-zcash-parameters", "wasm-bindgen", "wasm-bindgen-futures", @@ -1026,7 +1026,7 @@ dependencies = [ "sha2 0.10.7", "shared_ref_counter", "tokio", - "uuid 1.2.2", + "uuid", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", @@ -1101,9 +1101,9 @@ dependencies = [ [[package]] name = "cosmos-sdk-proto" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73c9d2043a9e617b0d602fbc0a0ecd621568edbf3a9774890a6d562389bd8e1c" +checksum = "32560304ab4c365791fd307282f76637213d8083c1a98490c35159cd67852237" dependencies = [ "prost", "prost-types", @@ -1112,18 +1112,18 @@ dependencies = [ [[package]] name = "cosmrs" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af13955d6f356272e6def9ff5e2450a7650df536d8934f47052a20c76513d2f6" +checksum = "47126f5364df9387b9d8559dcef62e99010e1d4098f39eb3f7ee4b5c254e40ea" dependencies = [ "cosmos-sdk-proto", "ecdsa", "eyre", - "getrandom 0.2.9", "k256", "rand_core 0.6.4", "serde", "serde_json", + "signature 2.2.0", "subtle-encoding", "tendermint", "thiserror", @@ -1586,7 +1586,7 @@ dependencies = [ "rusqlite", "sql-builder", "tokio", - "uuid 1.2.2", + "uuid", ] [[package]] @@ -2066,11 +2066,10 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ - "matches", "percent-encoding", ] @@ -2764,6 +2763,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "if-addrs" version = "0.7.0" @@ -3005,9 +3014,7 @@ dependencies = [ "cfg-if 1.0.0", "ecdsa", "elliptic-curve", - "once_cell", "sha2 0.10.7", - "signature 2.2.0", ] [[package]] @@ -3883,7 +3890,7 @@ dependencies = [ "serde_json", "shared_ref_counter", "tokio", - "uuid 1.2.2", + "uuid", "wasm-bindgen-test", ] @@ -4101,7 +4108,7 @@ dependencies = [ "trie-db", "trie-root 0.16.0", "url", - "uuid 1.2.2", + "uuid", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", @@ -4257,7 +4264,7 @@ dependencies = [ "ser_error_derive", "serde", "serde_json", - "uuid 1.2.2", + "uuid", ] [[package]] @@ -4295,7 +4302,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "uuid 1.2.2", + "uuid", ] [[package]] @@ -4727,9 +4734,9 @@ checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] name = "peg" -version = "0.7.0" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" +checksum = "295283b02df346d1ef66052a757869b2876ac29a6bb0ac3f5f7cd44aebe40e8f" dependencies = [ "peg-macros", "peg-runtime", @@ -4737,9 +4744,9 @@ dependencies = [ [[package]] name = "peg-macros" -version = "0.7.0" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" +checksum = "bdad6a1d9cf116a059582ce415d5f5566aabcd4008646779dab7fdc2a9a9d426" dependencies = [ "peg-runtime", "proc-macro2", @@ -4748,9 +4755,9 @@ dependencies = [ [[package]] name = "peg-runtime" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" +checksum = "e3aeb8f54c078314c2065ee649a7241f46b9d8e418e1a9581ba0546657d7aa3a" [[package]] name = "pem" @@ -4763,9 +4770,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" @@ -4890,12 +4897,12 @@ checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" [[package]] name = "prettyplease" -version = "0.1.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28f53e8b192565862cf99343194579a022eb9c7dd3a8d03134734803c7b3125" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 1.0.95", + "syn 2.0.38", ] [[package]] @@ -4977,9 +4984,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes 1.4.0", "prost-derive", @@ -4987,44 +4994,43 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes 1.4.0", "heck", "itertools", - "lazy_static", "log", "multimap", + "once_cell", "petgraph", "prettyplease", "prost", "prost-types", "regex", - "syn 1.0.95", + "syn 2.0.38", "tempfile", - "which", ] [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools", "proc-macro2", "quote 1.0.33", - "syn 1.0.95", + "syn 2.0.38", ] [[package]] name = "prost-types" -version = "0.11.9" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -6753,9 +6759,9 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.32.2" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0a7d05cf78524782337f8edd55cbc578d159a16ad4affe2135c92f7dbac7f0" +checksum = "15ab8f0a25d0d2ad49ac615da054d6a76aa6603ff95f7d18bafdd34450a1a04b" dependencies = [ "bytes 1.4.0", "digest 0.10.7", @@ -6784,9 +6790,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.32.2" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a72dbbea6dde12045d261f2c70c0de039125675e8a026c8d5ad34522756372" +checksum = "e1a02da769166e2052cd537b1a97c78017632c2d9e19266367b27e73910434fc" dependencies = [ "flex-error", "serde", @@ -6798,9 +6804,9 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.32.2" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cec054567d16d85e8c3f6a3139963d1a66d9d3051ed545d31562550e9bcc3d" +checksum = "b797dd3d2beaaee91d2f065e7bdf239dc8d80bba4a183a288bc1279dd5a69a1e" dependencies = [ "bytes 1.4.0", "flex-error", @@ -6816,9 +6822,9 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.32.2" +version = "0.34.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d83a130537fc4a98c3c9eb6899ebe857fea4860400a61675bfb5f0b35129" +checksum = "71afae8bb5f6b14ed48d4e1316a643b6c2c3cbad114f510be77b4ed20b7b3e42" dependencies = [ "async-trait", "bytes 1.4.0", @@ -6826,6 +6832,7 @@ dependencies = [ "getrandom 0.2.9", "peg", "pin-project", + "rand 0.8.4", "semver 1.0.6", "serde", "serde_bytes", @@ -6838,7 +6845,7 @@ dependencies = [ "thiserror", "time 0.3.20", "url", - "uuid 0.8.2", + "uuid", "walkdir", ] @@ -7105,9 +7112,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.9.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ "async-stream", "async-trait", @@ -7115,8 +7122,6 @@ dependencies = [ "base64 0.21.7", "bytes 1.4.0", "flate2", - "futures-core", - "futures-util", "h2", "http 0.2.12", "http-body 0.4.5", @@ -7125,6 +7130,7 @@ dependencies = [ "percent-encoding", "pin-project", "prost", + "rustls 0.21.10", "rustls-pemfile 1.0.2", "tokio", "tokio-rustls 0.24.1", @@ -7133,20 +7139,20 @@ dependencies = [ "tower-layer", "tower-service", "tracing", - "webpki-roots 0.23.1", + "webpki-roots 0.25.4", ] [[package]] name = "tonic-build" -version = "0.9.2" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" dependencies = [ "prettyplease", "proc-macro2", "prost-build", "quote 1.0.33", - "syn 1.0.95", + "syn 2.0.38", ] [[package]] @@ -7285,7 +7291,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna", + "idna 0.2.3", "ipnet", "lazy_static", "rand 0.8.4", @@ -7370,12 +7376,9 @@ source = "git+https://github.com/KomodoPlatform/mm2-parity-ethereum.git?rev=mm2- [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -7385,9 +7388,9 @@ checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -7444,13 +7447,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.2.2" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna", - "matches", + "idna 0.5.0", "percent-encoding", "serde", ] @@ -7481,15 +7483,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" - -[[package]] -name = "uuid" -version = "1.2.2" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom 0.2.9", "rand 0.8.4", @@ -7725,7 +7721,7 @@ dependencies = [ "getrandom 0.2.9", "headers", "hex", - "idna", + "idna 0.2.3", "js-sys", "jsonrpc-core", "log", @@ -7786,16 +7782,6 @@ dependencies = [ "cc", ] -[[package]] -name = "which" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe" -dependencies = [ - "either", - "libc", -] - [[package]] name = "widestring" version = "0.5.1" diff --git a/mm2src/coins/Cargo.toml b/mm2src/coins/Cargo.toml index 62c0e24ea0..8fa02034c1 100644 --- a/mm2src/coins/Cargo.toml +++ b/mm2src/coins/Cargo.toml @@ -33,7 +33,7 @@ cfg-if = "1.0" chain = { path = "../mm2_bitcoin/chain" } chrono = { version = "0.4.23", "features" = ["serde"] } common = { path = "../common" } -cosmrs = { version = "0.14.0", default-features = false } +cosmrs = { version = "0.15", default-features = false } crossbeam = "0.8" crypto = { path = "../crypto" } db_common = { path = "../db_common" } @@ -75,7 +75,7 @@ mocktopus = "0.8.0" num-traits = "0.2" parking_lot = { version = "0.12.0", features = ["nightly"] } primitives = { path = "../mm2_bitcoin/primitives" } -prost = "0.11" +prost = "0.12" protobuf = "2.20" proxy_signature = { path = "../proxy_signature" } rand = { version = "0.7", features = ["std", "small_rng"] } @@ -101,7 +101,7 @@ sha2 = "0.10" sha3 = "0.9" utxo_signer = { path = "utxo_signer" } # using the same version as cosmrs -tendermint-rpc = { version = "0.32.0", default-features = false } +tendermint-rpc = { version = "0.34", default-features = false } tokio-tungstenite-wasm = { git = "https://github.com/KomodoPlatform/tokio-tungstenite-wasm", rev = "d20abdb", features = ["rustls-tls-native-roots"]} url = { version = "2.2.2", features = ["serde"] } uuid = { version = "1.2.2", features = ["fast-rng", "serde", "v4"] } @@ -124,7 +124,7 @@ mm2_db = { path = "../mm2_db" } mm2_metamask = { path = "../mm2_metamask" } mm2_test_helpers = { path = "../mm2_test_helpers" } time = { version = "0.3.20", features = ["wasm-bindgen"] } -tonic = { version = "0.9", default-features = false, features = ["prost", "codegen", "gzip"] } +tonic = { version = "0.10", default-features = false, features = ["prost", "codegen", "gzip"] } tower-service = "0.3" wasm-bindgen = "0.2.86" wasm-bindgen-futures = { version = "0.4.1" } @@ -149,7 +149,7 @@ rustls = { version = "0.21", features = ["dangerous_configuration"] } secp256k1v24 = { version = "0.24", package = "secp256k1" } tokio = { version = "1.20" } tokio-rustls = { version = "0.24" } -tonic = { version = "0.9", features = ["tls", "tls-webpki-roots", "gzip"] } +tonic = { version = "0.10", features = ["tls", "tls-webpki-roots", "gzip"] } webpki-roots = { version = "0.25" } zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.4.1" } zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.4.1", default-features = false, features = ["local-prover", "multicore"] } @@ -164,5 +164,5 @@ mm2_test_helpers = { path = "../mm2_test_helpers" } wagyu-zcash-parameters = { version = "0.2" } [build-dependencies] -prost-build = { version = "0.11", default-features = false } -tonic-build = { version = "0.9", default-features = false, features = ["prost"] } +prost-build = { version = "0.12", default-features = false } +tonic-build = { version = "0.10", default-features = false, features = ["prost"] } diff --git a/mm2src/coins/tendermint/htlc/iris/htlc.rs b/mm2src/coins/tendermint/htlc/iris/htlc.rs index 09561a4048..59cfb5cd73 100644 --- a/mm2src/coins/tendermint/htlc/iris/htlc.rs +++ b/mm2src/coins/tendermint/htlc/iris/htlc.rs @@ -1,12 +1,9 @@ use super::htlc_proto::{IrisClaimHtlcProto, IrisCreateHtlcProto}; -use cosmrs::proto::traits::TypeUrl; +use cosmrs::proto::traits::Name; use cosmrs::{tx::Msg, AccountId, Coin, ErrorReport}; use std::convert::TryFrom; -pub(crate) const IRIS_CREATE_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgCreateHTLC"; -pub(crate) const IRIS_CLAIM_HTLC_TYPE_URL: &str = "/irismod.htlc.MsgClaimHTLC"; - #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct IrisCreateHtlcMsg { /// Sender's address. @@ -87,8 +84,9 @@ impl From<&IrisCreateHtlcMsg> for IrisCreateHtlcProto { } } -impl TypeUrl for IrisCreateHtlcProto { - const TYPE_URL: &'static str = IRIS_CREATE_HTLC_TYPE_URL; +impl Name for IrisCreateHtlcProto { + const NAME: &'static str = "MsgCreateHTLC"; + const PACKAGE: &'static str = "irismod.htlc"; } #[derive(Clone)] @@ -141,6 +139,7 @@ impl From<&IrisClaimHtlcMsg> for IrisClaimHtlcProto { } } -impl TypeUrl for IrisClaimHtlcProto { - const TYPE_URL: &'static str = IRIS_CLAIM_HTLC_TYPE_URL; +impl Name for IrisClaimHtlcProto { + const NAME: &'static str = "MsgClaimHTLC"; + const PACKAGE: &'static str = "irismod.htlc"; } diff --git a/mm2src/coins/tendermint/htlc/nucleus/htlc.rs b/mm2src/coins/tendermint/htlc/nucleus/htlc.rs index a768f7fd4a..2c423285bf 100644 --- a/mm2src/coins/tendermint/htlc/nucleus/htlc.rs +++ b/mm2src/coins/tendermint/htlc/nucleus/htlc.rs @@ -1,12 +1,9 @@ use super::htlc_proto::{NucleusClaimHtlcProto, NucleusCreateHtlcProto}; -use cosmrs::proto::traits::TypeUrl; +use cosmrs::proto::traits::Name; use cosmrs::{tx::Msg, AccountId, Coin, ErrorReport}; use std::convert::TryFrom; -pub(crate) const NUCLEUS_CREATE_HTLC_TYPE_URL: &str = "/nucleus.htlc.MsgCreateHTLC"; -pub(crate) const NUCLEUS_CLAIM_HTLC_TYPE_URL: &str = "/nucleus.htlc.MsgClaimHTLC"; - #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct NucleusCreateHtlcMsg { /// Sender's address. @@ -72,8 +69,9 @@ impl From<&NucleusCreateHtlcMsg> for NucleusCreateHtlcProto { } } -impl TypeUrl for NucleusCreateHtlcProto { - const TYPE_URL: &'static str = NUCLEUS_CREATE_HTLC_TYPE_URL; +impl Name for NucleusCreateHtlcProto { + const NAME: &'static str = "MsgCreateHTLC"; + const PACKAGE: &'static str = "nucleus.htlc"; } #[derive(Clone)] @@ -126,6 +124,7 @@ impl From<&NucleusClaimHtlcMsg> for NucleusClaimHtlcProto { } } -impl TypeUrl for NucleusClaimHtlcProto { - const TYPE_URL: &'static str = NUCLEUS_CLAIM_HTLC_TYPE_URL; +impl Name for NucleusClaimHtlcProto { + const NAME: &'static str = "MsgClaimHTLC"; + const PACKAGE: &'static str = "nucleus.htlc"; } diff --git a/mm2src/coins/tendermint/ibc/mod.rs b/mm2src/coins/tendermint/ibc/mod.rs index 51df375ab1..9e1c905398 100644 --- a/mm2src/coins/tendermint/ibc/mod.rs +++ b/mm2src/coins/tendermint/ibc/mod.rs @@ -1,7 +1,6 @@ mod ibc_proto; pub(crate) mod transfer_v1; -pub(crate) const IBC_TRANSFER_TYPE_URL: &str = "/ibc.applications.transfer.v1.MsgTransfer"; pub(crate) const IBC_OUT_SOURCE_PORT: &str = "transfer"; pub(crate) const IBC_OUT_TIMEOUT_IN_NANOS: u64 = 60000000000 * 15; // 15 minutes pub(crate) const IBC_GAS_LIMIT_DEFAULT: u64 = 150_000; diff --git a/mm2src/coins/tendermint/ibc/transfer_v1.rs b/mm2src/coins/tendermint/ibc/transfer_v1.rs index c5780e32b7..22bad1fefe 100644 --- a/mm2src/coins/tendermint/ibc/transfer_v1.rs +++ b/mm2src/coins/tendermint/ibc/transfer_v1.rs @@ -1,6 +1,5 @@ use super::{ibc_proto::IBCTransferV1Proto, IBC_OUT_SOURCE_PORT, IBC_OUT_TIMEOUT_IN_NANOS}; -use crate::tendermint::ibc::IBC_TRANSFER_TYPE_URL; -use cosmrs::proto::traits::TypeUrl; +use cosmrs::proto::traits::Name; use cosmrs::{tx::Msg, AccountId, Coin, ErrorReport}; use std::convert::TryFrom; @@ -99,6 +98,7 @@ impl From<&MsgTransfer> for IBCTransferV1Proto { } } -impl TypeUrl for IBCTransferV1Proto { - const TYPE_URL: &'static str = IBC_TRANSFER_TYPE_URL; +impl Name for IBCTransferV1Proto { + const NAME: &'static str = "MsgTransfer"; + const PACKAGE: &'static str = "ibc.applications.transfer.v1"; } diff --git a/mm2src/coins/tendermint/tendermint_coin.rs b/mm2src/coins/tendermint/tendermint_coin.rs index 9c7a1c1d96..de1753cffe 100644 --- a/mm2src/coins/tendermint/tendermint_coin.rs +++ b/mm2src/coins/tendermint/tendermint_coin.rs @@ -2531,13 +2531,13 @@ impl MarketCoinOps for TendermintCoin { let broadcast_res = try_s!(try_s!(coin.rpc_client().await).broadcast_tx_commit(tx_bytes).await); if broadcast_res.check_tx.log.contains(ACCOUNT_SEQUENCE_ERR) - || broadcast_res.deliver_tx.log.contains(ACCOUNT_SEQUENCE_ERR) + || broadcast_res.tx_result.log.contains(ACCOUNT_SEQUENCE_ERR) { return ERR!( "{}. check_tx log: {}, deliver_tx log: {}", ACCOUNT_SEQUENCE_ERR, broadcast_res.check_tx.log, - broadcast_res.deliver_tx.log + broadcast_res.tx_result.log ); } @@ -2545,8 +2545,8 @@ impl MarketCoinOps for TendermintCoin { return ERR!("Tx check failed {:?}", broadcast_res.check_tx); } - if !broadcast_res.deliver_tx.code.is_ok() { - return ERR!("Tx deliver failed {:?}", broadcast_res.deliver_tx); + if !broadcast_res.tx_result.code.is_ok() { + return ERR!("Tx deliver failed {:?}", broadcast_res.tx_result); } Ok(broadcast_res.hash.to_string()) }; diff --git a/mm2src/coins/utxo/pb.rs b/mm2src/coins/utxo/pb.rs index 3ae572bc23..a9fb741a11 100644 --- a/mm2src/coins/utxo/pb.rs +++ b/mm2src/coins/utxo/pb.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct GetMempoolInfoRequest {} diff --git a/mm2src/mm2_main/Cargo.toml b/mm2src/mm2_main/Cargo.toml index 5458c853be..259d3fc934 100644 --- a/mm2src/mm2_main/Cargo.toml +++ b/mm2src/mm2_main/Cargo.toml @@ -73,7 +73,7 @@ num-traits = "0.2" parity-util-mem = "0.11" parking_lot = { version = "0.12.0", features = ["nightly"] } primitives = { path = "../mm2_bitcoin/primitives" } -prost = "0.11" +prost = "0.12" rand = { version = "0.7", features = ["std", "small_rng"] } rand6 = { version = "0.6", package = "rand" } rmp-serde = "0.14.3" @@ -134,5 +134,5 @@ url = { version = "2.2.2", features = ["serde"] } [build-dependencies] chrono = "0.4" gstuff = { version = "0.7", features = ["nightly"] } -prost-build = { version = "0.11", default-features = false } +prost-build = { version = "0.12", default-features = false } regex = "1" diff --git a/mm2src/mm2_main/src/lp_swap/komodefi.swap_v2.pb.rs b/mm2src/mm2_main/src/lp_swap/komodefi.swap_v2.pb.rs index 130fb2e3e1..38c6e07106 100644 --- a/mm2src/mm2_main/src/lp_swap/komodefi.swap_v2.pb.rs +++ b/mm2src/mm2_main/src/lp_swap/komodefi.swap_v2.pb.rs @@ -1,3 +1,4 @@ +// This file is @generated by prost-build. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct SignedMessage { diff --git a/mm2src/mm2_net/Cargo.toml b/mm2src/mm2_net/Cargo.toml index d92e0c08b6..3962bf1136 100644 --- a/mm2src/mm2_net/Cargo.toml +++ b/mm2src/mm2_net/Cargo.toml @@ -27,7 +27,7 @@ mm2_err_handle = { path = "../mm2_err_handle" } mm2_event_stream = { path = "../mm2_event_stream", optional = true } mm2-libp2p = { path = "../mm2_p2p", package = "mm2_p2p", optional = true } parking_lot = { version = "0.12.0", features = ["nightly"], optional = true } -prost = "0.11" +prost = "0.12" rand = { version = "0.7", features = ["std", "small_rng", "wasm-bindgen"] } serde = "1" serde_json = { version = "1", features = ["preserve_order", "raw_value"] } @@ -41,7 +41,7 @@ http-body = "0.4" httparse = "1.8.0" js-sys = "0.3.27" pin-project = "1.1.2" -tonic = { version = "0.9", default-features = false, features = ["prost", "codegen"] } +tonic = { version = "0.10", default-features = false, features = ["prost", "codegen"] } tower-service = "0.3" wasm-bindgen = "0.2.86" wasm-bindgen-test = { version = "0.3.2" } diff --git a/mm2src/trezor/Cargo.toml b/mm2src/trezor/Cargo.toml index 5f0542d35a..36e5abb0ec 100644 --- a/mm2src/trezor/Cargo.toml +++ b/mm2src/trezor/Cargo.toml @@ -14,7 +14,7 @@ derive_more = "0.99" futures = { version = "0.3", package = "futures", features = ["compat", "async-await"] } hw_common = { path = "../hw_common" } mm2_err_handle = { path = "../mm2_err_handle" } -prost = "0.11" +prost = "0.12" rand = { version = "0.7", features = ["std", "wasm-bindgen"] } rpc_task = { path = "../rpc_task" } serde = "1.0" diff --git a/mm2src/trezor/src/error.rs b/mm2src/trezor/src/error.rs index 798185695c..6a67c592f2 100644 --- a/mm2src/trezor/src/error.rs +++ b/mm2src/trezor/src/error.rs @@ -1,3 +1,5 @@ +use std::convert::TryFrom; + use crate::proto::messages::MessageType; use crate::proto::messages_common::{failure::FailureType, Failure}; use crate::user_interaction::TrezorUserInteraction; @@ -57,7 +59,7 @@ pub enum OperationFailure { impl From for OperationFailure { fn from(failure: Failure) -> Self { - match failure.code.and_then(FailureType::from_i32) { + match failure.code.and_then(|t| FailureType::try_from(t).ok()) { Some(FailureType::FailurePinInvalid) | Some(FailureType::FailurePinMismatch) => { OperationFailure::InvalidPin }, diff --git a/mm2src/trezor/src/response.rs b/mm2src/trezor/src/response.rs index 869b910997..259db41840 100644 --- a/mm2src/trezor/src/response.rs +++ b/mm2src/trezor/src/response.rs @@ -6,6 +6,7 @@ use crate::{TrezorError, TrezorResult}; use async_trait::async_trait; use mm2_err_handle::prelude::*; use rpc_task::RpcTaskError; +use std::convert::TryFrom; use std::fmt; use std::sync::Arc; @@ -150,7 +151,10 @@ impl<'a, 'b, T> fmt::Debug for ButtonRequest<'a, 'b, T> { impl<'a, 'b, T: 'static> ButtonRequest<'a, 'b, T> { /// The type of button request. - pub fn request_type(&self) -> Option { self.message.code.and_then(ButtonRequestType::from_i32) } + #[inline(always)] + pub fn request_type(&self) -> Option { + self.message.code.and_then(|t| ButtonRequestType::try_from(t).ok()) + } /// Ack the request and get the next message from the device. pub async fn ack(self) -> TrezorResult> { @@ -174,8 +178,9 @@ impl<'a, 'b, T> fmt::Debug for PinMatrixRequest<'a, 'b, T> { impl<'a, 'b, T: 'static> PinMatrixRequest<'a, 'b, T> { /// The type of PIN matrix request. + #[inline(always)] pub fn request_type(&self) -> Option { - self.message.r#type.and_then(PinMatrixRequestType::from_i32) + self.message.r#type.and_then(|t| PinMatrixRequestType::try_from(t).ok()) } /// Ack the request with a PIN and get the next message from the device. diff --git a/mm2src/trezor/src/transport/protocol.rs b/mm2src/trezor/src/transport/protocol.rs index 6c553e5d76..e6c822eb3c 100644 --- a/mm2src/trezor/src/transport/protocol.rs +++ b/mm2src/trezor/src/transport/protocol.rs @@ -1,5 +1,7 @@ //! This file is inspired by https://github.com/tezedge/tezedge-client/blob/master/trezor_api/src/transport/protocol.rs +use std::convert::TryFrom; + use crate::proto::messages::MessageType; use crate::proto::ProtoMessage; use crate::{TrezorError, TrezorResult}; @@ -85,9 +87,10 @@ impl Protocol for ProtocolV1 { ); return MmError::err(TrezorError::ProtocolError(error)); } - let message_type_id = BigEndian::read_u16(&chunk[3..5]) as u32; - let message_type = MessageType::from_i32(message_type_id as i32) - .or_mm_err(|| TrezorError::ProtocolError(format!("Invalid message type: {}", message_type_id)))?; + let message_type_id = BigEndian::read_u16(&chunk[3..5]) as i32; + let message_type = MessageType::try_from(message_type_id).map_err(|e| { + TrezorError::ProtocolError(format!("Invalid message type: {}, Error: {}", message_type_id, e)) + })?; let data_length = BigEndian::read_u32(&chunk[5..9]) as usize; let mut data: Vec = chunk[9..].into(); diff --git a/mm2src/trezor/src/utxo/sign_utxo.rs b/mm2src/trezor/src/utxo/sign_utxo.rs index 8b56f4fbd4..7f53182639 100644 --- a/mm2src/trezor/src/utxo/sign_utxo.rs +++ b/mm2src/trezor/src/utxo/sign_utxo.rs @@ -1,3 +1,5 @@ +use std::convert::TryFrom; + use crate::proto::messages_bitcoin as proto_bitcoin; use crate::result_handler::ResultHandler; use crate::utxo::unsigned_tx::UnsignedUtxoTx; @@ -61,7 +63,9 @@ impl<'a> TrezorSession<'a> { loop { extract_serialized_data(&tx_request, &mut result)?; - let request_type = tx_request.request_type.and_then(ProtoTxRequestType::from_i32); + let request_type = tx_request + .request_type + .and_then(|t| ProtoTxRequestType::try_from(t).ok()); let request_type = match request_type { Some(ProtoTxRequestType::Txfinished) => return Ok(result), Some(req_type) => req_type,