From cbeb750951b91f228c5fefeed3d53f8a94f32483 Mon Sep 17 00:00:00 2001 From: dzung pham Date: Wed, 20 Nov 2024 17:00:51 +0700 Subject: [PATCH 01/32] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e0889ee..c22f35e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ ## User settings xcuserdata/ +.idea ## Obj-C/Swift specific *.hmap From 6c6374eea9f766a96f99bedecf206150d8baaf66 Mon Sep 17 00:00:00 2001 From: dzung pham Date: Wed, 20 Nov 2024 17:29:32 +0700 Subject: [PATCH 02/32] wip --- rust/Cargo.lock | 2087 +++++++++++++++++++++++++++---- rust/Cargo.toml | 15 +- rust/a.json | 25 + rust/a.sjon | 25 + rust/src/asset.rs | 34 + rust/src/bip39.rs | 7 - rust/src/bytes.rs | 18 + rust/src/lib.rs | 81 +- rust/src/minswap_provider.rs | 25 + rust/src/minwallet.rs | 247 +--- rust/src/minwallet_backup.rs | 290 +++++ rust/src/public_key_hash.rs | 12 + rust/src/translucent_helpers.rs | 15 + rust/src/tx_in.rs | 49 + rust/src/tx_out.rs | 51 + rust/src/utxo.rs | 20 + rust/src/value.rs | 66 + rust/src/wallet/embedded.rs | 75 ++ rust/src/wallet/emip3.rs | 65 + rust/src/wallet/maestro.rs | 235 ++++ rust/src/wallet/mod.rs | 4 + rust/src/wallet/provider.rs | 58 + 22 files changed, 3028 insertions(+), 476 deletions(-) create mode 100644 rust/a.json create mode 100644 rust/a.sjon create mode 100644 rust/src/asset.rs delete mode 100644 rust/src/bip39.rs create mode 100644 rust/src/bytes.rs create mode 100644 rust/src/minswap_provider.rs create mode 100644 rust/src/minwallet_backup.rs create mode 100644 rust/src/public_key_hash.rs create mode 100644 rust/src/translucent_helpers.rs create mode 100644 rust/src/tx_in.rs create mode 100644 rust/src/tx_out.rs create mode 100644 rust/src/utxo.rs create mode 100644 rust/src/value.rs create mode 100644 rust/src/wallet/embedded.rs create mode 100644 rust/src/wallet/emip3.rs create mode 100644 rust/src/wallet/maestro.rs create mode 100644 rust/src/wallet/mod.rs create mode 100644 rust/src/wallet/provider.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d55d737..83a1f2b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2,11 +2,64 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -19,43 +72,49 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" + +[[package]] +name = "arrayvec" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "askama" @@ -80,7 +139,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.87", ] [[package]] @@ -100,9 +159,30 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" @@ -135,29 +215,28 @@ dependencies = [ ] [[package]] -name = "bip39" -version = "2.0.0" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" -dependencies = [ - "bitcoin_hashes", - "rand", - "rand_core 0.6.4", - "serde", - "unicode-normalization", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "bitcoin_hashes" -version = "0.11.0" +name = "bitflags" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] -name = "bitflags" -version = "1.3.2" +name = "bitvec" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] [[package]] name = "block-buffer" @@ -168,12 +247,66 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "borsh" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" +dependencies = [ + "borsh-derive", + "cfg_aliases", +] + +[[package]] +name = "borsh-derive" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" +dependencies = [ + "once_cell", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytecheck" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" +dependencies = [ + "bytecheck_derive", + "ptr_meta", + "simdutf8", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -182,47 +315,50 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "camino" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] [[package]] name = "cardano-serialization-lib" -version = "11.5.0" +version = "13.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3fab2c10aa73dae6ea90ed459ef07ed7acb09270ea90d9a37fa00420b9c25c" +checksum = "44ab8700b9a4bc42f48a06f9555ea28c7cb958a3cb470de5727b8e0d76c2a702" dependencies = [ "bech32", "cbor_event", "cfg-if", "clear_on_drop", "cryptoxide", - "digest", + "digest 0.9.0", "ed25519-bip32", "getrandom", + "hashlink", "hex", "itertools", "js-sys", - "linked-hash-map", "noop_proc_macro", + "num", "num-bigint", + "num-derive", "num-integer", + "num-traits", "rand", "rand_os", "schemars", "serde", "serde-wasm-bindgen", "serde_json", - "sha2", + "sha2 0.9.9", "wasm-bindgen", ] @@ -257,9 +393,12 @@ checksum = "089a0261d1bc59e54e8e11860031efd88593f0e61b921172c474f1f38c2f2d3c" [[package]] name = "cc" -version = "1.1.7" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -267,11 +406,32 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.6", +] + [[package]] name = "clap" -version = "4.5.13" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -279,9 +439,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -291,21 +451,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "clear_on_drop" @@ -322,24 +482,50 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "cryptoxide" version = "0.4.4" @@ -355,6 +541,28 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "dyn-clone" version = "1.0.17" @@ -376,6 +584,67 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-err" version = "2.11.0" @@ -391,6 +660,60 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -414,6 +737,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + [[package]] name = "glob" version = "0.3.1" @@ -432,67 +761,418 @@ dependencies = [ ] [[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hex" -version = "0.4.3" +name = "h2" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] [[package]] -name = "is_terminal_polyfill" -version = "1.70.1" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] -name = "itertools" -version = "0.10.5" +name = "hashbrown" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "either", + "ahash 0.8.11", ] [[package]] -name = "itoa" -version = "1.0.11" +name = "hashbrown" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] -name = "js-sys" -version = "0.3.64" +name = "hashlink" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "wasm-bindgen", + "hashbrown 0.14.5", ] [[package]] -name = "libc" -version = "0.2.155" +name = "heck" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "hermit-abi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] -name = "log" -version = "0.4.22" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "memchr" +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.1", +] + +[[package]] +name = "ipnet" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "maestro-rust-sdk" +version = "1.2.5" +source = "git+ssh://git@github.com/maestro-org/rust-sdk.git#55b8d161e3efe15a93ffbb8898caeaa45cb37a19" +dependencies = [ + "chrono", + "reqwest", + "rust_decimal", + "serde", + "serde_json", + "serde_qs", +] + +[[package]] +name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" @@ -519,79 +1199,290 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "mwrust" version = "0.1.0" dependencies = [ - "base64", - "bip39", + "base64 0.22.1", "cardano-serialization-lib", + "cryptoxide", "hex", + "lazy_static", + "maestro-rust-sdk", "rand", + "reqwest", + "serde", + "serde_json", + "tiny-bip39", + "tokio", "uniffi", ] [[package]] -name = "nom" -version = "7.1.3" +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ - "memchr", - "minimal-lexical", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] -name = "noop_proc_macro" -version = "0.3.0" +name = "parking_lot" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] [[package]] -name = "num-bigint" -version = "0.4.6" +name = "parking_lot_core" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "num-integer", - "num-traits", + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", ] [[package]] -name = "num-integer" -version = "0.1.46" +name = "paste" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] -name = "num-traits" -version = "0.2.19" +name = "pbkdf2" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ - "autocfg", + "digest 0.10.7", + "hmac", ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "percent-encoding" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "opaque-debug" -version = "0.3.1" +name = "pin-project-lite" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] -name = "paste" -version = "1.0.15" +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plain" @@ -608,24 +1499,59 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -695,12 +1621,158 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "rend" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "reqwest" +version = "0.11.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +dependencies = [ + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rkyv" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" +dependencies = [ + "bitvec", + "bytecheck", + "bytes", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", + "tinyvec", + "uuid", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "rust_decimal" +version = "1.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" +dependencies = [ + "arrayvec", + "borsh", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "schemars" version = "0.8.21" @@ -722,9 +1794,15 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 2.0.87", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "scroll" version = "0.12.0" @@ -742,7 +1820,36 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] @@ -756,9 +1863,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -776,13 +1883,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] @@ -793,14 +1900,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -808,25 +1915,95 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_qs" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0431a35568651e363364210c91983c1da5eb29404d9f0928b67d4ebcfa7d330c" +dependencies = [ + "percent-encoding", + "serde", + "thiserror", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha2" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + [[package]] name = "smawk" version = "0.3.2" @@ -834,26 +2011,116 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] -name = "static_assertions" -version = "1.1.0" +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.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.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] -name = "strsim" -version = "0.11.1" +name = "tap" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "syn" -version = "2.0.72" +name = "tempfile" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -867,22 +2134,49 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "tiny-bip39" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a30fd743a02bf35236f6faf99adb03089bb77e91c998dac2c2ad76bb424f668c" +dependencies = [ + "once_cell", + "pbkdf2", + "rand", + "rustc-hash", + "sha2 0.10.8", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", ] [[package]] @@ -900,6 +2194,58 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tokio" +version = "1.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.11" @@ -909,6 +2255,54 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -917,36 +2311,34 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicase" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "uniffi" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31bff6daf87277a9014bcdefbc2842b0553392919d1096843c5aad899ca4588" +checksum = "4cb08c58c7ed7033150132febe696bef553f891b1ede57424b40d87a89e3c170" dependencies = [ "anyhow", "camino", + "cargo_metadata", "clap", "uniffi_bindgen", "uniffi_build", @@ -956,9 +2348,9 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96061d7e01b185aa405f7c9b134741ab3e50cc6796a47d6fd8ab9a5364b5feed" +checksum = "cade167af943e189a55020eda2c314681e223f1e42aca7c4e52614c2b627698f" dependencies = [ "anyhow", "askama", @@ -974,15 +2366,14 @@ dependencies = [ "textwrap", "toml", "uniffi_meta", - "uniffi_testing", "uniffi_udl", ] [[package]] name = "uniffi_build" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6b86f9b221046af0c533eafe09ece04e2f1ded04ccdc9bba0ec09aec1c52bd" +checksum = "4c7cf32576e08104b7dc2a6a5d815f37616e66c6866c2a639fe16e6d2286b75b" dependencies = [ "anyhow", "camino", @@ -991,23 +2382,22 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fcfa22f55829d3aaa7acfb1c5150224188fe0f27c59a8a3eddcaa24d1ffbe58" +checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a" dependencies = [ "quote", - "syn", + "syn 2.0.87", ] [[package]] name = "uniffi_core" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3210d57d6ab6065ab47a2898dacdb7c606fd6a4156196831fa3bf82e34ac58a6" +checksum = "bc7687007d2546c454d8ae609b105daceb88175477dac280707ad6d95bcd6f1f" dependencies = [ "anyhow", "bytes", - "camino", "log", "once_cell", "paste", @@ -1016,9 +2406,9 @@ dependencies = [ [[package]] name = "uniffi_macros" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58691741080935437dc862122e68d7414432a11824ac1137868de46181a0bd2" +checksum = "12c65a5b12ec544ef136693af8759fb9d11aefce740fb76916721e876639033b" dependencies = [ "bincode", "camino", @@ -1027,16 +2417,16 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.87", "toml", "uniffi_meta", ] [[package]] name = "uniffi_meta" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7663eacdbd9fbf4a88907ddcfe2e6fa85838eb6dc2418a7d91eebb3786f8e20b" +checksum = "4a74ed96c26882dac1ca9b93ca23c827e284bacbd7ec23c6f0b0372f747d59e4" dependencies = [ "anyhow", "bytes", @@ -1046,9 +2436,9 @@ dependencies = [ [[package]] name = "uniffi_testing" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f922465f7566f25f8fe766920205fdfa9a3fcdc209c6bfb7557f0b5bf45b04dd" +checksum = "6a6f984f0781f892cc864a62c3a5c60361b1ccbd68e538e6c9fbced5d82268ac" dependencies = [ "anyhow", "camino", @@ -1059,9 +2449,9 @@ dependencies = [ [[package]] name = "uniffi_udl" -version = "0.28.0" +version = "0.28.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef408229a3a407fafa4c36dc4f6ece78a6fb258ab28d2b64bddd49c8cb680f6" +checksum = "037820a4cfc4422db1eaa82f291a3863c92c7d1789dc513489c36223f9b4cdfc" dependencies = [ "anyhow", "textwrap", @@ -1070,18 +2460,62 @@ dependencies = [ "weedle2", ] +[[package]] +name = "url" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1090,9 +2524,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1100,24 +2534,36 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.87", "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1125,22 +2571,32 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] [[package]] name = "weedle2" @@ -1173,13 +2629,55 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1188,28 +2686,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1222,30 +2738,118 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -1264,5 +2868,68 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index c290018..632248c 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -5,14 +5,21 @@ edition = "2021" [dependencies] base64 = "0.22.1" -bip39 = { version = "2.0.0", features = ["rand"] } -cardano-serialization-lib = "11.5.0" +tiny-bip39 = "2.0.0" +cardano-serialization-lib = "13.2.0" hex = "0.4.3" +lazy_static = "1.5.0" rand = "0.8.5" -uniffi = { version = "0.28.0", features = ["cli"] } +reqwest = { version = "0.11.27", features = ["json", "blocking"] } +serde = { version = "1.0.213", features = ["derive"] } +serde_json = "1.0.132" +uniffi = { version = "0.28.2", features = ["cli"] } +cryptoxide = "0.4.4" +maestro-rust-sdk = { git = "ssh://git@github.com/maestro-org/rust-sdk.git" } +tokio = { version = "1.41.1", features = ["full"] } [build-dependencies] -uniffi = { version = "0.28.0", features = ["build"] } +uniffi = { version = "0.28.2", features = ["build"] } [lib] crate-type = ["cdylib", "staticlib"] diff --git a/rust/a.json b/rust/a.json new file mode 100644 index 0000000..8354dcc --- /dev/null +++ b/rust/a.json @@ -0,0 +1,25 @@ +{ + "data": [ + { + "tx_hash": "3b9242c898a7c1fa81547b47d5bc6f5e2c6b161a3fd389b1d8db4ecee86ac0c5", + "index": 0, + "slot": 76412221, + "assets": [ + { + "unit": "lovelace", + "amount": 10000000 + } + ], + "address": "addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt", + "datum": null, + "reference_script": null, + "txout_cbor": "82583900a79de6b2aec3119a422218e9f52cd880e73ec0b9bf47f7d1e68543ea8262d5e844dcc7e5e06b6b034a099c776b22475eef4300313d3a821c1a00989680" + } + ], + "last_updated": { + "timestamp": "2024-11-20 09:39:48", + "block_hash": "e1d2b1c16ae7c8552187dfdfe6707b4daa78eeaf5cf7f5ad7bc6b70f7879fdda", + "block_slot": 76412388 + }, + "next_cursor": null +} diff --git a/rust/a.sjon b/rust/a.sjon new file mode 100644 index 0000000..8354dcc --- /dev/null +++ b/rust/a.sjon @@ -0,0 +1,25 @@ +{ + "data": [ + { + "tx_hash": "3b9242c898a7c1fa81547b47d5bc6f5e2c6b161a3fd389b1d8db4ecee86ac0c5", + "index": 0, + "slot": 76412221, + "assets": [ + { + "unit": "lovelace", + "amount": 10000000 + } + ], + "address": "addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt", + "datum": null, + "reference_script": null, + "txout_cbor": "82583900a79de6b2aec3119a422218e9f52cd880e73ec0b9bf47f7d1e68543ea8262d5e844dcc7e5e06b6b034a099c776b22475eef4300313d3a821c1a00989680" + } + ], + "last_updated": { + "timestamp": "2024-11-20 09:39:48", + "block_hash": "e1d2b1c16ae7c8552187dfdfe6707b4daa78eeaf5cf7f5ad7bc6b70f7879fdda", + "block_slot": 76412388 + }, + "next_cursor": null +} diff --git a/rust/src/asset.rs b/rust/src/asset.rs new file mode 100644 index 0000000..951dfef --- /dev/null +++ b/rust/src/asset.rs @@ -0,0 +1,34 @@ +use lazy_static::lazy_static; + +use crate::bytes::Bytes; + +#[derive(Clone, PartialEq)] +pub struct Asset { + pub currency_symbol: Bytes, + pub token_name: Bytes, +} + +impl Asset { + pub fn new(currency_symbol: &Bytes, token_name: &Bytes) -> Self { + Self { + currency_symbol: currency_symbol.clone(), + token_name: token_name.clone(), + } + } + + pub fn to_string(&self) -> String { + if *self == *ADA { + return "lovelace".to_string(); + } + + if self.token_name.hex == "" { + return self.currency_symbol.hex.clone(); + } + + return format!("{}.{}", self.currency_symbol.hex, self.token_name.hex); + } +} + +lazy_static! { + pub static ref ADA: Asset = Asset::new(&Bytes::from_hex(""), &Bytes::from_hex("")); +} diff --git a/rust/src/bip39.rs b/rust/src/bip39.rs deleted file mode 100644 index f331d0a..0000000 --- a/rust/src/bip39.rs +++ /dev/null @@ -1,7 +0,0 @@ -use bip39::{Language, Mnemonic}; - -pub fn generate_mnemonic() -> String { - let mut rng = bip39::rand::thread_rng(); - let m = Mnemonic::generate_in_with(&mut rng, Language::English, 24); - m.unwrap().to_string() -} diff --git a/rust/src/bytes.rs b/rust/src/bytes.rs new file mode 100644 index 0000000..1d9f405 --- /dev/null +++ b/rust/src/bytes.rs @@ -0,0 +1,18 @@ +#[derive(Clone, PartialEq)] +pub struct Bytes { + pub bytes: Vec, + pub hex: String, +} + +impl Bytes { + pub fn new(bytes: &[u8]) -> Self { + Self { + bytes: bytes.to_vec(), + hex: hex::encode(bytes), + } + } + + pub fn from_hex(hex: &str) -> Self { + Self::new(&hex::decode(hex).unwrap()) + } +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index b4fe76e..8fc153a 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,17 +1,27 @@ -use crate::bip39::generate_mnemonic; use crate::network::{NetworkEnvironment, NetworkId}; use crate::utils::harden; +use cardano_serialization_lib::Bip32PrivateKey; use cardano_serialization_lib::{ - address::{BaseAddress, EnterpriseAddress, RewardAddress, StakeCredential}, - crypto::{self, PrivateKey, Vkeywitnesses}, - utils::{hash_transaction, make_vkey_witness}, + BaseAddress, EnterpriseAddress, RewardAddress,Credential, + PrivateKey, Vkeywitnesses, + make_vkey_witness, Transaction, TransactionWitnessSet, }; -pub mod bip39; -pub mod minwallet; +pub mod wallet; +mod asset; +mod bytes; +mod minswap_provider; pub mod network; +pub mod public_key_hash; +mod translucent_helpers; +mod tx_in; +mod tx_out; pub mod utils; +mod utxo; +mod value; + +pub mod minwallet; pub enum AddressType { BaseAddress, @@ -39,8 +49,7 @@ pub fn create_wallet( network_environment: NetworkEnvironment, ) -> WalletType { let network_id = NetworkId::from_network_environment(&network_environment) as u8; - let root_key = - crypto::Bip32PrivateKey::from_bip39_entropy(mnemonic.as_bytes(), password.as_bytes()); + let root_key = Bip32PrivateKey::from_bip39_entropy(mnemonic.as_bytes(), password.as_bytes()); let account_key = root_key .derive(harden(1852)) @@ -58,15 +67,15 @@ pub fn create_wallet( let address = BaseAddress::new( network_id, - &StakeCredential::from_keyhash(&payment_key_hash), - &StakeCredential::from_keyhash(&stake_key_hash), + &Credential::from_keyhash(&payment_key_hash), + &Credential::from_keyhash(&stake_key_hash), ) - .to_address() - .to_bech32(None) - .unwrap(); + .to_address() + .to_bech32(None) + .unwrap(); let reward_address = - RewardAddress::new(network_id, &StakeCredential::from_keyhash(&stake_key_hash)) + RewardAddress::new(network_id, &Credential::from_keyhash(&stake_key_hash)) .to_address() .to_bech32(None) .unwrap(); @@ -81,11 +90,11 @@ pub fn create_wallet( AddressType::EnterpriseAddress => { let address = EnterpriseAddress::new( network_id, - &StakeCredential::from_keyhash(&payment_key_hash), + &Credential::from_keyhash(&payment_key_hash), ) - .to_address() - .to_bech32(None) - .unwrap(); + .to_address() + .to_bech32(None) + .unwrap(); WalletType::EnterpriseWallet { address, @@ -95,22 +104,24 @@ pub fn create_wallet( } } -pub fn sign_tx(tx_raw: &str, keys: Vec) -> String { - let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); - let tx_body = tx.body(); - let tx_hash = hash_transaction(&tx_body); - - let mut witness_set = TransactionWitnessSet::new(); - let mut vkey_witnesses = Vkeywitnesses::new(); - - for key in keys { - let pkey = PrivateKey::from_bech32(&key).unwrap(); - let vkey = make_vkey_witness(&tx_hash, &pkey); - vkey_witnesses.add(&vkey); - } - - witness_set.set_vkeys(&vkey_witnesses); - witness_set.to_hex() -} +// pub fn sign_tx(tx_raw: &str, keys: Vec) -> String { +// let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); +// let tx_body = tx.body(); +// let tx_hash = hash_transaction(&tx_body); +// +// let mut witness_set = TransactionWitnessSet::new(); +// let mut vkey_witnesses = Vkeywitnesses::new(); +// +// for key in keys { +// let pkey = PrivateKey::from_bech32(&key).unwrap(); +// let vkey = make_vkey_witness(&tx_hash, &pkey); +// vkey_witnesses.add(&vkey); +// } +// +// witness_set.set_vkeys(&vkey_witnesses); +// let signed_tx = witness_set.to_hex(); +// +// "".to_owned() +// } uniffi::include_scaffolding!("mwrust"); diff --git a/rust/src/minswap_provider.rs b/rust/src/minswap_provider.rs new file mode 100644 index 0000000..97e4848 --- /dev/null +++ b/rust/src/minswap_provider.rs @@ -0,0 +1,25 @@ +use crate::translucent_helpers::TOutRef; + +struct WalletEndpoints { + utxo_by_tx_in: &'static str, +} + +const WALLET_ENDPOINTS: WalletEndpoints = WalletEndpoints { + utxo_by_tx_in: "/wallet/utxo/tx-in", +}; + +struct MinswapProvider { + url: String, +} + +impl MinswapProvider { + fn make_post_call(&self, path: &str, body: &str) -> String { + let client = reqwest::blocking::Client::new(); + let res = client + .post(format!("{}/{}", self.url, path)) + .body(body.to_string()) + .send() + .unwrap(); + res.text().unwrap() + } +} diff --git a/rust/src/minwallet.rs b/rust/src/minwallet.rs index 1ea0cc1..c290bc3 100644 --- a/rust/src/minwallet.rs +++ b/rust/src/minwallet.rs @@ -1,251 +1,58 @@ -use std::collections::HashMap; - -use base64::prelude::*; -use bip39::Mnemonic; -use cardano_serialization_lib::{ - address::{BaseAddress, NetworkInfo, RewardAddress, StakeCredential}, - crypto::{Bip32PrivateKey, Bip32PublicKey}, - emip3::{decrypt_with_password, encrypt_with_password}, -}; -use rand::RngCore; - -use crate::network::{NetworkEnvironment, NetworkId}; -use crate::utils::harden; +use crate::network::NetworkEnvironment; +use crate::wallet::embedded::WalletStaticMethods; +use crate::wallet::emip3::encrypt_password; +use cardano_serialization_lib::{Address, RewardAddress}; const MINWALLET_VERSION: &str = "2.0.0"; -#[derive(Debug)] -enum TransportType { - WEBUSB, - WEBHID, - WEBBLE, - BLE, -} - -impl TransportType { - pub fn to_string(&self) -> String { - match self { - TransportType::WEBUSB => "WebUSB".to_string(), - TransportType::WEBHID => "WebHID".to_string(), - TransportType::WEBBLE => "WebBluetooth".to_string(), - TransportType::BLE => "Bluetooth".to_string(), - } - } -} - -#[derive(Debug)] pub struct Minwallet { name: String, - base_address: HashMap, - reward_address: HashMap, - pub_key_hash_derive_map: HashMap>, + address: Address, + reward_address: RewardAddress, network_id: u8, encrypted_key: String, version: String, - account_index: u8, + account_index: u32, wallet_name: String, - transport_type: Option, } +impl WalletStaticMethods for Minwallet {} + impl Minwallet { - pub fn new( + pub fn create( mnemonic: &str, password: &str, network_environment: NetworkEnvironment, wallet_name: &str, ) -> Self { - let entropy = Mnemonic::parse(mnemonic).unwrap().to_entropy(); - let root_key = Bip32PrivateKey::from_bip39_entropy(&entropy, &[]); + let account_index = 0; + + // Convert mnemonic to entropy + let entropy = Minwallet::mnemonic_to_entropy(&mnemonic); + + // Derive root key and account key + let root_key = Minwallet::entropy_to_root_key(&entropy, &password); + let account_key = Minwallet::get_account(&root_key, account_index); + + // Encrypt root key with password let encrypted_key = encrypt_password(password, &root_key.to_hex()); - let account_key = root_key - .derive(harden(1852)) - .derive(harden(1815)) - .derive(harden(0)); - let public_key = account_key.to_public(); + + // Derive network ID let network_id = network_environment.to_network_id() as u8; - let base_address = generate_base_address(&public_key); - let reward_address = generate_reward_address(&public_key); - let pub_key_hash_derive_map = generate_addresses(&public_key); + // Generate addresses + let address = Minwallet::get_address(&account_key, network_id); + let reward_address = Minwallet::gen_reward_address(&account_key, network_id); Minwallet { name: "minwallet".to_string(), - base_address, + address, reward_address, network_id, - account_index: 0, - transport_type: None, + account_index, encrypted_key, - pub_key_hash_derive_map, version: MINWALLET_VERSION.to_string(), wallet_name: wallet_name.to_string(), } } - - pub fn sign(&self, raw_tx: &str) {} -} - -fn generate_addresses(public_key: &Bip32PublicKey) -> HashMap> { - let mut pub_key_hash_derive_map = HashMap::new(); - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - pub_key_hash_derive_map.insert(stake_key_hash.to_hex(), vec![2, 0]); - - for i in 0..1000 { - let receving_pub_key_hash = public_key - .derive(0) - .unwrap() - .derive(i) - .unwrap() - .to_raw_key() - .hash(); - let change_pub_key_hash = public_key - .derive(1) - .unwrap() - .derive(i) - .unwrap() - .to_raw_key() - .hash(); - - pub_key_hash_derive_map.insert(receving_pub_key_hash.to_hex(), vec![0, i]); - pub_key_hash_derive_map.insert(change_pub_key_hash.to_hex(), vec![1, i]); - } - - pub_key_hash_derive_map -} - -fn generate_reward_address(public_key: &Bip32PublicKey) -> HashMap { - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let mut reward_address = HashMap::new(); - - reward_address.insert( - NetworkId::Mainnet as u8, - RewardAddress::new( - NetworkInfo::mainnet().network_id(), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - reward_address.insert( - NetworkId::Testnet as u8, - RewardAddress::new( - NetworkInfo::testnet_preprod().network_id(), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - reward_address -} - -fn generate_base_address(public_key: &Bip32PublicKey) -> HashMap { - let payment_key_hash = public_key - .derive(0) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let mut base_address = HashMap::new(); - - base_address.insert( - NetworkId::Mainnet as u8, - BaseAddress::new( - NetworkInfo::mainnet().network_id(), - &StakeCredential::from_keyhash(&payment_key_hash), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - base_address.insert( - NetworkId::Testnet as u8, - BaseAddress::new( - NetworkInfo::testnet_preprod().network_id(), - &StakeCredential::from_keyhash(&payment_key_hash), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - base_address -} - -fn generate_secure_string(length: usize) -> String { - let mut bytes = vec![0u8; length]; - rand::thread_rng().fill_bytes(&mut bytes); - - // Use base64 for a compact and URL-safe representation - let mut encoded = BASE64_STANDARD.encode(bytes); - encoded.truncate(length); - encoded -} - -fn encrypt_password(password: &str, root_key_hex: &str) -> String { - let password_hex = hex::encode(password); - let salt = hex::encode(generate_secure_string(32)); - let nonce = hex::encode(generate_secure_string(12)); - encrypt_with_password(&password_hex, &salt, &nonce, root_key_hex).unwrap() -} - -fn decrypt_password(password: &str, encrypted_hex: &str) -> String { - let password_hex = hex::encode(password); - decrypt_with_password(&password_hex, encrypted_hex).unwrap() -} - -#[cfg(test)] -mod tests { - use super::{decrypt_password, encrypt_password, generate_secure_string, Minwallet}; - use crate::bip39::generate_mnemonic; - use crate::network::NetworkEnvironment; - - #[test] - fn can_generate_secure_string_with_length() { - let result = generate_secure_string(64); - assert_eq!(result.bytes().len(), 64); - } - - #[test] - fn can_encrypt_and_decrypt_password() { - let password = "MyPassword@@"; - let data = "aqu23oi45ufdgsaiklojug8oasdff"; - let data_hex = hex::encode(data); - let encrypted_hex = encrypt_password(&password, &data_hex); - let decrypted_hex = decrypt_password(&password, &encrypted_hex); - assert_eq!(decrypted_hex, data_hex); - } - - #[test] - fn can_create_new_minwallet() { - let mnemonic = generate_mnemonic(); - let password = "MyPassword@@"; - let network_environment = NetworkEnvironment::TestnetPreprod; - let wallet_name = "W01"; - let wallet = Minwallet::new(&mnemonic, password, network_environment, wallet_name); - println!("{:#?}", wallet); - assert_eq!(1, 1); - } } diff --git a/rust/src/minwallet_backup.rs b/rust/src/minwallet_backup.rs new file mode 100644 index 0000000..4d1ad9f --- /dev/null +++ b/rust/src/minwallet_backup.rs @@ -0,0 +1,290 @@ +use std::collections::{HashMap, HashSet}; +use base64::prelude::*; +use bip39::Mnemonic; +use cardano_serialization_lib::{address::{BaseAddress, NetworkInfo, RewardAddress, StakeCredential}, crypto::{Bip32PrivateKey, Bip32PublicKey}, emip3::{decrypt_with_password, encrypt_with_password}, Transaction, utils}; +use rand::RngCore; + +use crate::{network::{NetworkEnvironment, NetworkId}, tx_in::TxIn}; +use crate::utils::harden; +use crate::public_key_hash::PublicKeyHash; + +const MINWALLET_VERSION: &str = "2.0.0"; + +#[derive(Debug)] +enum TransportType { + WEBUSB, + WEBHID, + WEBBLE, + BLE, +} + +impl TransportType { + pub fn to_string(&self) -> String { + match self { + TransportType::WEBUSB => "WebUSB".to_string(), + TransportType::WEBHID => "WebHID".to_string(), + TransportType::WEBBLE => "WebBluetooth".to_string(), + TransportType::BLE => "Bluetooth".to_string(), + } + } +} + +#[derive(Debug)] +pub struct Minwallet { + name: String, + base_address: HashMap, + reward_address: HashMap, + pub_key_hash_derive_map: HashMap>, + network_id: u8, + encrypted_key: String, + version: String, + account_index: u8, + wallet_name: String, + transport_type: Option, +} + +impl Minwallet { + pub fn new( + mnemonic: &str, + password: &str, + network_environment: NetworkEnvironment, + wallet_name: &str, + ) -> Self { + let entropy = Mnemonic::parse(mnemonic).unwrap().to_entropy(); + let root_key = Bip32PrivateKey::from_bip39_entropy(&entropy, &[]); + let encrypted_key = encrypt_password(password, &root_key.to_hex()); + let account_key = root_key + .derive(harden(1852)) + .derive(harden(1815)) + .derive(harden(0)); + let public_key = account_key.to_public(); + let network_id = network_environment.to_network_id() as u8; + + let base_address = generate_base_address(&public_key); + let reward_address = generate_reward_address(&public_key); + let pub_key_hash_derive_map = generate_addresses(&public_key); + + Minwallet { + name: "minwallet".to_string(), + base_address, + reward_address, + network_id, + account_index: 0, + transport_type: None, + encrypted_key, + pub_key_hash_derive_map, + version: MINWALLET_VERSION.to_string(), + wallet_name: wallet_name.to_string(), + } + } + + pub fn sign_tx(&self, raw_tx: &str) {} + + fn get_transaction_from_raw(&self, raw_tx: &str) { + let tx = Transaction::from_hex(raw_tx).unwrap(); + let tx_body = tx.body(); + let tx_hash = utils::hash_transaction(&tx_body); + let tx_id = tx_hash.to_hex(); + let tx_size = tx.to_bytes().len(); + let fee = tx_body.fee(); + + let witness_set = tx.witness_set(); + let vkey_witnesses = witness_set.vkeys(); + let mut signed_pub_key_hashes = HashSet::new(); + + if let Some(vkey_witnesses) = vkey_witnesses { + for i in 0..vkey_witnesses.len() { + let vkey_witness = vkey_witnesses.get(i); + let key = vkey_witness.vkey(); + let pub_key = key.public_key(); + let pub_key_hash = pub_key.hash(); + signed_pub_key_hashes.insert(pub_key_hash.to_hex()); + } + } + + let tx_ins = TxIn::get_inputs_from_tx_raw(raw_tx); + let tx_collateral_ins = match TxIn::get_collateral_from_tx_raw(raw_tx) { + Some(data) => data, + None => vec![] + }; + let mut public_key_hashes = HashSet::new(); + + for tx_in in tx_ins { + + } + + + //missing_signatures -> keyHash + let missing_signatures = vec![]; + for signature in signed_pub_key_hashes { + let pkh = PublicKeyHash::new(signature); + if !signed_pub_key_hashes + } + } +} + + +fn generate_addresses(public_key: &Bip32PublicKey) -> HashMap> { + let mut pub_key_hash_derive_map = HashMap::new(); + let stake_key_hash = public_key + .derive(2) + .unwrap() + .derive(0) + .unwrap() + .to_raw_key() + .hash(); + pub_key_hash_derive_map.insert(stake_key_hash.to_hex(), vec![2, 0]); + + for i in 0..1000 { + let receving_pub_key_hash = public_key + .derive(0) + .unwrap() + .derive(i) + .unwrap() + .to_raw_key() + .hash(); + let change_pub_key_hash = public_key + .derive(1) + .unwrap() + .derive(i) + .unwrap() + .to_raw_key() + .hash(); + + pub_key_hash_derive_map.insert(receving_pub_key_hash.to_hex(), vec![0, i]); + pub_key_hash_derive_map.insert(change_pub_key_hash.to_hex(), vec![1, i]); + } + + pub_key_hash_derive_map +} + +fn generate_reward_address(public_key: &Bip32PublicKey) -> HashMap { + let stake_key_hash = public_key + .derive(2) + .unwrap() + .derive(0) + .unwrap() + .to_raw_key() + .hash(); + let mut reward_address = HashMap::new(); + + reward_address.insert( + NetworkId::Mainnet as u8, + RewardAddress::new( + NetworkInfo::mainnet().network_id(), + &StakeCredential::from_keyhash(&stake_key_hash), + ) + .to_address() + .to_hex(), + ); + + reward_address.insert( + NetworkId::Testnet as u8, + RewardAddress::new( + NetworkInfo::testnet_preprod().network_id(), + &StakeCredential::from_keyhash(&stake_key_hash), + ) + .to_address() + .to_hex(), + ); + + reward_address +} + +fn generate_base_address(public_key: &Bip32PublicKey) -> HashMap { + let payment_key_hash = public_key + .derive(0) + .unwrap() + .derive(0) + .unwrap() + .to_raw_key() + .hash(); + let stake_key_hash = public_key + .derive(2) + .unwrap() + .derive(0) + .unwrap() + .to_raw_key() + .hash(); + let mut base_address = HashMap::new(); + + base_address.insert( + NetworkId::Mainnet as u8, + BaseAddress::new( + NetworkInfo::mainnet().network_id(), + &StakeCredential::from_keyhash(&payment_key_hash), + &StakeCredential::from_keyhash(&stake_key_hash), + ) + .to_address() + .to_hex(), + ); + + base_address.insert( + NetworkId::Testnet as u8, + BaseAddress::new( + NetworkInfo::testnet_preprod().network_id(), + &StakeCredential::from_keyhash(&payment_key_hash), + &StakeCredential::from_keyhash(&stake_key_hash), + ) + .to_address() + .to_hex(), + ); + + base_address +} + +fn generate_secure_string(length: usize) -> String { + let mut bytes = vec![0u8; length]; + rand::thread_rng().fill_bytes(&mut bytes); + + // Use base64 for a compact and URL-safe representation + let mut encoded = BASE64_STANDARD.encode(bytes); + encoded.truncate(length); + encoded +} + +fn encrypt_password(password: &str, root_key_hex: &str) -> String { + let password_hex = hex::encode(password); + let salt = hex::encode(generate_secure_string(32)); + let nonce = hex::encode(generate_secure_string(12)); + encrypt_with_password(&password_hex, &salt, &nonce, root_key_hex).unwrap() +} + +fn decrypt_password(password: &str, encrypted_hex: &str) -> String { + let password_hex = hex::encode(password); + decrypt_with_password(&password_hex, encrypted_hex).unwrap() +} + +#[cfg(test)] +mod tests { + use super::{decrypt_password, encrypt_password, generate_secure_string, Minwallet}; + use crate::bip39::generate_mnemonic; + use crate::network::NetworkEnvironment; + + #[test] + fn can_generate_secure_string_with_length() { + let result = generate_secure_string(64); + assert_eq!(result.bytes().len(), 64); + } + + #[test] + fn can_encrypt_and_decrypt_password() { + let password = "MyPassword@@"; + let data = "aqu23oi45ufdgsaiklojug8oasdff"; + let data_hex = hex::encode(data); + let encrypted_hex = encrypt_password(&password, &data_hex); + let decrypted_hex = decrypt_password(&password, &encrypted_hex); + assert_eq!(decrypted_hex, data_hex); + } + + #[test] + fn can_create_new_minwallet() { + let mnemonic = generate_mnemonic(); + let password = "MyPassword@@"; + let network_environment = NetworkEnvironment::TestnetPreprod; + let wallet_name = "W01"; + let wallet = Minwallet::new(&mnemonic, password, network_environment, wallet_name); + println!("{:#?}", wallet); + assert_eq!(1, 1); + } +} diff --git a/rust/src/public_key_hash.rs b/rust/src/public_key_hash.rs new file mode 100644 index 0000000..15eb459 --- /dev/null +++ b/rust/src/public_key_hash.rs @@ -0,0 +1,12 @@ +pub struct PublicKeyHash { + pub key_hash: String, +} + +impl PublicKeyHash { + pub fn new(key_hash: String) -> Self { + if key_hash.as_bytes().len() != 28 { + panic!("Invalid key hash length") + } + PublicKeyHash { key_hash } + } +} diff --git a/rust/src/translucent_helpers.rs b/rust/src/translucent_helpers.rs new file mode 100644 index 0000000..17fd332 --- /dev/null +++ b/rust/src/translucent_helpers.rs @@ -0,0 +1,15 @@ +use crate::{tx_in::TxIn, utxo::Utxo}; + +pub struct TOutRef { + pub tx_hash: String, + pub output_index: u32, +} + +impl TOutRef { + pub fn from_tx_in(tx_in: &TxIn) -> Self { + Self { + tx_hash: format!("{:x?}", tx_in.tx_id), + output_index: tx_in.index, + } + } +} diff --git a/rust/src/tx_in.rs b/rust/src/tx_in.rs new file mode 100644 index 0000000..eb4bc2f --- /dev/null +++ b/rust/src/tx_in.rs @@ -0,0 +1,49 @@ +use cardano_serialization_lib::{Transaction, TransactionInput}; + +pub struct TxIn { + pub tx_id: Vec, + pub index: u32, +} + +impl TxIn { + pub fn get_inputs_from_tx_raw(tx_raw: &str) -> Vec { + let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); + let tx_body = tx.body(); + let inputs = tx_body.inputs(); + let mut tx_ins = Vec::new(); + for i in 0..inputs.len() { + let input = inputs.get(i); + tx_ins.push(Self::from_hex(&input.to_hex())); + } + + tx_ins + } + + pub fn get_collateral_from_tx_raw(tx_raw: &str) -> Option> { + let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); + let tx_body = tx.body(); + let collateral = tx_body.collateral(); + + match collateral { + Some(collateral) => { + let mut tx_ins = Vec::new(); + for i in 0..collateral.len() { + let input = collateral.get(i); + tx_ins.push(Self::from_hex(&input.to_hex())); + } + + Some(tx_ins) + } + None => None, + } + } + + pub fn from_hex(input: &str) -> Self { + let transaction_input = TransactionInput::from_hex(input).unwrap(); + let transaction_hash = transaction_input.transaction_id(); + Self { + tx_id: transaction_hash.to_bytes(), + index: transaction_input.index(), + } + } +} diff --git a/rust/src/tx_out.rs b/rust/src/tx_out.rs new file mode 100644 index 0000000..7c9130d --- /dev/null +++ b/rust/src/tx_out.rs @@ -0,0 +1,51 @@ +use cardano_serialization_lib::{Address, Value, TransactionOutput}; + +pub enum DatumSource { + DatumHash { hash: Vec }, + InlineDatum { data: Vec }, +} + +pub struct TxOut { + pub address: Address, + pub value: Value, + pub datum_source: Option, + pub script_ref: Option>, +} + +impl TxOut { + pub fn from_hex(out: &str) -> Self { + let transaction_output = TransactionOutput::from_hex(out).unwrap(); + + let address = transaction_output.address(); + let value = transaction_output.amount(); + let datum_hash = transaction_output.data_hash(); + let plutus_data = transaction_output.plutus_data(); + + let mut datum_source: Option = None; + if let Some(plutus_data) = plutus_data { + datum_source = Some(DatumSource::InlineDatum { + data: plutus_data.to_bytes(), + }); + } else if let Some(datum_hash) = datum_hash { + datum_source = Some(DatumSource::DatumHash { + hash: datum_hash.to_bytes(), + }) + } + + let script_ref = transaction_output.script_ref(); + let plutus_script = match script_ref { + None => None, + Some(script_ref) => Some(script_ref.plutus_script()), + }; + Self { + address, + value, + datum_source, + script_ref: match plutus_script { + None => None, + Some(None) => None, + Some(Some(plutus_script)) => Some(plutus_script.to_bytes()), + }, + } + } +} diff --git a/rust/src/utxo.rs b/rust/src/utxo.rs new file mode 100644 index 0000000..1e2be1a --- /dev/null +++ b/rust/src/utxo.rs @@ -0,0 +1,20 @@ +use cardano_serialization_lib::TransactionUnspentOutput; + +use crate::{tx_in::TxIn, tx_out::TxOut}; + +pub struct Utxo { + pub input: TxIn, + pub output: TxOut, +} + +impl Utxo { + pub fn from_hex(value: &str) -> Self { + let cls_utxo = TransactionUnspentOutput::from_hex(value).unwrap(); + let input = cls_utxo.input(); + let output = cls_utxo.output(); + Self { + input: TxIn::from_hex(&input.to_hex()), + output: TxOut::from_hex(&output.to_hex()), + } + } +} diff --git a/rust/src/value.rs b/rust/src/value.rs new file mode 100644 index 0000000..1b3bbde --- /dev/null +++ b/rust/src/value.rs @@ -0,0 +1,66 @@ +use std::collections::HashMap; + +use cardano_serialization_lib::Value as CSLValue; + +use crate::asset::{Asset, ADA}; +use crate::bytes::Bytes; + +#[derive(Clone)] +pub struct Value { + pub map: HashMap, +} + +impl Value { + pub fn new(map: Option>) -> Self { + match map { + Some(map) => Self { map }, + None => Self { + map: HashMap::new(), + }, + } + } + + fn init_if_not_exists(&mut self, a: &Asset) { + if !self.map.contains_key(&a.to_string()) { + self.map.insert(a.to_string(), 0); + } + } + + pub fn add(&mut self, a: &Asset, x: u64) -> &mut Self { + if x == 0 { + return self; + } + + self.init_if_not_exists(a); + self.map + .insert(a.to_string(), self.map.get(&a.to_string()).unwrap() + 1); + + self + } + + pub fn from_hex(value: &str) -> Self { + let value = CSLValue::from_hex(value).unwrap(); + let coin = value.coin(); + let mut initialzed_value = Value::new(None); + let ret = initialzed_value.add(&ADA.to_owned(), coin.try_into().unwrap()); + let ma = value.multiasset(); + if let Some(ma) = ma { + for i in 0..ma.keys().len() { + let currency_symbol = ma.keys().get(i); + let assets = ma.get(¤cy_symbol).unwrap(); + + for j in 0..assets.keys().len() { + let token_name = assets.keys().get(j); + let amount = assets.get(&token_name).unwrap(); + let asset = Asset::new( + &Bytes::from_hex(¤cy_symbol.to_hex()), + &Bytes::from_hex(&token_name.to_hex()), + ); + ret.add(&asset, amount.try_into().unwrap()); + } + } + } + + ret.to_owned() + } +} diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs new file mode 100644 index 0000000..b164254 --- /dev/null +++ b/rust/src/wallet/embedded.rs @@ -0,0 +1,75 @@ +use bip39::{Mnemonic, Language}; +use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credential, RewardAddress}; + +use crate::utils::harden; +pub struct Account {} + +pub trait WalletStaticMethods { + fn mnemonic_to_entropy(phrase: &str) -> Vec { + let mnemonic = Mnemonic::from_phrase(&phrase, Language::English).unwrap(); + mnemonic.entropy().to_vec() + } + + fn entropy_to_root_key(entropy: &[u8], password: &str)-> Bip32PrivateKey { + Bip32PrivateKey::from_bip39_entropy( + entropy, + password.as_bytes() + ) + } + + fn harden(index: u32) -> u32 { + index | 0x80_00_00_00 + } + + fn get_account(root_key: &Bip32PrivateKey, index: u32) -> Bip32PrivateKey { + root_key + .derive(harden(1852)) // purpose + .derive(harden(1815)) // coin type + .derive(harden(index)) + } + + fn get_address(account: &Bip32PrivateKey, network_id: u8) -> Address { + let payment_key = account.derive(0).derive(0).to_raw_key(); + let payment_key_hash = payment_key.to_public().hash(); + let payment_credential = Credential::from_keyhash(&payment_key_hash); + + let stake_key = account.derive(2).derive(0).to_raw_key(); + let stake_key_hash = stake_key.to_public().hash(); + let stake_credential = Credential::from_keyhash(&stake_key_hash); + + BaseAddress::new(network_id, &payment_credential, &stake_credential).to_address() + } + + fn gen_reward_address(account: &Bip32PrivateKey, network_id: u8) -> RewardAddress { + let stake_key = account.derive(2).derive(0).to_raw_key(); + let stake_key_hash = stake_key.to_public().hash(); + let stake_credential = Credential::from_keyhash(&stake_key_hash); + + RewardAddress::new(network_id, &stake_credential) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + struct TestWallet; + + impl WalletStaticMethods for TestWallet {} + + #[test] + fn test_base_address() { + let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); + let password = String::from("helloworld"); + let entropy = TestWallet::mnemonic_to_entropy(&seed); + let root_key = TestWallet::entropy_to_root_key(&entropy, &password); + assert_eq!(root_key.to_bech32(), "xprv1gre69tdkhwnzsl0spaj9n9ty9gc7yx64fm29ff9hea57sd4q03xuatqlpq7qanpl3dnjzdtchx394gdk9w0c9ezaaau45c2wk5aduyht3kw7659u7gzt4qh37na0dsh66txhajlzssf27ay75s8hpdqqug7vwwy6"); + + let account = TestWallet::get_account(&root_key, 0); + let address = TestWallet::get_address(&account, 1); + assert_eq!(address.to_bech32(None).unwrap(), "addr1q82vnh5g9epl7x8c3m0zngjtfzcjttt5gjpf8eptvjxk74397eag00jf7yvzj28v38mufm9keaygaywu0eprdwnu40hsm6eekf"); + + let reward_address = TestWallet::gen_reward_address(&account, 1); + assert_eq!(reward_address.to_address().to_bech32(None).unwrap(), "stake1uyjlv758heylzxpf9rkgna7yajmv7jywj8w8us3khf72hmcmx40fs"); + } +} diff --git a/rust/src/wallet/emip3.rs b/rust/src/wallet/emip3.rs new file mode 100644 index 0000000..3ea6770 --- /dev/null +++ b/rust/src/wallet/emip3.rs @@ -0,0 +1,65 @@ +use cardano_serialization_lib::{decrypt_with_password, encrypt_with_password}; +use hex::ToHex; +use rand::Rng; + +mod password_encryption_parameter { + pub const ITER: u32 = 19_162; + pub const SALT_SIZE: usize = 32; + pub const NONCE_SIZE: usize = 12; + pub const KEY_SIZE: usize = 32; + pub const TAG_SIZE: usize = 16; + + pub const METADATA_SIZE: usize = SALT_SIZE + NONCE_SIZE + TAG_SIZE; + + pub const SALT_START: usize = 0; + pub const SALT_END: usize = SALT_START + SALT_SIZE; + pub const NONCE_START: usize = SALT_END; + pub const NONCE_END: usize = NONCE_START + NONCE_SIZE; + pub const TAG_START: usize = NONCE_END; + pub const TAG_END: usize = TAG_START + TAG_SIZE; + pub const ENCRYPTED_START: usize = TAG_END; +} + +/// Generates a random value of the given size in hexadecimal format +fn generate_random_hex(size: usize) -> String { + let mut rng = rand::thread_rng(); + (0..size) + .map(|_| format!("{:02x}", rng.gen::())) + .collect() +} + +/// Generates a random salt +pub fn generate_salt() -> String { + generate_random_hex(password_encryption_parameter::SALT_SIZE) +} + +/// Generates a random nonce +pub fn generate_nonce() -> String { + generate_random_hex(password_encryption_parameter::NONCE_SIZE) +} + +pub fn encrypt_password(password: &str, data: &str) -> String { + let salt = generate_salt(); + let nonce = generate_nonce(); + let password_hex = hex::encode(password); + encrypt_with_password(&password_hex, &salt, &nonce, &data).unwrap() +} + +pub fn decrypt_password(password: &str, data: &str) -> String { + let password_hex = hex::encode(password); + decrypt_with_password(&password_hex, &data).unwrap() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_round_trip_encryption() { + let password = "fMESeaTVyCklzUD"; + let data = String::from("736f6d65206461746120746f20656e6372797074"); + let encrypted_data = encrypt_password(&password, &data); + let decrypted_data = decrypt_password(&password, &encrypted_data); + assert_eq!(data, decrypted_data); + } +} diff --git a/rust/src/wallet/maestro.rs b/rust/src/wallet/maestro.rs new file mode 100644 index 0000000..435fbb2 --- /dev/null +++ b/rust/src/wallet/maestro.rs @@ -0,0 +1,235 @@ +use std::collections::HashMap; +use std::error::Error; + +use reqwest::RequestBuilder; +use serde::Deserialize; +use serde::Serialize; + +#[derive(Deserialize, Debug, Clone)] +pub struct ClientConfig { + pub version: String, +} + +#[derive(Deserialize, Debug, Clone)] +pub struct Config { + pub client: ClientConfig, +} + +impl Config { + pub fn get_config() -> Config { + Config { + client: ClientConfig { + version: "v1".to_string(), + }, + } + } +} + +pub struct Maestro { + api_key: String, + http_client: reqwest::Client, + pub base_url: String, +} + +impl Maestro { + pub fn new(api_key: String, network: String) -> Self { + let cfg = Config::get_config(); + let base_url = format!( + "https://{}.gomaestro-api.org/{}", + &network, &cfg.client.version + ); + let http_client = reqwest::Client::builder() + .timeout(std::time::Duration::from_secs(300)) + .build() + .expect("Failed to create HTTP client"); + + Maestro { + api_key, + http_client, + base_url, + } + } + + async fn send_request( + &self, + req: RequestBuilder, + response_body: &mut String, + ) -> Result<(), Box> { + let req = req + .header("Accept", "application/json") + .header("api-key", &self.api_key) + .build()?; + + let response = self.http_client.execute(req).await?; + + if response.status().is_success() { + *response_body = response.text().await?; + Ok(()) + } else { + Err(format!("Error: {}", response.status()).into()) + } + } + + pub async fn get(&self, url: &str) -> Result> { + let req = self.http_client.get(format!("{}{}", &self.base_url, url)); + let mut response_body = String::new(); + self.send_request(req, &mut response_body).await?; + Ok(response_body) + } + + pub async fn post( + &self, + url: &str, + body: T, + ) -> Result> { + let json_body = serde_json::to_string(&body)?; + + let req = self + .http_client + .post(format!("{}{}", &self.base_url, url)) + .header("Content-Type", "application/json") + .body(json_body); + + let mut response_body = String::new(); + self.send_request(req, &mut response_body).await?; + Ok(response_body) + } +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct OperationalCertificate { + pub hot_vkey: String, + pub sequence_number: i64, + pub kes_period: i64, + pub kes_signature: String, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct LastUpdated { + timestamp: String, + block_hash: String, + block_slot: i64, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct TotalExUnits { + pub mem: i64, + pub steps: i64, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct LatestBlockData { + pub hash: String, + pub height: i64, + pub timestamp: String, + pub epoch: i64, + pub epoch_slot: i64, + pub absolute_slot: i64, + pub block_producer: String, + pub confirmations: i64, + pub tx_hashes: Vec, + pub total_fees: i64, + pub total_ex_units: TotalExUnits, + pub script_invocations: i32, + pub size: i32, + pub previous_block: String, + pub next_block: Option, + pub total_output_lovelace: String, + pub era: String, + pub protocol_version: Vec, + pub vrf_key: String, + pub operational_certificate: OperationalCertificate, +} + +#[derive(Deserialize, Debug, Clone)] +pub struct Asset { + pub amount: i64, + pub unit: String, +} + +#[derive(Deserialize, Debug, Clone)] +pub struct ReferenceScript { + pub bytes: String, + pub hash: String, + pub json: Option>, + pub r#type: String, +} + +#[derive(Deserialize, Debug, Clone)] +pub struct MaestroUtxo { + pub address: String, + pub assets: Vec, + pub datum: Option>, + pub index: i64, + pub reference_script: Option, + pub tx_hash: String, + #[serde(alias = "txout_cbor")] + pub tx_out_cbor: String, + pub slot: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct WrapperData { + pub data: T, + pub last_updated: Option, + pub next_cursor: Option, +} + +impl Maestro { + pub async fn get_latest_block(&self) -> Result> { + let url = String::from("/blocks/latest"); + let response = self.get(&url).await?; + + // Deserialize into the generic wrapper + let wrapper: WrapperData = + serde_json::from_str(&response).map_err(|e| Box::new(e) as Box)?; + + // Extract the inner data + Ok(wrapper.data) + } + + pub async fn get_utxos(&self, address_bech32: &String) -> Result, Box> { + let url = format!("/addresses/{}/utxos?with_cbor=true", address_bech32); + let response = self.get(&url).await?; + eprintln!("Raw API Response: {}", response); // Log the raw response + + let wrapper: WrapperData> = + serde_json::from_str(&response).map_err(|e| { + eprintln!("Deserialization failed: {:?}", e); + eprintln!("Response: {}", response); + Box::new(e) as Box + })?; + + // Deserialize into the generic wrapper + // let wrapper: WrapperData> = + // serde_json::from_str(&response).map_err(|e| Box::new(e) as Box)?; + + // Extract the inner data + Ok(wrapper.data) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_get_latest_block() { + let maestro_client = Maestro::new( + "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), + "preprod".to_string(), + ); + let data = maestro_client.get_latest_block().await.unwrap(); + assert!(data.height > 0); + } + + async fn test_maestro() { + let maestro_client = Maestro::new( + "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), + "preprod".to_string(), + ); + let address_bech32 = String::from("addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt"); + let utxos = maestro_client.get_utxos(&address_bech32).await.unwrap(); + assert!(utxos.len() > 0) + } +} diff --git a/rust/src/wallet/mod.rs b/rust/src/wallet/mod.rs new file mode 100644 index 0000000..9c7d1c1 --- /dev/null +++ b/rust/src/wallet/mod.rs @@ -0,0 +1,4 @@ +pub mod embedded; +pub mod emip3; +pub mod provider; +mod maestro; diff --git a/rust/src/wallet/provider.rs b/rust/src/wallet/provider.rs new file mode 100644 index 0000000..394b2a3 --- /dev/null +++ b/rust/src/wallet/provider.rs @@ -0,0 +1,58 @@ +use cardano_serialization_lib::{ + Address, TransactionUnspentOutput, TransactionUnspentOutputs, +}; +use cardano_serialization_lib::{TransactionHash, TransactionInput, TransactionOutput}; +use maestro_rust_sdk::models::addresses::Utxo as MaestroUtxo; +use maestro_rust_sdk::Maestro; + +struct MaestroProvider { + key: String, + network: String, +} + +impl MaestroProvider { + pub fn to_csl_utxo(utxo: &MaestroUtxo) -> TransactionUnspentOutput { + let tx_hash = TransactionHash::from_hex(utxo.tx_hash.as_str()).unwrap(); + let tx_index = utxo.index as u32; + let tx_in = TransactionInput::new(&tx_hash, tx_index); + let tx_out = TransactionOutput::from_hex(utxo.tx_out_cbor.as_str()).unwrap(); + TransactionUnspentOutput::new(&tx_in, &tx_out) + } + + pub async fn get_utxos(client: &Maestro, address: &Address) -> Result> { + let bech32 = address.to_bech32(None).unwrap(); + let utxos_at_address = Maestro::utxos_at_address(&client, &bech32.as_str(), None).await; + + // Handle errors properly + let utxos_at_address = match utxos_at_address { + Ok(result) => result, + Err(e) => { + eprintln!("Error fetching UTXOs: {:?}", e); + return Err(e); + } + }; + + let mut csl_utxos = TransactionUnspentOutputs::new(); + for utxo in utxos_at_address.data.into_iter() { + let csl_utxo = MaestroProvider::to_csl_utxo(&utxo); + csl_utxos.add(&csl_utxo); + } + Ok(csl_utxos) + } +} + +// #[cfg(test)] +// mod tests { +// use super::*; +// +// #[tokio::test] +// async fn test_maestro() { +// let maestro_client = Maestro::new( +// "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), +// "preprod".to_string(), +// ); +// let address = Address::from_bech32("addr_test1qq6dyn40spwrvhgx9sk28u0lu6e2xew7hsprev409gwv6pw5p9fxve2hgwv9ce5zz86j4k82vaa5g72cs9yjpz0jspfsvdm6zz").unwrap(); +// let utxos = MaestroProvider::get_utxos(&maestro_client, &address).await.unwrap(); +// assert!(utxos.len() > 0); +// } +// } From 9c7964d5f9b6d2d4b37ecf28846f910210b8f75c Mon Sep 17 00:00:00 2001 From: dzung pham Date: Wed, 20 Nov 2024 17:30:49 +0700 Subject: [PATCH 03/32] fix --- rust/src/wallet/maestro.rs | 62 +++++++++++++++++++++++++++++++------ rust/src/wallet/mod.rs | 1 - rust/src/wallet/provider.rs | 58 ---------------------------------- 3 files changed, 52 insertions(+), 69 deletions(-) delete mode 100644 rust/src/wallet/provider.rs diff --git a/rust/src/wallet/maestro.rs b/rust/src/wallet/maestro.rs index 435fbb2..89fc8bc 100644 --- a/rust/src/wallet/maestro.rs +++ b/rust/src/wallet/maestro.rs @@ -1,6 +1,12 @@ use std::collections::HashMap; use std::error::Error; +use cardano_serialization_lib::Address; +use cardano_serialization_lib::TransactionHash; +use cardano_serialization_lib::TransactionInput; +use cardano_serialization_lib::TransactionOutput; +use cardano_serialization_lib::TransactionUnspentOutput; +use cardano_serialization_lib::TransactionUnspentOutputs; use reqwest::RequestBuilder; use serde::Deserialize; use serde::Serialize; @@ -183,29 +189,55 @@ impl Maestro { // Deserialize into the generic wrapper let wrapper: WrapperData = serde_json::from_str(&response).map_err(|e| Box::new(e) as Box)?; - + // Extract the inner data Ok(wrapper.data) } - pub async fn get_utxos(&self, address_bech32: &String) -> Result, Box> { + pub async fn get_utxos( + &self, + address_bech32: &String, + ) -> Result, Box> { let url = format!("/addresses/{}/utxos?with_cbor=true", address_bech32); let response = self.get(&url).await?; - eprintln!("Raw API Response: {}", response); // Log the raw response - let wrapper: WrapperData> = serde_json::from_str(&response).map_err(|e| { eprintln!("Deserialization failed: {:?}", e); eprintln!("Response: {}", response); Box::new(e) as Box })?; + Ok(wrapper.data) + } - // Deserialize into the generic wrapper - // let wrapper: WrapperData> = - // serde_json::from_str(&response).map_err(|e| Box::new(e) as Box)?; + pub fn to_csl_utxo(&self, utxo: &MaestroUtxo) -> TransactionUnspentOutput { + let tx_hash = TransactionHash::from_hex(utxo.tx_hash.as_str()).unwrap(); + let tx_index = utxo.index as u32; + let tx_in = TransactionInput::new(&tx_hash, tx_index); + let tx_out = TransactionOutput::from_hex(utxo.tx_out_cbor.as_str()).unwrap(); + TransactionUnspentOutput::new(&tx_in, &tx_out) + } - // Extract the inner data - Ok(wrapper.data) + pub async fn get_csl_utxos( + &self, + address: &Address, + ) -> Result> { + let bech32 = address.to_bech32(None).map_err(|e| { + eprintln!("Failed to convert address to Bech32: {:?}", e); + e + })?; + + let maestro_utxos = self.get_utxos(&bech32).await.map_err(|e| { + eprintln!("Failed to fetch UTXOs: {:?}", e); + e + })?; + + let mut csl_utxos = TransactionUnspentOutputs::new(); + for utxo in maestro_utxos.into_iter() { + let csl_utxo = self.to_csl_utxo(&utxo); + csl_utxos.add(&csl_utxo); + } + + Ok(csl_utxos) } } @@ -223,7 +255,7 @@ mod tests { assert!(data.height > 0); } - async fn test_maestro() { + async fn test_get_utxos() { let maestro_client = Maestro::new( "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), "preprod".to_string(), @@ -232,4 +264,14 @@ mod tests { let utxos = maestro_client.get_utxos(&address_bech32).await.unwrap(); assert!(utxos.len() > 0) } + + async fn test_get_csl_utxos() { + let maestro_client = Maestro::new( + "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), + "preprod".to_string(), + ); + let address = Address::from_bech32("addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt").unwrap(); + let csl_utxos = maestro_client.get_csl_utxos(&address).await.unwrap(); + assert!(csl_utxos.len() > 0); + } } diff --git a/rust/src/wallet/mod.rs b/rust/src/wallet/mod.rs index 9c7d1c1..e20669e 100644 --- a/rust/src/wallet/mod.rs +++ b/rust/src/wallet/mod.rs @@ -1,4 +1,3 @@ pub mod embedded; pub mod emip3; -pub mod provider; mod maestro; diff --git a/rust/src/wallet/provider.rs b/rust/src/wallet/provider.rs deleted file mode 100644 index 394b2a3..0000000 --- a/rust/src/wallet/provider.rs +++ /dev/null @@ -1,58 +0,0 @@ -use cardano_serialization_lib::{ - Address, TransactionUnspentOutput, TransactionUnspentOutputs, -}; -use cardano_serialization_lib::{TransactionHash, TransactionInput, TransactionOutput}; -use maestro_rust_sdk::models::addresses::Utxo as MaestroUtxo; -use maestro_rust_sdk::Maestro; - -struct MaestroProvider { - key: String, - network: String, -} - -impl MaestroProvider { - pub fn to_csl_utxo(utxo: &MaestroUtxo) -> TransactionUnspentOutput { - let tx_hash = TransactionHash::from_hex(utxo.tx_hash.as_str()).unwrap(); - let tx_index = utxo.index as u32; - let tx_in = TransactionInput::new(&tx_hash, tx_index); - let tx_out = TransactionOutput::from_hex(utxo.tx_out_cbor.as_str()).unwrap(); - TransactionUnspentOutput::new(&tx_in, &tx_out) - } - - pub async fn get_utxos(client: &Maestro, address: &Address) -> Result> { - let bech32 = address.to_bech32(None).unwrap(); - let utxos_at_address = Maestro::utxos_at_address(&client, &bech32.as_str(), None).await; - - // Handle errors properly - let utxos_at_address = match utxos_at_address { - Ok(result) => result, - Err(e) => { - eprintln!("Error fetching UTXOs: {:?}", e); - return Err(e); - } - }; - - let mut csl_utxos = TransactionUnspentOutputs::new(); - for utxo in utxos_at_address.data.into_iter() { - let csl_utxo = MaestroProvider::to_csl_utxo(&utxo); - csl_utxos.add(&csl_utxo); - } - Ok(csl_utxos) - } -} - -// #[cfg(test)] -// mod tests { -// use super::*; -// -// #[tokio::test] -// async fn test_maestro() { -// let maestro_client = Maestro::new( -// "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), -// "preprod".to_string(), -// ); -// let address = Address::from_bech32("addr_test1qq6dyn40spwrvhgx9sk28u0lu6e2xew7hsprev409gwv6pw5p9fxve2hgwv9ce5zz86j4k82vaa5g72cs9yjpz0jspfsvdm6zz").unwrap(); -// let utxos = MaestroProvider::get_utxos(&maestro_client, &address).await.unwrap(); -// assert!(utxos.len() > 0); -// } -// } From 42413611f0573e1727f587348161567ee95ec433 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 21 Nov 2024 10:51:25 +0700 Subject: [PATCH 04/32] format --- rust/Cargo.lock | 403 +++----------------------------- rust/Cargo.toml | 1 - rust/src/lib.rs | 9 +- rust/src/minswap_provider.rs | 2 - rust/src/mwrust.udl | 2 - rust/src/translucent_helpers.rs | 15 -- 6 files changed, 35 insertions(+), 397 deletions(-) delete mode 100644 rust/src/translucent_helpers.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 83a1f2b..f06ef5f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -17,17 +17,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.11" @@ -40,21 +29,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anstream" version = "0.6.18" @@ -110,12 +84,6 @@ version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - [[package]] name = "askama" version = "0.12.1" @@ -139,7 +107,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.87", + "syn", ] [[package]] @@ -226,18 +194,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -256,57 +212,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "borsh" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" -dependencies = [ - "borsh-derive", - "cfg_aliases", -] - -[[package]] -name = "borsh-derive" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" -dependencies = [ - "once_cell", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "bytecheck" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "simdutf8", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "byteorder" version = "1.5.0" @@ -406,27 +317,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "serde", - "wasm-bindgen", - "windows-targets 0.52.6", -] - [[package]] name = "clap" version = "4.5.21" @@ -458,7 +348,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -560,7 +450,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -660,12 +550,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "futures-channel" version = "0.3.31" @@ -779,22 +663,13 @@ dependencies = [ "tracing", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] - [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash", ] [[package]] @@ -910,29 +785,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - [[package]] name = "icu_collections" version = "1.5.0" @@ -1048,7 +900,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1105,9 +957,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "js-sys" @@ -1158,19 +1010,6 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -[[package]] -name = "maestro-rust-sdk" -version = "1.2.5" -source = "git+ssh://git@github.com/maestro-org/rust-sdk.git#55b8d161e3efe15a93ffbb8898caeaa45cb37a19" -dependencies = [ - "chrono", - "reqwest", - "rust_decimal", - "serde", - "serde_json", - "serde_qs", -] - [[package]] name = "memchr" version = "2.7.4" @@ -1229,7 +1068,6 @@ dependencies = [ "cryptoxide", "hex", "lazy_static", - "maestro-rust-sdk", "rand", "reqwest", "serde", @@ -1313,7 +1151,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1400,7 +1238,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1499,44 +1337,15 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "proc-macro-crate" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" -dependencies = [ - "toml_edit", -] - [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "d4e1ced3fe749df87a909c23e9607ab9a09c8f0bedb7e03b8146f4c08c298673" dependencies = [ "unicode-ident", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "quote" version = "1.0.37" @@ -1546,12 +1355,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.8.5" @@ -1630,15 +1433,6 @@ dependencies = [ "bitflags 2.6.0", ] -[[package]] -name = "rend" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" -dependencies = [ - "bytecheck", -] - [[package]] name = "reqwest" version = "0.11.27" @@ -1679,51 +1473,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "rkyv" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" -dependencies = [ - "bitvec", - "bytecheck", - "bytes", - "hashbrown 0.12.3", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", - "tinyvec", - "uuid", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "rust_decimal" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" -dependencies = [ - "arrayvec", - "borsh", - "bytes", - "num-traits", - "rand", - "rkyv", - "serde", - "serde_json", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -1794,7 +1543,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.87", + "syn", ] [[package]] @@ -1820,15 +1569,9 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "security-framework" version = "2.11.1" @@ -1889,7 +1632,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1900,7 +1643,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -1915,17 +1658,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_qs" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0431a35568651e363364210c91983c1da5eb29404d9f0928b67d4ebcfa7d330c" -dependencies = [ - "percent-encoding", - "serde", - "thiserror", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1977,12 +1709,6 @@ dependencies = [ "libc", ] -[[package]] -name = "simdutf8" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" - [[package]] name = "siphasher" version = "0.3.11" @@ -2046,20 +1772,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "f8e9a4e1639f47f655bf8e5198232f05615d5fb7e864ef5c4f5abdaf8ad3b8f4" dependencies = [ "proc-macro2", "quote", @@ -2080,7 +1795,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2104,12 +1819,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tempfile" version = "3.14.0" @@ -2149,7 +1858,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2220,7 +1929,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2255,23 +1964,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" - -[[package]] -name = "toml_edit" -version = "0.22.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "tower-service" version = "0.3.3" @@ -2317,9 +2009,9 @@ checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-normalization" @@ -2387,7 +2079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "802d2051a700e3ec894c79f80d2705b69d85844dafbbe5d1a92776f8f48b563a" dependencies = [ "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2417,7 +2109,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.87", + "syn", "toml", "uniffi_meta", ] @@ -2489,12 +2181,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" - [[package]] name = "vcpkg" version = "0.2.15" @@ -2543,7 +2229,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn", "wasm-bindgen-shared", ] @@ -2577,7 +2263,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2629,15 +2315,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -2786,15 +2463,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" -dependencies = [ - "memchr", -] - [[package]] name = "winreg" version = "0.50.0" @@ -2817,15 +2485,6 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "yoke" version = "0.7.4" @@ -2846,7 +2505,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "synstructure", ] @@ -2868,7 +2527,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2888,7 +2547,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", "synstructure", ] @@ -2909,7 +2568,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] [[package]] @@ -2931,5 +2590,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 632248c..d5d270d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,7 +15,6 @@ serde = { version = "1.0.213", features = ["derive"] } serde_json = "1.0.132" uniffi = { version = "0.28.2", features = ["cli"] } cryptoxide = "0.4.4" -maestro-rust-sdk = { git = "ssh://git@github.com/maestro-org/rust-sdk.git" } tokio = { version = "1.41.1", features = ["full"] } [build-dependencies] diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 8fc153a..11a4a75 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -2,10 +2,10 @@ use crate::network::{NetworkEnvironment, NetworkId}; use crate::utils::harden; use cardano_serialization_lib::Bip32PrivateKey; use cardano_serialization_lib::{ - BaseAddress, EnterpriseAddress, RewardAddress,Credential, - PrivateKey, Vkeywitnesses, - make_vkey_witness, - Transaction, TransactionWitnessSet, + BaseAddress, Credential, EnterpriseAddress, RewardAddress + + + , }; pub mod wallet; @@ -14,7 +14,6 @@ mod bytes; mod minswap_provider; pub mod network; pub mod public_key_hash; -mod translucent_helpers; mod tx_in; mod tx_out; pub mod utils; diff --git a/rust/src/minswap_provider.rs b/rust/src/minswap_provider.rs index 97e4848..72de492 100644 --- a/rust/src/minswap_provider.rs +++ b/rust/src/minswap_provider.rs @@ -1,5 +1,3 @@ -use crate::translucent_helpers::TOutRef; - struct WalletEndpoints { utxo_by_tx_in: &'static str, } diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 979c387..3b50fff 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,7 +1,5 @@ namespace mwrust { - string generate_mnemonic(); WalletType create_wallet([ByRef] string mnemonic, [ByRef] string password, u32 account_index, AddressType address_type, NetworkEnvironment network_environment); - string sign_tx([ByRef] string tx_raw, sequence keys); }; enum NetworkEnvironment { diff --git a/rust/src/translucent_helpers.rs b/rust/src/translucent_helpers.rs deleted file mode 100644 index 17fd332..0000000 --- a/rust/src/translucent_helpers.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::{tx_in::TxIn, utxo::Utxo}; - -pub struct TOutRef { - pub tx_hash: String, - pub output_index: u32, -} - -impl TOutRef { - pub fn from_tx_in(tx_in: &TxIn) -> Self { - Self { - tx_hash: format!("{:x?}", tx_in.tx_id), - output_index: tx_in.index, - } - } -} From 4e1e0e09fc72e94356fe76986a6c93a1e444b155 Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 14:06:07 +0700 Subject: [PATCH 05/32] wip --- rust/src/crypto.rs | 13 ++++++++++ rust/src/lib.rs | 2 +- rust/src/minwallet.rs | 49 +++++++++++++++++++++++++++++++++++-- rust/src/wallet/embedded.rs | 25 ++++++++++++++++++- rust/src/wallet/maestro.rs | 40 ++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 rust/src/crypto.rs diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs new file mode 100644 index 0000000..ae27052 --- /dev/null +++ b/rust/src/crypto.rs @@ -0,0 +1,13 @@ +use cryptoxide::blake2b::Blake2b; + +pub(crate) fn blake2b224(data: &[u8]) -> [u8; 28] { + let mut out = [0; 28]; + Blake2b::blake2b(&mut out, data, &[]); + out +} + +pub(crate) fn blake2b256(data: &[u8]) -> [u8; 32] { + let mut out = [0; 32]; + Blake2b::blake2b(&mut out, data, &[]); + out +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 11a4a75..6caef98 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -19,7 +19,7 @@ mod tx_out; pub mod utils; mod utxo; mod value; - +mod crypto; pub mod minwallet; pub enum AddressType { diff --git a/rust/src/minwallet.rs b/rust/src/minwallet.rs index c290bc3..797d94d 100644 --- a/rust/src/minwallet.rs +++ b/rust/src/minwallet.rs @@ -1,7 +1,7 @@ use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; use crate::wallet::emip3::encrypt_password; -use cardano_serialization_lib::{Address, RewardAddress}; +use cardano_serialization_lib::{Address, PrivateKey, RewardAddress}; const MINWALLET_VERSION: &str = "2.0.0"; @@ -35,7 +35,7 @@ impl Minwallet { let account_key = Minwallet::get_account(&root_key, account_index); // Encrypt root key with password - let encrypted_key = encrypt_password(password, &root_key.to_hex()); + let encrypted_key = Minwallet::gen_encrypted_key(password, &root_key); // Derive network ID let network_id = network_environment.to_network_id() as u8; @@ -55,4 +55,49 @@ impl Minwallet { wallet_name: wallet_name.to_string(), } } + + pub fn get_private_key(&self, password: &str, account_index: u32) -> PrivateKey { + let root_key = Minwallet::get_root_key_from_password(&password, &self.encrypted_key); + let account_key = Minwallet::get_account(&root_key, account_index); + let payment_key = account_key.derive(0).derive(0).to_raw_key(); + PrivateKey::from_bech32(payment_key.to_bech32().as_ref()).unwrap() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitness, Vkeywitnesses}; + use crate::crypto::blake2b256; + + #[test] + fn test_get_private_key() { + let password = "Minswap@123456"; + let min_wallet = Minwallet::create( + "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", + &password, + NetworkEnvironment::TestnetPreprod, "Tony" + ); + let private_key = min_wallet.get_private_key(&password, 0); + assert_eq!(private_key.to_hex(), String::from("f838ddcb280f7c89bf5480591a0b46b2b80602134b19179a61c1991d7639ab549009491d6b359c37f03af6422af350e2e041ecde02a734a4b9dae5a6f7a1bf69")); + } + + #[test] + fn test_happy_path() { + let password = "Minswap@123456"; + let min_wallet = Minwallet::create( + "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", + &password, + NetworkEnvironment::TestnetPreprod, "Tony" + ); + let tx_raw = "84a40081825820dee6b0848594bea01d61450e47827da762947f61ad2387ccf1f8ba629b5252d4020182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a1d16ce6d021a0002917d031a048f683ca0f5f6"; + let tx = Transaction::from_hex(tx_raw).unwrap(); + let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); + let mut witness_set = TransactionWitnessSet::new(); + let mut v_key_witness = Vkeywitnesses::new(); + let private_key = min_wallet.get_private_key(&password, 0); + let v_key = make_vkey_witness(&tx_hash, &private_key); + v_key_witness.add(&v_key); + witness_set.set_vkeys(&v_key_witness); + } } diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index b164254..2538e70 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -1,7 +1,9 @@ -use bip39::{Mnemonic, Language}; +use bip39::{Language, Mnemonic}; use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credential, RewardAddress}; use crate::utils::harden; +use crate::wallet::emip3::{decrypt_password, encrypt_password}; + pub struct Account {} pub trait WalletStaticMethods { @@ -47,6 +49,16 @@ pub trait WalletStaticMethods { RewardAddress::new(network_id, &stake_credential) } + + fn gen_encrypted_key(password: &str, root_key: &Bip32PrivateKey) -> String { + let root_key_hex = root_key.to_hex(); + encrypt_password(password, root_key_hex.as_str()) + } + + fn get_root_key_from_password(password: &str, encrypted_key: &String) -> Bip32PrivateKey { + let decrypted = decrypt_password(password, encrypted_key); + Bip32PrivateKey::from_hex(decrypted.as_str()).unwrap() + } } #[cfg(test)] @@ -57,6 +69,17 @@ mod tests { impl WalletStaticMethods for TestWallet {} + #[test] + fn test_round_trip_root_key() { + let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); + let password = String::from("helloworld"); + let entropy = TestWallet::mnemonic_to_entropy(&seed); + let root_key = TestWallet::entropy_to_root_key(&entropy, &password); + let encrypted = TestWallet::gen_encrypted_key(&password, &root_key); + let decrypted = TestWallet::get_root_key_from_password(&password, &encrypted); + assert_eq!(root_key.to_hex(), decrypted.to_hex()); + } + #[test] fn test_base_address() { let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); diff --git a/rust/src/wallet/maestro.rs b/rust/src/wallet/maestro.rs index 89fc8bc..7c55bb6 100644 --- a/rust/src/wallet/maestro.rs +++ b/rust/src/wallet/maestro.rs @@ -209,6 +209,30 @@ impl Maestro { Ok(wrapper.data) } + pub async fn submit_tx(&self, tx_cbor: &Vec) -> Result> { + let url = "/txmanager"; + let req = self + .http_client + .post(format!("{}{}", &self.base_url, url)) + .header("Content-Type", "application/cbor") + .header("Accept", "text/plain") + .header("api-key", &self.api_key) + .body(tx_cbor.clone()) + .build()?; + + let response = self.http_client.execute(req).await?; + // Clone the status before consuming the response body + let status = response.status(); + let response_body = response.text().await.unwrap_or_else(|_| "Failed to read response body".to_string()); + + if status.is_success() { + Ok(response_body) + } else { + eprintln!("Error | Status = {}, Body = {}", status, response_body); + Err(format!("Error | Status = {}, Body = {}", status, response_body).into()) + } + } + pub fn to_csl_utxo(&self, utxo: &MaestroUtxo) -> TransactionUnspentOutput { let tx_hash = TransactionHash::from_hex(utxo.tx_hash.as_str()).unwrap(); let tx_index = utxo.index as u32; @@ -243,6 +267,7 @@ impl Maestro { #[cfg(test)] mod tests { + use cardano_serialization_lib::Transaction; use super::*; #[tokio::test] @@ -255,6 +280,7 @@ mod tests { assert!(data.height > 0); } + #[tokio::test] async fn test_get_utxos() { let maestro_client = Maestro::new( "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), @@ -265,6 +291,7 @@ mod tests { assert!(utxos.len() > 0) } + #[tokio::test] async fn test_get_csl_utxos() { let maestro_client = Maestro::new( "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), @@ -274,4 +301,17 @@ mod tests { let csl_utxos = maestro_client.get_csl_utxos(&address).await.unwrap(); assert!(csl_utxos.len() > 0); } + + #[tokio::test] + #[ignore] + async fn test_submit_tx() { + let maestro_client = Maestro::new( + "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), + "preprod".to_string(), + ); + let tx_raw = "84a300818258203cc12ff1e7e02a953ce2dbe2c3e4edf5fc516c64322778a123e547dbf1886cfc010182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a9821b00000001c9cd8f35a2581ce16c2dc8ae937e8d3790c7fd7168d7b994621ba14ca11415f39fed72a2434d494e1a00019ae2444d494e741a00018a7b581ce4214b7cce62ac6fbba385d164df48e157eae5863521b4b67ca71d86a258203bb0079303c57812462dec9de8fb867cef8fd3768de7f12c77f6f0dd80381d0d1a00022098582044d75b06a5aafc296e094bf3a450734f739449c62183d4e3bbd50c28522afc971a000428e7021a001eab58a10081825820caef3384a369c8267801777c240bf648aa59719a31a3706113bd7cce67d477a4584090363e91ee07de04952e818bbc67cbd24501c78ced75497b48a6e76e8a9993e33dff2508d319799985643eb7b75e8b4e04a7975cea43da96463378ef6179c30bf5f6"; + let tx = Transaction::from_hex(&tx_raw).unwrap(); + let tx_cbor = tx.to_bytes(); + let result = maestro_client.submit_tx(&tx_cbor).await.unwrap(); + } } From 2dbef21752a57f8d609e47e435b0d59bcd2f92df Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 14:21:29 +0700 Subject: [PATCH 06/32] wip --- rust/a.json | 25 --- rust/a.sjon | 25 --- rust/src/asset.rs | 34 ---- rust/src/bytes.rs | 18 --- rust/src/lib.rs | 120 --------------- rust/src/minswap_provider.rs | 23 --- rust/src/minwallet.rs | 24 ++- rust/src/minwallet_backup.rs | 290 ----------------------------------- rust/src/mwrust.udl | 35 +++-- rust/src/public_key_hash.rs | 12 -- rust/src/tx_in.rs | 49 ------ rust/src/tx_out.rs | 51 ------ rust/src/utils.rs | 3 - rust/src/utxo.rs | 20 --- rust/src/value.rs | 66 -------- rust/src/wallet/embedded.rs | 10 +- 16 files changed, 39 insertions(+), 766 deletions(-) delete mode 100644 rust/a.json delete mode 100644 rust/a.sjon delete mode 100644 rust/src/asset.rs delete mode 100644 rust/src/bytes.rs delete mode 100644 rust/src/minswap_provider.rs delete mode 100644 rust/src/minwallet_backup.rs delete mode 100644 rust/src/public_key_hash.rs delete mode 100644 rust/src/tx_in.rs delete mode 100644 rust/src/tx_out.rs delete mode 100644 rust/src/utils.rs delete mode 100644 rust/src/utxo.rs delete mode 100644 rust/src/value.rs diff --git a/rust/a.json b/rust/a.json deleted file mode 100644 index 8354dcc..0000000 --- a/rust/a.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "data": [ - { - "tx_hash": "3b9242c898a7c1fa81547b47d5bc6f5e2c6b161a3fd389b1d8db4ecee86ac0c5", - "index": 0, - "slot": 76412221, - "assets": [ - { - "unit": "lovelace", - "amount": 10000000 - } - ], - "address": "addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt", - "datum": null, - "reference_script": null, - "txout_cbor": "82583900a79de6b2aec3119a422218e9f52cd880e73ec0b9bf47f7d1e68543ea8262d5e844dcc7e5e06b6b034a099c776b22475eef4300313d3a821c1a00989680" - } - ], - "last_updated": { - "timestamp": "2024-11-20 09:39:48", - "block_hash": "e1d2b1c16ae7c8552187dfdfe6707b4daa78eeaf5cf7f5ad7bc6b70f7879fdda", - "block_slot": 76412388 - }, - "next_cursor": null -} diff --git a/rust/a.sjon b/rust/a.sjon deleted file mode 100644 index 8354dcc..0000000 --- a/rust/a.sjon +++ /dev/null @@ -1,25 +0,0 @@ -{ - "data": [ - { - "tx_hash": "3b9242c898a7c1fa81547b47d5bc6f5e2c6b161a3fd389b1d8db4ecee86ac0c5", - "index": 0, - "slot": 76412221, - "assets": [ - { - "unit": "lovelace", - "amount": 10000000 - } - ], - "address": "addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt", - "datum": null, - "reference_script": null, - "txout_cbor": "82583900a79de6b2aec3119a422218e9f52cd880e73ec0b9bf47f7d1e68543ea8262d5e844dcc7e5e06b6b034a099c776b22475eef4300313d3a821c1a00989680" - } - ], - "last_updated": { - "timestamp": "2024-11-20 09:39:48", - "block_hash": "e1d2b1c16ae7c8552187dfdfe6707b4daa78eeaf5cf7f5ad7bc6b70f7879fdda", - "block_slot": 76412388 - }, - "next_cursor": null -} diff --git a/rust/src/asset.rs b/rust/src/asset.rs deleted file mode 100644 index 951dfef..0000000 --- a/rust/src/asset.rs +++ /dev/null @@ -1,34 +0,0 @@ -use lazy_static::lazy_static; - -use crate::bytes::Bytes; - -#[derive(Clone, PartialEq)] -pub struct Asset { - pub currency_symbol: Bytes, - pub token_name: Bytes, -} - -impl Asset { - pub fn new(currency_symbol: &Bytes, token_name: &Bytes) -> Self { - Self { - currency_symbol: currency_symbol.clone(), - token_name: token_name.clone(), - } - } - - pub fn to_string(&self) -> String { - if *self == *ADA { - return "lovelace".to_string(); - } - - if self.token_name.hex == "" { - return self.currency_symbol.hex.clone(); - } - - return format!("{}.{}", self.currency_symbol.hex, self.token_name.hex); - } -} - -lazy_static! { - pub static ref ADA: Asset = Asset::new(&Bytes::from_hex(""), &Bytes::from_hex("")); -} diff --git a/rust/src/bytes.rs b/rust/src/bytes.rs deleted file mode 100644 index 1d9f405..0000000 --- a/rust/src/bytes.rs +++ /dev/null @@ -1,18 +0,0 @@ -#[derive(Clone, PartialEq)] -pub struct Bytes { - pub bytes: Vec, - pub hex: String, -} - -impl Bytes { - pub fn new(bytes: &[u8]) -> Self { - Self { - bytes: bytes.to_vec(), - hex: hex::encode(bytes), - } - } - - pub fn from_hex(hex: &str) -> Self { - Self::new(&hex::decode(hex).unwrap()) - } -} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 6caef98..33b77a9 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,126 +1,6 @@ -use crate::network::{NetworkEnvironment, NetworkId}; -use crate::utils::harden; -use cardano_serialization_lib::Bip32PrivateKey; -use cardano_serialization_lib::{ - BaseAddress, Credential, EnterpriseAddress, RewardAddress - - - , -}; - pub mod wallet; -mod asset; -mod bytes; -mod minswap_provider; pub mod network; -pub mod public_key_hash; -mod tx_in; -mod tx_out; -pub mod utils; -mod utxo; -mod value; mod crypto; pub mod minwallet; -pub enum AddressType { - BaseAddress, - EnterpriseAddress, -} - -pub enum WalletType { - BaseWallet { - address: String, - reward_address: String, - payment_key: String, - stake_key: String, - }, - EnterpriseWallet { - address: String, - payment_key: String, - }, -} - -pub fn create_wallet( - mnemonic: &str, - password: &str, - account_index: u32, - address_type: AddressType, - network_environment: NetworkEnvironment, -) -> WalletType { - let network_id = NetworkId::from_network_environment(&network_environment) as u8; - let root_key = Bip32PrivateKey::from_bip39_entropy(mnemonic.as_bytes(), password.as_bytes()); - - let account_key = root_key - .derive(harden(1852)) - .derive(harden(1815)) - .derive(account_index); - - let payment_key = account_key.derive(0).derive(0).to_raw_key(); - - let payment_key_hash = payment_key.to_public().hash(); - - match address_type { - AddressType::BaseAddress => { - let stake_key = account_key.derive(2).derive(0).to_raw_key(); - let stake_key_hash = stake_key.to_public().hash(); - - let address = BaseAddress::new( - network_id, - &Credential::from_keyhash(&payment_key_hash), - &Credential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_bech32(None) - .unwrap(); - - let reward_address = - RewardAddress::new(network_id, &Credential::from_keyhash(&stake_key_hash)) - .to_address() - .to_bech32(None) - .unwrap(); - - WalletType::BaseWallet { - address, - reward_address, - payment_key: payment_key.to_bech32(), - stake_key: stake_key.to_bech32(), - } - } - AddressType::EnterpriseAddress => { - let address = EnterpriseAddress::new( - network_id, - &Credential::from_keyhash(&payment_key_hash), - ) - .to_address() - .to_bech32(None) - .unwrap(); - - WalletType::EnterpriseWallet { - address, - payment_key: payment_key.to_bech32(), - } - } - } -} - -// pub fn sign_tx(tx_raw: &str, keys: Vec) -> String { -// let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); -// let tx_body = tx.body(); -// let tx_hash = hash_transaction(&tx_body); -// -// let mut witness_set = TransactionWitnessSet::new(); -// let mut vkey_witnesses = Vkeywitnesses::new(); -// -// for key in keys { -// let pkey = PrivateKey::from_bech32(&key).unwrap(); -// let vkey = make_vkey_witness(&tx_hash, &pkey); -// vkey_witnesses.add(&vkey); -// } -// -// witness_set.set_vkeys(&vkey_witnesses); -// let signed_tx = witness_set.to_hex(); -// -// "".to_owned() -// } - uniffi::include_scaffolding!("mwrust"); diff --git a/rust/src/minswap_provider.rs b/rust/src/minswap_provider.rs deleted file mode 100644 index 72de492..0000000 --- a/rust/src/minswap_provider.rs +++ /dev/null @@ -1,23 +0,0 @@ -struct WalletEndpoints { - utxo_by_tx_in: &'static str, -} - -const WALLET_ENDPOINTS: WalletEndpoints = WalletEndpoints { - utxo_by_tx_in: "/wallet/utxo/tx-in", -}; - -struct MinswapProvider { - url: String, -} - -impl MinswapProvider { - fn make_post_call(&self, path: &str, body: &str) -> String { - let client = reqwest::blocking::Client::new(); - let res = client - .post(format!("{}/{}", self.url, path)) - .body(body.to_string()) - .send() - .unwrap(); - res.text().unwrap() - } -} diff --git a/rust/src/minwallet.rs b/rust/src/minwallet.rs index 797d94d..e8daaa5 100644 --- a/rust/src/minwallet.rs +++ b/rust/src/minwallet.rs @@ -1,9 +1,7 @@ use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; -use crate::wallet::emip3::encrypt_password; use cardano_serialization_lib::{Address, PrivateKey, RewardAddress}; - -const MINWALLET_VERSION: &str = "2.0.0"; +use uniffi::export; pub struct Minwallet { name: String, @@ -11,9 +9,7 @@ pub struct Minwallet { reward_address: RewardAddress, network_id: u8, encrypted_key: String, - version: String, account_index: u32, - wallet_name: String, } impl WalletStaticMethods for Minwallet {} @@ -51,8 +47,6 @@ impl Minwallet { network_id, account_index, encrypted_key, - version: MINWALLET_VERSION.to_string(), - wallet_name: wallet_name.to_string(), } } @@ -64,11 +58,25 @@ impl Minwallet { } } +// Uniffi needs this to expose the `MinWallet` struct and its methods. +uniffi::export!( + fn create_wallet( + name: String, + address: String, + reward_address: String, + network_id: u8, + encrypted_key: String, + account_index: u32, + ) -> MinWallet { + MinWallet::new(name, address, reward_address, network_id, encrypted_key, account_index) + } +); + #[cfg(test)] mod tests { use super::*; - use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitness, Vkeywitnesses}; use crate::crypto::blake2b256; + use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; #[test] fn test_get_private_key() { diff --git a/rust/src/minwallet_backup.rs b/rust/src/minwallet_backup.rs deleted file mode 100644 index 4d1ad9f..0000000 --- a/rust/src/minwallet_backup.rs +++ /dev/null @@ -1,290 +0,0 @@ -use std::collections::{HashMap, HashSet}; -use base64::prelude::*; -use bip39::Mnemonic; -use cardano_serialization_lib::{address::{BaseAddress, NetworkInfo, RewardAddress, StakeCredential}, crypto::{Bip32PrivateKey, Bip32PublicKey}, emip3::{decrypt_with_password, encrypt_with_password}, Transaction, utils}; -use rand::RngCore; - -use crate::{network::{NetworkEnvironment, NetworkId}, tx_in::TxIn}; -use crate::utils::harden; -use crate::public_key_hash::PublicKeyHash; - -const MINWALLET_VERSION: &str = "2.0.0"; - -#[derive(Debug)] -enum TransportType { - WEBUSB, - WEBHID, - WEBBLE, - BLE, -} - -impl TransportType { - pub fn to_string(&self) -> String { - match self { - TransportType::WEBUSB => "WebUSB".to_string(), - TransportType::WEBHID => "WebHID".to_string(), - TransportType::WEBBLE => "WebBluetooth".to_string(), - TransportType::BLE => "Bluetooth".to_string(), - } - } -} - -#[derive(Debug)] -pub struct Minwallet { - name: String, - base_address: HashMap, - reward_address: HashMap, - pub_key_hash_derive_map: HashMap>, - network_id: u8, - encrypted_key: String, - version: String, - account_index: u8, - wallet_name: String, - transport_type: Option, -} - -impl Minwallet { - pub fn new( - mnemonic: &str, - password: &str, - network_environment: NetworkEnvironment, - wallet_name: &str, - ) -> Self { - let entropy = Mnemonic::parse(mnemonic).unwrap().to_entropy(); - let root_key = Bip32PrivateKey::from_bip39_entropy(&entropy, &[]); - let encrypted_key = encrypt_password(password, &root_key.to_hex()); - let account_key = root_key - .derive(harden(1852)) - .derive(harden(1815)) - .derive(harden(0)); - let public_key = account_key.to_public(); - let network_id = network_environment.to_network_id() as u8; - - let base_address = generate_base_address(&public_key); - let reward_address = generate_reward_address(&public_key); - let pub_key_hash_derive_map = generate_addresses(&public_key); - - Minwallet { - name: "minwallet".to_string(), - base_address, - reward_address, - network_id, - account_index: 0, - transport_type: None, - encrypted_key, - pub_key_hash_derive_map, - version: MINWALLET_VERSION.to_string(), - wallet_name: wallet_name.to_string(), - } - } - - pub fn sign_tx(&self, raw_tx: &str) {} - - fn get_transaction_from_raw(&self, raw_tx: &str) { - let tx = Transaction::from_hex(raw_tx).unwrap(); - let tx_body = tx.body(); - let tx_hash = utils::hash_transaction(&tx_body); - let tx_id = tx_hash.to_hex(); - let tx_size = tx.to_bytes().len(); - let fee = tx_body.fee(); - - let witness_set = tx.witness_set(); - let vkey_witnesses = witness_set.vkeys(); - let mut signed_pub_key_hashes = HashSet::new(); - - if let Some(vkey_witnesses) = vkey_witnesses { - for i in 0..vkey_witnesses.len() { - let vkey_witness = vkey_witnesses.get(i); - let key = vkey_witness.vkey(); - let pub_key = key.public_key(); - let pub_key_hash = pub_key.hash(); - signed_pub_key_hashes.insert(pub_key_hash.to_hex()); - } - } - - let tx_ins = TxIn::get_inputs_from_tx_raw(raw_tx); - let tx_collateral_ins = match TxIn::get_collateral_from_tx_raw(raw_tx) { - Some(data) => data, - None => vec![] - }; - let mut public_key_hashes = HashSet::new(); - - for tx_in in tx_ins { - - } - - - //missing_signatures -> keyHash - let missing_signatures = vec![]; - for signature in signed_pub_key_hashes { - let pkh = PublicKeyHash::new(signature); - if !signed_pub_key_hashes - } - } -} - - -fn generate_addresses(public_key: &Bip32PublicKey) -> HashMap> { - let mut pub_key_hash_derive_map = HashMap::new(); - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - pub_key_hash_derive_map.insert(stake_key_hash.to_hex(), vec![2, 0]); - - for i in 0..1000 { - let receving_pub_key_hash = public_key - .derive(0) - .unwrap() - .derive(i) - .unwrap() - .to_raw_key() - .hash(); - let change_pub_key_hash = public_key - .derive(1) - .unwrap() - .derive(i) - .unwrap() - .to_raw_key() - .hash(); - - pub_key_hash_derive_map.insert(receving_pub_key_hash.to_hex(), vec![0, i]); - pub_key_hash_derive_map.insert(change_pub_key_hash.to_hex(), vec![1, i]); - } - - pub_key_hash_derive_map -} - -fn generate_reward_address(public_key: &Bip32PublicKey) -> HashMap { - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let mut reward_address = HashMap::new(); - - reward_address.insert( - NetworkId::Mainnet as u8, - RewardAddress::new( - NetworkInfo::mainnet().network_id(), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - reward_address.insert( - NetworkId::Testnet as u8, - RewardAddress::new( - NetworkInfo::testnet_preprod().network_id(), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - reward_address -} - -fn generate_base_address(public_key: &Bip32PublicKey) -> HashMap { - let payment_key_hash = public_key - .derive(0) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let stake_key_hash = public_key - .derive(2) - .unwrap() - .derive(0) - .unwrap() - .to_raw_key() - .hash(); - let mut base_address = HashMap::new(); - - base_address.insert( - NetworkId::Mainnet as u8, - BaseAddress::new( - NetworkInfo::mainnet().network_id(), - &StakeCredential::from_keyhash(&payment_key_hash), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - base_address.insert( - NetworkId::Testnet as u8, - BaseAddress::new( - NetworkInfo::testnet_preprod().network_id(), - &StakeCredential::from_keyhash(&payment_key_hash), - &StakeCredential::from_keyhash(&stake_key_hash), - ) - .to_address() - .to_hex(), - ); - - base_address -} - -fn generate_secure_string(length: usize) -> String { - let mut bytes = vec![0u8; length]; - rand::thread_rng().fill_bytes(&mut bytes); - - // Use base64 for a compact and URL-safe representation - let mut encoded = BASE64_STANDARD.encode(bytes); - encoded.truncate(length); - encoded -} - -fn encrypt_password(password: &str, root_key_hex: &str) -> String { - let password_hex = hex::encode(password); - let salt = hex::encode(generate_secure_string(32)); - let nonce = hex::encode(generate_secure_string(12)); - encrypt_with_password(&password_hex, &salt, &nonce, root_key_hex).unwrap() -} - -fn decrypt_password(password: &str, encrypted_hex: &str) -> String { - let password_hex = hex::encode(password); - decrypt_with_password(&password_hex, encrypted_hex).unwrap() -} - -#[cfg(test)] -mod tests { - use super::{decrypt_password, encrypt_password, generate_secure_string, Minwallet}; - use crate::bip39::generate_mnemonic; - use crate::network::NetworkEnvironment; - - #[test] - fn can_generate_secure_string_with_length() { - let result = generate_secure_string(64); - assert_eq!(result.bytes().len(), 64); - } - - #[test] - fn can_encrypt_and_decrypt_password() { - let password = "MyPassword@@"; - let data = "aqu23oi45ufdgsaiklojug8oasdff"; - let data_hex = hex::encode(data); - let encrypted_hex = encrypt_password(&password, &data_hex); - let decrypted_hex = decrypt_password(&password, &encrypted_hex); - assert_eq!(decrypted_hex, data_hex); - } - - #[test] - fn can_create_new_minwallet() { - let mnemonic = generate_mnemonic(); - let password = "MyPassword@@"; - let network_environment = NetworkEnvironment::TestnetPreprod; - let wallet_name = "W01"; - let wallet = Minwallet::new(&mnemonic, password, network_environment, wallet_name); - println!("{:#?}", wallet); - assert_eq!(1, 1); - } -} diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 3b50fff..3a93676 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,20 +1,21 @@ namespace mwrust { - WalletType create_wallet([ByRef] string mnemonic, [ByRef] string password, u32 account_index, AddressType address_type, NetworkEnvironment network_environment); -}; - -enum NetworkEnvironment { - "Mainnet", - "TestnetPreprod", - "TestnetPreview", -}; - -enum AddressType { - "BaseAddress", - "EnterpriseAddress", -}; + record MinWallet { + string name; + string address; + string reward_address; + uint8 network_id; + string encrypted_key; + uint32 account_index; + } -[Enum] -interface WalletType { - BaseWallet(string address, string reward_address, string payment_key, string stake_key); - EnterpriseWallet(string address, string payment_key); + interface WalletStaticMethods { + MinWallet create_wallet( + string name, + string address, + string reward_address, + uint8 network_id, + string encrypted_key, + uint32 account_index + ); + } }; diff --git a/rust/src/public_key_hash.rs b/rust/src/public_key_hash.rs deleted file mode 100644 index 15eb459..0000000 --- a/rust/src/public_key_hash.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub struct PublicKeyHash { - pub key_hash: String, -} - -impl PublicKeyHash { - pub fn new(key_hash: String) -> Self { - if key_hash.as_bytes().len() != 28 { - panic!("Invalid key hash length") - } - PublicKeyHash { key_hash } - } -} diff --git a/rust/src/tx_in.rs b/rust/src/tx_in.rs deleted file mode 100644 index eb4bc2f..0000000 --- a/rust/src/tx_in.rs +++ /dev/null @@ -1,49 +0,0 @@ -use cardano_serialization_lib::{Transaction, TransactionInput}; - -pub struct TxIn { - pub tx_id: Vec, - pub index: u32, -} - -impl TxIn { - pub fn get_inputs_from_tx_raw(tx_raw: &str) -> Vec { - let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); - let tx_body = tx.body(); - let inputs = tx_body.inputs(); - let mut tx_ins = Vec::new(); - for i in 0..inputs.len() { - let input = inputs.get(i); - tx_ins.push(Self::from_hex(&input.to_hex())); - } - - tx_ins - } - - pub fn get_collateral_from_tx_raw(tx_raw: &str) -> Option> { - let tx = Transaction::from_bytes(tx_raw.as_bytes().to_vec()).unwrap(); - let tx_body = tx.body(); - let collateral = tx_body.collateral(); - - match collateral { - Some(collateral) => { - let mut tx_ins = Vec::new(); - for i in 0..collateral.len() { - let input = collateral.get(i); - tx_ins.push(Self::from_hex(&input.to_hex())); - } - - Some(tx_ins) - } - None => None, - } - } - - pub fn from_hex(input: &str) -> Self { - let transaction_input = TransactionInput::from_hex(input).unwrap(); - let transaction_hash = transaction_input.transaction_id(); - Self { - tx_id: transaction_hash.to_bytes(), - index: transaction_input.index(), - } - } -} diff --git a/rust/src/tx_out.rs b/rust/src/tx_out.rs deleted file mode 100644 index 7c9130d..0000000 --- a/rust/src/tx_out.rs +++ /dev/null @@ -1,51 +0,0 @@ -use cardano_serialization_lib::{Address, Value, TransactionOutput}; - -pub enum DatumSource { - DatumHash { hash: Vec }, - InlineDatum { data: Vec }, -} - -pub struct TxOut { - pub address: Address, - pub value: Value, - pub datum_source: Option, - pub script_ref: Option>, -} - -impl TxOut { - pub fn from_hex(out: &str) -> Self { - let transaction_output = TransactionOutput::from_hex(out).unwrap(); - - let address = transaction_output.address(); - let value = transaction_output.amount(); - let datum_hash = transaction_output.data_hash(); - let plutus_data = transaction_output.plutus_data(); - - let mut datum_source: Option = None; - if let Some(plutus_data) = plutus_data { - datum_source = Some(DatumSource::InlineDatum { - data: plutus_data.to_bytes(), - }); - } else if let Some(datum_hash) = datum_hash { - datum_source = Some(DatumSource::DatumHash { - hash: datum_hash.to_bytes(), - }) - } - - let script_ref = transaction_output.script_ref(); - let plutus_script = match script_ref { - None => None, - Some(script_ref) => Some(script_ref.plutus_script()), - }; - Self { - address, - value, - datum_source, - script_ref: match plutus_script { - None => None, - Some(None) => None, - Some(Some(plutus_script)) => Some(plutus_script.to_bytes()), - }, - } - } -} diff --git a/rust/src/utils.rs b/rust/src/utils.rs deleted file mode 100644 index 3ed285d..0000000 --- a/rust/src/utils.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn harden(index: u32) -> u32 { - 0x80000000 + index -} diff --git a/rust/src/utxo.rs b/rust/src/utxo.rs deleted file mode 100644 index 1e2be1a..0000000 --- a/rust/src/utxo.rs +++ /dev/null @@ -1,20 +0,0 @@ -use cardano_serialization_lib::TransactionUnspentOutput; - -use crate::{tx_in::TxIn, tx_out::TxOut}; - -pub struct Utxo { - pub input: TxIn, - pub output: TxOut, -} - -impl Utxo { - pub fn from_hex(value: &str) -> Self { - let cls_utxo = TransactionUnspentOutput::from_hex(value).unwrap(); - let input = cls_utxo.input(); - let output = cls_utxo.output(); - Self { - input: TxIn::from_hex(&input.to_hex()), - output: TxOut::from_hex(&output.to_hex()), - } - } -} diff --git a/rust/src/value.rs b/rust/src/value.rs deleted file mode 100644 index 1b3bbde..0000000 --- a/rust/src/value.rs +++ /dev/null @@ -1,66 +0,0 @@ -use std::collections::HashMap; - -use cardano_serialization_lib::Value as CSLValue; - -use crate::asset::{Asset, ADA}; -use crate::bytes::Bytes; - -#[derive(Clone)] -pub struct Value { - pub map: HashMap, -} - -impl Value { - pub fn new(map: Option>) -> Self { - match map { - Some(map) => Self { map }, - None => Self { - map: HashMap::new(), - }, - } - } - - fn init_if_not_exists(&mut self, a: &Asset) { - if !self.map.contains_key(&a.to_string()) { - self.map.insert(a.to_string(), 0); - } - } - - pub fn add(&mut self, a: &Asset, x: u64) -> &mut Self { - if x == 0 { - return self; - } - - self.init_if_not_exists(a); - self.map - .insert(a.to_string(), self.map.get(&a.to_string()).unwrap() + 1); - - self - } - - pub fn from_hex(value: &str) -> Self { - let value = CSLValue::from_hex(value).unwrap(); - let coin = value.coin(); - let mut initialzed_value = Value::new(None); - let ret = initialzed_value.add(&ADA.to_owned(), coin.try_into().unwrap()); - let ma = value.multiasset(); - if let Some(ma) = ma { - for i in 0..ma.keys().len() { - let currency_symbol = ma.keys().get(i); - let assets = ma.get(¤cy_symbol).unwrap(); - - for j in 0..assets.keys().len() { - let token_name = assets.keys().get(j); - let amount = assets.get(&token_name).unwrap(); - let asset = Asset::new( - &Bytes::from_hex(¤cy_symbol.to_hex()), - &Bytes::from_hex(&token_name.to_hex()), - ); - ret.add(&asset, amount.try_into().unwrap()); - } - } - } - - ret.to_owned() - } -} diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 2538e70..1855724 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -1,11 +1,15 @@ use bip39::{Language, Mnemonic}; use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credential, RewardAddress}; -use crate::utils::harden; use crate::wallet::emip3::{decrypt_password, encrypt_password}; pub struct Account {} + +fn harden(index: u32) -> u32 { + index | 0x80_00_00_00 +} + pub trait WalletStaticMethods { fn mnemonic_to_entropy(phrase: &str) -> Vec { let mnemonic = Mnemonic::from_phrase(&phrase, Language::English).unwrap(); @@ -18,10 +22,6 @@ pub trait WalletStaticMethods { password.as_bytes() ) } - - fn harden(index: u32) -> u32 { - index | 0x80_00_00_00 - } fn get_account(root_key: &Bip32PrivateKey, index: u32) -> Bip32PrivateKey { root_key From 01ca96db20c94e958518cc7a79523e304189257f Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 14:56:20 +0700 Subject: [PATCH 07/32] tes build --- rust/build.sh | 1 - rust/src/lib.rs | 12 ++++++++---- rust/src/mwrust.udl | 20 +------------------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/rust/build.sh b/rust/build.sh index 4a1e749..99985ea 100755 --- a/rust/build.sh +++ b/rust/build.sh @@ -4,7 +4,6 @@ cargo check cargo build --release -rm -rf bindings cargo run --bin uniffi-bindgen generate --library ./target/release/libmwrust.dylib --language swift --out-dir ./bindings mv ./bindings/mwrustFFI.modulemap ./bindings/module.modulemap diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 33b77a9..69bfdd7 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,6 +1,10 @@ -pub mod wallet; -pub mod network; -mod crypto; -pub mod minwallet; +// pub mod wallet; +// pub mod network; +// mod crypto; +// pub mod minwallet; + +fn add(a: u32, b: u32) -> u32 { + a + b +} uniffi::include_scaffolding!("mwrust"); diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 3a93676..2bb906a 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,21 +1,3 @@ namespace mwrust { - record MinWallet { - string name; - string address; - string reward_address; - uint8 network_id; - string encrypted_key; - uint32 account_index; - } - - interface WalletStaticMethods { - MinWallet create_wallet( - string name, - string address, - string reward_address, - uint8 network_id, - string encrypted_key, - uint32 account_index - ); - } + u32 add(u32 a, u32 b); }; From f4c9473ce42ea1b55169e96ab02aedaa09132115 Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 15:07:31 +0700 Subject: [PATCH 08/32] remove min wallet --- rust/src/lib.rs | 97 +++++++++++++++++++++++++++++++--- rust/src/minwallet.rs | 111 --------------------------------------- rust/src/mwrust.udl | 8 ++- rust/src/wallet/emip3.rs | 1 - 4 files changed, 98 insertions(+), 119 deletions(-) delete mode 100644 rust/src/minwallet.rs diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 69bfdd7..ab717c9 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,10 +1,95 @@ -// pub mod wallet; -// pub mod network; -// mod crypto; -// pub mod minwallet; +mod crypto; +mod wallet; +pub mod network; +use crate::network::NetworkEnvironment; +use crate::wallet::embedded::WalletStaticMethods; +use cardano_serialization_lib::PrivateKey; -fn add(a: u32, b: u32) -> u32 { - a + b +pub struct MinWallet { + address: String, + network_id: u8, + encrypted_key: String, + account_index: u32, +} + +impl WalletStaticMethods for MinWallet {} + +impl MinWallet { + pub fn create( + mnemonic: &str, + password: &str, + network_environment: NetworkEnvironment, + ) -> Self { + let account_index = 0; + + // Convert mnemonic to entropy + let entropy = MinWallet::mnemonic_to_entropy(&mnemonic); + + // Derive root key and account key + let root_key = MinWallet::entropy_to_root_key(&entropy, &password); + let account_key = MinWallet::get_account(&root_key, account_index); + + // Encrypt root key with password + let encrypted_key = MinWallet::gen_encrypted_key(password, &root_key); + + // Derive network ID + let network_id = network_environment.to_network_id() as u8; + + // Generate addresses + let address = MinWallet::get_address(&account_key, network_id); + + MinWallet { + address: address.to_hex(), + network_id, + account_index, + encrypted_key, + } + } + + pub fn get_private_key(&self, password: &str, account_index: u32) -> PrivateKey { + let root_key = MinWallet::get_root_key_from_password(&password, &self.encrypted_key); + let account_key = MinWallet::get_account(&root_key, account_index); + let payment_key = account_key.derive(0).derive(0).to_raw_key(); + PrivateKey::from_bech32(payment_key.to_bech32().as_ref()).unwrap() + } } uniffi::include_scaffolding!("mwrust"); + +#[cfg(test)] +mod tests { + use super::*; + use crate::crypto::blake2b256; + use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; + + #[test] + fn test_get_private_key() { + let password = "Minswap@123456"; + let min_wallet = MinWallet::create( + "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", + &password, + network::NetworkEnvironment::TestnetPreprod, + ); + let private_key = min_wallet.get_private_key(&password, 0); + assert_eq!(private_key.to_hex(), String::from("f838ddcb280f7c89bf5480591a0b46b2b80602134b19179a61c1991d7639ab549009491d6b359c37f03af6422af350e2e041ecde02a734a4b9dae5a6f7a1bf69")); + } + + #[test] + fn test_happy_path() { + let password = "Minswap@123456"; + let min_wallet = MinWallet::create( + "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", + &password, + NetworkEnvironment::TestnetPreprod, + ); + let tx_raw = "84a40081825820dee6b0848594bea01d61450e47827da762947f61ad2387ccf1f8ba629b5252d4020182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a1d16ce6d021a0002917d031a048f683ca0f5f6"; + let tx = Transaction::from_hex(tx_raw).unwrap(); + let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); + let mut witness_set = TransactionWitnessSet::new(); + let mut v_key_witness = Vkeywitnesses::new(); + let private_key = min_wallet.get_private_key(&password, 0); + let v_key = make_vkey_witness(&tx_hash, &private_key); + v_key_witness.add(&v_key); + witness_set.set_vkeys(&v_key_witness); + } +} diff --git a/rust/src/minwallet.rs b/rust/src/minwallet.rs deleted file mode 100644 index e8daaa5..0000000 --- a/rust/src/minwallet.rs +++ /dev/null @@ -1,111 +0,0 @@ -use crate::network::NetworkEnvironment; -use crate::wallet::embedded::WalletStaticMethods; -use cardano_serialization_lib::{Address, PrivateKey, RewardAddress}; -use uniffi::export; - -pub struct Minwallet { - name: String, - address: Address, - reward_address: RewardAddress, - network_id: u8, - encrypted_key: String, - account_index: u32, -} - -impl WalletStaticMethods for Minwallet {} - -impl Minwallet { - pub fn create( - mnemonic: &str, - password: &str, - network_environment: NetworkEnvironment, - wallet_name: &str, - ) -> Self { - let account_index = 0; - - // Convert mnemonic to entropy - let entropy = Minwallet::mnemonic_to_entropy(&mnemonic); - - // Derive root key and account key - let root_key = Minwallet::entropy_to_root_key(&entropy, &password); - let account_key = Minwallet::get_account(&root_key, account_index); - - // Encrypt root key with password - let encrypted_key = Minwallet::gen_encrypted_key(password, &root_key); - - // Derive network ID - let network_id = network_environment.to_network_id() as u8; - - // Generate addresses - let address = Minwallet::get_address(&account_key, network_id); - let reward_address = Minwallet::gen_reward_address(&account_key, network_id); - - Minwallet { - name: "minwallet".to_string(), - address, - reward_address, - network_id, - account_index, - encrypted_key, - } - } - - pub fn get_private_key(&self, password: &str, account_index: u32) -> PrivateKey { - let root_key = Minwallet::get_root_key_from_password(&password, &self.encrypted_key); - let account_key = Minwallet::get_account(&root_key, account_index); - let payment_key = account_key.derive(0).derive(0).to_raw_key(); - PrivateKey::from_bech32(payment_key.to_bech32().as_ref()).unwrap() - } -} - -// Uniffi needs this to expose the `MinWallet` struct and its methods. -uniffi::export!( - fn create_wallet( - name: String, - address: String, - reward_address: String, - network_id: u8, - encrypted_key: String, - account_index: u32, - ) -> MinWallet { - MinWallet::new(name, address, reward_address, network_id, encrypted_key, account_index) - } -); - -#[cfg(test)] -mod tests { - use super::*; - use crate::crypto::blake2b256; - use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; - - #[test] - fn test_get_private_key() { - let password = "Minswap@123456"; - let min_wallet = Minwallet::create( - "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", - &password, - NetworkEnvironment::TestnetPreprod, "Tony" - ); - let private_key = min_wallet.get_private_key(&password, 0); - assert_eq!(private_key.to_hex(), String::from("f838ddcb280f7c89bf5480591a0b46b2b80602134b19179a61c1991d7639ab549009491d6b359c37f03af6422af350e2e041ecde02a734a4b9dae5a6f7a1bf69")); - } - - #[test] - fn test_happy_path() { - let password = "Minswap@123456"; - let min_wallet = Minwallet::create( - "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", - &password, - NetworkEnvironment::TestnetPreprod, "Tony" - ); - let tx_raw = "84a40081825820dee6b0848594bea01d61450e47827da762947f61ad2387ccf1f8ba629b5252d4020182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a1d16ce6d021a0002917d031a048f683ca0f5f6"; - let tx = Transaction::from_hex(tx_raw).unwrap(); - let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); - let mut witness_set = TransactionWitnessSet::new(); - let mut v_key_witness = Vkeywitnesses::new(); - let private_key = min_wallet.get_private_key(&password, 0); - let v_key = make_vkey_witness(&tx_hash, &private_key); - v_key_witness.add(&v_key); - witness_set.set_vkeys(&v_key_witness); - } -} diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 2bb906a..2f25567 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,3 +1,9 @@ namespace mwrust { - u32 add(u32 a, u32 b); +}; + +dictionary MinWallet { + string address; + u8 network_id; + string encrypted_key; + u32 account_index; }; diff --git a/rust/src/wallet/emip3.rs b/rust/src/wallet/emip3.rs index 3ea6770..da64da0 100644 --- a/rust/src/wallet/emip3.rs +++ b/rust/src/wallet/emip3.rs @@ -1,5 +1,4 @@ use cardano_serialization_lib::{decrypt_with_password, encrypt_with_password}; -use hex::ToHex; use rand::Rng; mod password_encryption_parameter { From 7f74d3c6946d0603cb6302ba788e613f2e400e74 Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 15:12:30 +0700 Subject: [PATCH 09/32] empty trash --- rust/Cargo.lock | 1398 +++-------------------------------- rust/Cargo.toml | 6 - rust/src/crypto.rs | 6 - rust/src/wallet/embedded.rs | 3 - rust/src/wallet/emip3.rs | 13 - rust/src/wallet/maestro.rs | 317 -------- rust/src/wallet/mod.rs | 1 - 7 files changed, 122 insertions(+), 1622 deletions(-) delete mode 100644 rust/src/wallet/maestro.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index f06ef5f..d1ee171 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2,21 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" - [[package]] name = "ahash" version = "0.8.11" @@ -65,7 +50,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -75,7 +60,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -131,33 +116,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" -[[package]] -name = "backtrace" -version = "0.3.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "basic-toml" version = "0.1.9" @@ -188,12 +146,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - [[package]] name = "block-buffer" version = "0.9.0" @@ -372,7 +324,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -381,27 +333,11 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -442,17 +378,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "dyn-clone" version = "1.0.17" @@ -474,67 +399,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "fs-err" version = "2.11.0" @@ -550,54 +414,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-core", - "futures-io", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -621,12 +437,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - [[package]] name = "glob" version = "0.3.1" @@ -644,25 +454,6 @@ dependencies = [ "scroll", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -672,19 +463,13 @@ dependencies = [ "ahash", ] -[[package]] -name = "hashbrown" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" - [[package]] name = "hashlink" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "hashbrown 0.14.5", + "hashbrown", ] [[package]] @@ -693,12 +478,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hex" version = "0.4.3" @@ -715,188 +494,141 @@ dependencies = [ ] [[package]] -name = "http" -version = "0.2.12" +name = "is_terminal_polyfill" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] -name = "http-body" -version = "0.4.6" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "bytes", - "http", - "pin-project-lite", + "either", ] [[package]] -name = "httparse" -version = "1.9.5" +name = "itoa" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] -name = "httpdate" -version = "1.0.3" +name = "js-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] [[package]] -name = "hyper" -version = "0.14.31" +name = "libc" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "log" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] -name = "icu_collections" -version = "1.5.0" +name = "memchr" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "icu_locid" -version = "1.5.0" +name = "mime" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "icu_locid_transform" -version = "1.5.0" +name = "mime_guess" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", + "mime", + "unicase", ] [[package]] -name = "icu_locid_transform_data" -version = "1.5.0" +name = "minimal-lexical" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "icu_normalizer" -version = "1.5.0" +name = "mwrust" +version = "0.1.0" +dependencies = [ + "cardano-serialization-lib", + "cryptoxide", + "hex", + "rand", + "tiny-bip39", + "uniffi", +] + +[[package]] +name = "nom" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", + "memchr", + "minimal-lexical", ] [[package]] -name = "icu_normalizer_data" -version = "1.5.0" +name = "noop_proc_macro" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" [[package]] -name = "icu_properties" -version = "1.5.1" +name = "num" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", ] [[package]] -name = "icu_properties_data" -version = "1.5.0" +name = "num-bigint" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] [[package]] -name = "icu_provider" -version = "1.5.0" +name = "num-complex" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", + "num-traits", ] [[package]] -name = "icu_provider_macros" -version = "1.5.0" +name = "num-derive" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", @@ -904,304 +636,44 @@ dependencies = [ ] [[package]] -name = "idna" -version = "1.0.3" +name = "num-integer" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", + "num-traits", ] [[package]] -name = "idna_adapter" -version = "1.2.0" +name = "num-iter" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ - "icu_normalizer", - "icu_properties", + "autocfg", + "num-integer", + "num-traits", ] [[package]] -name = "indexmap" -version = "2.6.0" +name = "num-rational" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "equivalent", - "hashbrown 0.15.1", + "num-bigint", + "num-integer", + "num-traits", ] [[package]] -name = "ipnet" -version = "2.10.1" +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.164" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" - -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" - -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "mime_guess" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" -dependencies = [ - "mime", - "unicase", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" -dependencies = [ - "adler2", -] - -[[package]] -name = "mio" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" -dependencies = [ - "hermit-abi", - "libc", - "wasi", - "windows-sys 0.52.0", -] - -[[package]] -name = "mwrust" -version = "0.1.0" -dependencies = [ - "base64 0.22.1", - "cardano-serialization-lib", - "cryptoxide", - "hex", - "lazy_static", - "rand", - "reqwest", - "serde", - "serde_json", - "tiny-bip39", - "tokio", - "uniffi", -] - -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "noop_proc_macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "num-integer" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.36.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" -dependencies = [ - "memchr", -] +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] [[package]] name = "once_cell" @@ -1215,73 +687,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl" -version = "0.10.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.6", -] - [[package]] name = "paste" version = "1.0.15" @@ -1298,30 +703,6 @@ dependencies = [ "hmac", ] -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pin-project-lite" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" - [[package]] name = "plain" version = "0.2.3" @@ -1339,9 +720,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e1ced3fe749df87a909c23e9607ab9a09c8f0bedb7e03b8146f4c08c298673" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -1424,104 +805,18 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "redox_syscall" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" -dependencies = [ - "bitflags 2.6.0", -] - -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustix" -version = "0.38.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" -dependencies = [ - "bitflags 2.6.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "schemars" version = "0.8.21" @@ -1546,12 +841,6 @@ dependencies = [ "syn", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "scroll" version = "0.12.0" @@ -1567,32 +856,9 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags 2.6.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" -dependencies = [ - "core-foundation-sys", - "libc", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1658,18 +924,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha2" version = "0.9.9" @@ -1700,58 +954,18 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signal-hook-registry" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] - [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - [[package]] name = "smawk" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" -[[package]] -name = "socket2" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" -dependencies = [ - "libc", - "windows-sys 0.52.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" @@ -1772,66 +986,15 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.88" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e9a4e1639f47f655bf8e5198232f05615d5fb7e864ef5c4f5abdaf8ad3b8f4" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" -dependencies = [ - "cfg-if", - "fastrand", - "once_cell", - "rustix", - "windows-sys 0.59.0", -] - [[package]] name = "textwrap" version = "0.16.1" @@ -1878,16 +1041,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" version = "1.8.0" @@ -1903,58 +1056,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "tokio" -version = "1.41.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.52.0", -] - -[[package]] -name = "tokio-macros" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - [[package]] name = "toml" version = "0.5.11" @@ -1964,37 +1065,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.17.0" @@ -2152,56 +1222,18 @@ dependencies = [ "weedle2", ] -[[package]] -name = "url" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2233,18 +1265,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.92" @@ -2274,16 +1294,6 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "weedle2" version = "5.0.0" @@ -2315,46 +1325,13 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -2363,46 +1340,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -2415,100 +1374,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.7.35" @@ -2530,27 +1419,6 @@ dependencies = [ "syn", ] -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - [[package]] name = "zeroize" version = "1.8.1" @@ -2570,25 +1438,3 @@ dependencies = [ "quote", "syn", ] - -[[package]] -name = "zerovec" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d5d270d..25896d2 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -4,18 +4,12 @@ version = "0.1.0" edition = "2021" [dependencies] -base64 = "0.22.1" tiny-bip39 = "2.0.0" cardano-serialization-lib = "13.2.0" hex = "0.4.3" -lazy_static = "1.5.0" rand = "0.8.5" -reqwest = { version = "0.11.27", features = ["json", "blocking"] } -serde = { version = "1.0.213", features = ["derive"] } -serde_json = "1.0.132" uniffi = { version = "0.28.2", features = ["cli"] } cryptoxide = "0.4.4" -tokio = { version = "1.41.1", features = ["full"] } [build-dependencies] uniffi = { version = "0.28.2", features = ["build"] } diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs index ae27052..574f5dd 100644 --- a/rust/src/crypto.rs +++ b/rust/src/crypto.rs @@ -1,11 +1,5 @@ use cryptoxide::blake2b::Blake2b; -pub(crate) fn blake2b224(data: &[u8]) -> [u8; 28] { - let mut out = [0; 28]; - Blake2b::blake2b(&mut out, data, &[]); - out -} - pub(crate) fn blake2b256(data: &[u8]) -> [u8; 32] { let mut out = [0; 32]; Blake2b::blake2b(&mut out, data, &[]); diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 1855724..2134b6b 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -3,9 +3,6 @@ use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credentia use crate::wallet::emip3::{decrypt_password, encrypt_password}; -pub struct Account {} - - fn harden(index: u32) -> u32 { index | 0x80_00_00_00 } diff --git a/rust/src/wallet/emip3.rs b/rust/src/wallet/emip3.rs index da64da0..c8e1ed5 100644 --- a/rust/src/wallet/emip3.rs +++ b/rust/src/wallet/emip3.rs @@ -2,21 +2,8 @@ use cardano_serialization_lib::{decrypt_with_password, encrypt_with_password}; use rand::Rng; mod password_encryption_parameter { - pub const ITER: u32 = 19_162; pub const SALT_SIZE: usize = 32; pub const NONCE_SIZE: usize = 12; - pub const KEY_SIZE: usize = 32; - pub const TAG_SIZE: usize = 16; - - pub const METADATA_SIZE: usize = SALT_SIZE + NONCE_SIZE + TAG_SIZE; - - pub const SALT_START: usize = 0; - pub const SALT_END: usize = SALT_START + SALT_SIZE; - pub const NONCE_START: usize = SALT_END; - pub const NONCE_END: usize = NONCE_START + NONCE_SIZE; - pub const TAG_START: usize = NONCE_END; - pub const TAG_END: usize = TAG_START + TAG_SIZE; - pub const ENCRYPTED_START: usize = TAG_END; } /// Generates a random value of the given size in hexadecimal format diff --git a/rust/src/wallet/maestro.rs b/rust/src/wallet/maestro.rs deleted file mode 100644 index 7c55bb6..0000000 --- a/rust/src/wallet/maestro.rs +++ /dev/null @@ -1,317 +0,0 @@ -use std::collections::HashMap; -use std::error::Error; - -use cardano_serialization_lib::Address; -use cardano_serialization_lib::TransactionHash; -use cardano_serialization_lib::TransactionInput; -use cardano_serialization_lib::TransactionOutput; -use cardano_serialization_lib::TransactionUnspentOutput; -use cardano_serialization_lib::TransactionUnspentOutputs; -use reqwest::RequestBuilder; -use serde::Deserialize; -use serde::Serialize; - -#[derive(Deserialize, Debug, Clone)] -pub struct ClientConfig { - pub version: String, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct Config { - pub client: ClientConfig, -} - -impl Config { - pub fn get_config() -> Config { - Config { - client: ClientConfig { - version: "v1".to_string(), - }, - } - } -} - -pub struct Maestro { - api_key: String, - http_client: reqwest::Client, - pub base_url: String, -} - -impl Maestro { - pub fn new(api_key: String, network: String) -> Self { - let cfg = Config::get_config(); - let base_url = format!( - "https://{}.gomaestro-api.org/{}", - &network, &cfg.client.version - ); - let http_client = reqwest::Client::builder() - .timeout(std::time::Duration::from_secs(300)) - .build() - .expect("Failed to create HTTP client"); - - Maestro { - api_key, - http_client, - base_url, - } - } - - async fn send_request( - &self, - req: RequestBuilder, - response_body: &mut String, - ) -> Result<(), Box> { - let req = req - .header("Accept", "application/json") - .header("api-key", &self.api_key) - .build()?; - - let response = self.http_client.execute(req).await?; - - if response.status().is_success() { - *response_body = response.text().await?; - Ok(()) - } else { - Err(format!("Error: {}", response.status()).into()) - } - } - - pub async fn get(&self, url: &str) -> Result> { - let req = self.http_client.get(format!("{}{}", &self.base_url, url)); - let mut response_body = String::new(); - self.send_request(req, &mut response_body).await?; - Ok(response_body) - } - - pub async fn post( - &self, - url: &str, - body: T, - ) -> Result> { - let json_body = serde_json::to_string(&body)?; - - let req = self - .http_client - .post(format!("{}{}", &self.base_url, url)) - .header("Content-Type", "application/json") - .body(json_body); - - let mut response_body = String::new(); - self.send_request(req, &mut response_body).await?; - Ok(response_body) - } -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct OperationalCertificate { - pub hot_vkey: String, - pub sequence_number: i64, - pub kes_period: i64, - pub kes_signature: String, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct LastUpdated { - timestamp: String, - block_hash: String, - block_slot: i64, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct TotalExUnits { - pub mem: i64, - pub steps: i64, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct LatestBlockData { - pub hash: String, - pub height: i64, - pub timestamp: String, - pub epoch: i64, - pub epoch_slot: i64, - pub absolute_slot: i64, - pub block_producer: String, - pub confirmations: i64, - pub tx_hashes: Vec, - pub total_fees: i64, - pub total_ex_units: TotalExUnits, - pub script_invocations: i32, - pub size: i32, - pub previous_block: String, - pub next_block: Option, - pub total_output_lovelace: String, - pub era: String, - pub protocol_version: Vec, - pub vrf_key: String, - pub operational_certificate: OperationalCertificate, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct Asset { - pub amount: i64, - pub unit: String, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct ReferenceScript { - pub bytes: String, - pub hash: String, - pub json: Option>, - pub r#type: String, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct MaestroUtxo { - pub address: String, - pub assets: Vec, - pub datum: Option>, - pub index: i64, - pub reference_script: Option, - pub tx_hash: String, - #[serde(alias = "txout_cbor")] - pub tx_out_cbor: String, - pub slot: Option, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct WrapperData { - pub data: T, - pub last_updated: Option, - pub next_cursor: Option, -} - -impl Maestro { - pub async fn get_latest_block(&self) -> Result> { - let url = String::from("/blocks/latest"); - let response = self.get(&url).await?; - - // Deserialize into the generic wrapper - let wrapper: WrapperData = - serde_json::from_str(&response).map_err(|e| Box::new(e) as Box)?; - - // Extract the inner data - Ok(wrapper.data) - } - - pub async fn get_utxos( - &self, - address_bech32: &String, - ) -> Result, Box> { - let url = format!("/addresses/{}/utxos?with_cbor=true", address_bech32); - let response = self.get(&url).await?; - let wrapper: WrapperData> = - serde_json::from_str(&response).map_err(|e| { - eprintln!("Deserialization failed: {:?}", e); - eprintln!("Response: {}", response); - Box::new(e) as Box - })?; - Ok(wrapper.data) - } - - pub async fn submit_tx(&self, tx_cbor: &Vec) -> Result> { - let url = "/txmanager"; - let req = self - .http_client - .post(format!("{}{}", &self.base_url, url)) - .header("Content-Type", "application/cbor") - .header("Accept", "text/plain") - .header("api-key", &self.api_key) - .body(tx_cbor.clone()) - .build()?; - - let response = self.http_client.execute(req).await?; - // Clone the status before consuming the response body - let status = response.status(); - let response_body = response.text().await.unwrap_or_else(|_| "Failed to read response body".to_string()); - - if status.is_success() { - Ok(response_body) - } else { - eprintln!("Error | Status = {}, Body = {}", status, response_body); - Err(format!("Error | Status = {}, Body = {}", status, response_body).into()) - } - } - - pub fn to_csl_utxo(&self, utxo: &MaestroUtxo) -> TransactionUnspentOutput { - let tx_hash = TransactionHash::from_hex(utxo.tx_hash.as_str()).unwrap(); - let tx_index = utxo.index as u32; - let tx_in = TransactionInput::new(&tx_hash, tx_index); - let tx_out = TransactionOutput::from_hex(utxo.tx_out_cbor.as_str()).unwrap(); - TransactionUnspentOutput::new(&tx_in, &tx_out) - } - - pub async fn get_csl_utxos( - &self, - address: &Address, - ) -> Result> { - let bech32 = address.to_bech32(None).map_err(|e| { - eprintln!("Failed to convert address to Bech32: {:?}", e); - e - })?; - - let maestro_utxos = self.get_utxos(&bech32).await.map_err(|e| { - eprintln!("Failed to fetch UTXOs: {:?}", e); - e - })?; - - let mut csl_utxos = TransactionUnspentOutputs::new(); - for utxo in maestro_utxos.into_iter() { - let csl_utxo = self.to_csl_utxo(&utxo); - csl_utxos.add(&csl_utxo); - } - - Ok(csl_utxos) - } -} - -#[cfg(test)] -mod tests { - use cardano_serialization_lib::Transaction; - use super::*; - - #[tokio::test] - async fn test_get_latest_block() { - let maestro_client = Maestro::new( - "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), - "preprod".to_string(), - ); - let data = maestro_client.get_latest_block().await.unwrap(); - assert!(data.height > 0); - } - - #[tokio::test] - async fn test_get_utxos() { - let maestro_client = Maestro::new( - "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), - "preprod".to_string(), - ); - let address_bech32 = String::from("addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt"); - let utxos = maestro_client.get_utxos(&address_bech32).await.unwrap(); - assert!(utxos.len() > 0) - } - - #[tokio::test] - async fn test_get_csl_utxos() { - let maestro_client = Maestro::new( - "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), - "preprod".to_string(), - ); - let address = Address::from_bech32("addr_test1qzneme4j4mp3rxjzygvwnafvmzqww0kqhxl50a73u6z5865zvt27s3xuclj7q6mtqd9qn8rhdv3ywhh0gvqrz0f6sgwqxfxeqt").unwrap(); - let csl_utxos = maestro_client.get_csl_utxos(&address).await.unwrap(); - assert!(csl_utxos.len() > 0); - } - - #[tokio::test] - #[ignore] - async fn test_submit_tx() { - let maestro_client = Maestro::new( - "QlSHwIRe4Hq47kKgmFQOR0slx8lWyhiD".to_string(), - "preprod".to_string(), - ); - let tx_raw = "84a300818258203cc12ff1e7e02a953ce2dbe2c3e4edf5fc516c64322778a123e547dbf1886cfc010182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a9821b00000001c9cd8f35a2581ce16c2dc8ae937e8d3790c7fd7168d7b994621ba14ca11415f39fed72a2434d494e1a00019ae2444d494e741a00018a7b581ce4214b7cce62ac6fbba385d164df48e157eae5863521b4b67ca71d86a258203bb0079303c57812462dec9de8fb867cef8fd3768de7f12c77f6f0dd80381d0d1a00022098582044d75b06a5aafc296e094bf3a450734f739449c62183d4e3bbd50c28522afc971a000428e7021a001eab58a10081825820caef3384a369c8267801777c240bf648aa59719a31a3706113bd7cce67d477a4584090363e91ee07de04952e818bbc67cbd24501c78ced75497b48a6e76e8a9993e33dff2508d319799985643eb7b75e8b4e04a7975cea43da96463378ef6179c30bf5f6"; - let tx = Transaction::from_hex(&tx_raw).unwrap(); - let tx_cbor = tx.to_bytes(); - let result = maestro_client.submit_tx(&tx_cbor).await.unwrap(); - } -} diff --git a/rust/src/wallet/mod.rs b/rust/src/wallet/mod.rs index e20669e..a7ca7fb 100644 --- a/rust/src/wallet/mod.rs +++ b/rust/src/wallet/mod.rs @@ -1,3 +1,2 @@ pub mod embedded; pub mod emip3; -mod maestro; From ea53acc00b472db1069e76f4dd2a84401a1f8cba Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 15:21:02 +0700 Subject: [PATCH 10/32] sign tx --- rust/src/lib.rs | 15 ++++++++++++++- rust/src/network.rs | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index ab717c9..28cb0a7 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,9 +1,10 @@ mod crypto; mod wallet; pub mod network; +use crate::crypto::blake2b256; use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; -use cardano_serialization_lib::PrivateKey; +use cardano_serialization_lib::{make_vkey_witness, PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; pub struct MinWallet { address: String, @@ -52,6 +53,18 @@ impl MinWallet { let payment_key = account_key.derive(0).derive(0).to_raw_key(); PrivateKey::from_bech32(payment_key.to_bech32().as_ref()).unwrap() } + + pub fn sign_tx(&self, password: &str, account_index: u32, tx_raw: String) -> String { + let private_key = &self.get_private_key(password, account_index); + let tx = Transaction::from_hex(tx_raw.as_str()).unwrap(); + let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); + let mut witness_set = TransactionWitnessSet::new(); + let mut v_key_witness = Vkeywitnesses::new(); + let v_key = make_vkey_witness(&tx_hash, &private_key); + v_key_witness.add(&v_key); + witness_set.set_vkeys(&v_key_witness); + witness_set.to_hex() + } } uniffi::include_scaffolding!("mwrust"); diff --git a/rust/src/network.rs b/rust/src/network.rs index d77eb9a..2b7194f 100644 --- a/rust/src/network.rs +++ b/rust/src/network.rs @@ -14,6 +14,7 @@ impl NetworkId { } } +#[derive(uniffi::Enum)] pub enum NetworkEnvironment { Mainnet = 764824073, TestnetPreprod = 1, From 30ba4ae38ab1cd473125a9e87ef611071e884f65 Mon Sep 17 00:00:00 2001 From: tony Date: Fri, 22 Nov 2024 16:03:58 +0700 Subject: [PATCH 11/32] test IOS hello --- MinWallet/ContentView.swift | 14 +++++++++++++- rust/src/lib.rs | 4 ++++ rust/src/mwrust.udl | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/MinWallet/ContentView.swift b/MinWallet/ContentView.swift index e4d4a2d..e72dbea 100644 --- a/MinWallet/ContentView.swift +++ b/MinWallet/ContentView.swift @@ -1,8 +1,20 @@ import SwiftUI +import Foundation struct ContentView: View { var body: some View { - HomeScreen() + VStack { + HomeScreen() + Button("Tap Me") { + let result = mwrust.add(3, 5) + print(result) + print("DEBUG: Button tapped!") + } + .padding() + .background(Color.blue) + .foregroundColor(.white) + .cornerRadius(8) + } } } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 28cb0a7..ea710ea 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -6,6 +6,10 @@ use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; use cardano_serialization_lib::{make_vkey_witness, PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; +fn add(a: u32, b: u32) -> u32 { + a + b +} + pub struct MinWallet { address: String, network_id: u8, diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 2f25567..eabf638 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,4 +1,5 @@ namespace mwrust { + u32 add(u32 a, u32 b); }; dictionary MinWallet { From 072eee22384c7606690fb60ac3771fdb608b8a66 Mon Sep 17 00:00:00 2001 From: Nhat Khanh Date: Fri, 22 Nov 2024 16:53:59 +0700 Subject: [PATCH 12/32] fix build --- MinWallet.xcodeproj/project.pbxproj | 12 ++++++++---- MinWallet/ContentView.swift | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MinWallet.xcodeproj/project.pbxproj b/MinWallet.xcodeproj/project.pbxproj index da38147..d4f0a7d 100644 --- a/MinWallet.xcodeproj/project.pbxproj +++ b/MinWallet.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 2802CFDB8CD6498862AF73F2 /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 091411DC0725C9FF25F366CD /* Token.swift */; }; 5718EB1A2CEDE5BA00CDE34D /* DisableBounces.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5718EB192CEDE5B700CDE34D /* DisableBounces.swift */; }; 5718EB1D2CEDF72000CDE34D /* ShortenAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5718EB1C2CEDF71500CDE34D /* ShortenAddress.swift */; }; + 57248F152CF08B600070BFD9 /* Mobile.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57248F142CF08B600070BFD9 /* Mobile.xcframework */; }; + 57248F1D2CF08BF50070BFD9 /* mwrust.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57248F1C2CF08BF50070BFD9 /* mwrust.swift */; }; 575157912CEB43FF004CD647 /* HomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5751578E2CEB43FF004CD647 /* HomeScreen.swift */; }; 5751579B2CEB4407004CD647 /* AppButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575157922CEB4407004CD647 /* AppButton.swift */; }; 5751579C2CEB4407004CD647 /* Others.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575157972CEB4407004CD647 /* Others.swift */; }; @@ -94,6 +96,8 @@ 2C84DBEF290DC9F64EA0880D /* TokenListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenListItem.swift; sourceTree = ""; }; 5718EB192CEDE5B700CDE34D /* DisableBounces.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableBounces.swift; sourceTree = ""; }; 5718EB1C2CEDF71500CDE34D /* ShortenAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortenAddress.swift; sourceTree = ""; }; + 57248F142CF08B600070BFD9 /* Mobile.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Mobile.xcframework; path = rust/ios/Mobile.xcframework; sourceTree = ""; }; + 57248F1C2CF08BF50070BFD9 /* mwrust.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = mwrust.swift; path = rust/bindings/mwrust.swift; sourceTree = ""; }; 5751578E2CEB43FF004CD647 /* HomeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreen.swift; sourceTree = ""; }; 575157922CEB4407004CD647 /* AppButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppButton.swift; sourceTree = ""; }; 575157932CEB4407004CD647 /* AppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIcon.swift; sourceTree = ""; }; @@ -144,8 +148,6 @@ 578C60352CEF980A00E93A08 /* BeforeYouStart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BeforeYouStart.swift; sourceTree = ""; }; 579AFF772CEF9D0700A9B375 /* RevealSeedPhrase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RevealSeedPhrase.swift; sourceTree = ""; }; 579AFF792CEFA1F100A9B375 /* AppTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTextField.swift; sourceTree = ""; }; - 57A6D9192CEC35BF009CF6CD /* Mobile.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Mobile.xcframework; path = rust/ios/Mobile.xcframework; sourceTree = ""; }; - 57A6D91A2CEC3604009CF6CD /* mwrust.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = mwrust.swift; path = rust/bindings/mwrust.swift; sourceTree = ""; }; 57A6D91B2CEC3980009CF6CD /* AppBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppBar.swift; sourceTree = ""; }; 57A6F7C6490456E5F226DC7F /* TokenLogo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenLogo.swift; sourceTree = ""; }; 57F102922C64CCA0000B3544 /* MinWallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MinWallet.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -166,6 +168,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 57248F152CF08B600070BFD9 /* Mobile.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -351,8 +354,8 @@ 57F102A52C64CCA1000B3544 /* MinWalletTests */, 57F102AF2C64CCA1000B3544 /* MinWalletUITests */, 57F102932C64CCA0000B3544 /* Products */, - 57A6D9192CEC35BF009CF6CD /* Mobile.xcframework */, - 57A6D91A2CEC3604009CF6CD /* mwrust.swift */, + 57248F142CF08B600070BFD9 /* Mobile.xcframework */, + 57248F1C2CF08BF50070BFD9 /* mwrust.swift */, ); sourceTree = ""; }; @@ -588,6 +591,7 @@ 5718EB1D2CEDF72000CDE34D /* ShortenAddress.swift in Sources */, 578C60322CEF90A700E93A08 /* CreateWalletScreen.swift in Sources */, 5751579B2CEB4407004CD647 /* AppButton.swift in Sources */, + 57248F1D2CF08BF50070BFD9 /* mwrust.swift in Sources */, 5751579C2CEB4407004CD647 /* Others.swift in Sources */, 5751579D2CEB4407004CD647 /* AppIcon.swift in Sources */, 57A6D91C2CEC3982009CF6CD /* AppBar.swift in Sources */, diff --git a/MinWallet/ContentView.swift b/MinWallet/ContentView.swift index e72dbea..2fb7f9e 100644 --- a/MinWallet/ContentView.swift +++ b/MinWallet/ContentView.swift @@ -6,8 +6,8 @@ struct ContentView: View { VStack { HomeScreen() Button("Tap Me") { - let result = mwrust.add(3, 5) - print(result) + let result = add(a: 1, b: 2) + print("result") print("DEBUG: Button tapped!") } .padding() From 7f5829ef9ac2a2f0bc2e83015b2ae03fb81a4385 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 09:48:04 +0700 Subject: [PATCH 13/32] add gen pharse --- MinWallet/ContentView.swift | 5 +++-- rust/src/lib.rs | 20 ++++++++++++++++++++ rust/src/mwrust.udl | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/MinWallet/ContentView.swift b/MinWallet/ContentView.swift index 2fb7f9e..5bea563 100644 --- a/MinWallet/ContentView.swift +++ b/MinWallet/ContentView.swift @@ -6,8 +6,9 @@ struct ContentView: View { VStack { HomeScreen() Button("Tap Me") { - let result = add(a: 1, b: 2) - print("result") + let pharse = genPhrase(wordCount: 12) + // let result = add(a: 1, b: 2) + print(pharse) print("DEBUG: Button tapped!") } .padding() diff --git a/rust/src/lib.rs b/rust/src/lib.rs index ea710ea..1d6f943 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,11 +1,31 @@ mod crypto; mod wallet; pub mod network; + +use bip39::{Language, Mnemonic, MnemonicType}; use crate::crypto::blake2b256; use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; use cardano_serialization_lib::{make_vkey_witness, PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; +fn gen_phrase(word_count: u32) -> String { + // Match the word_count to the corresponding MnemonicType variant + let m_type = match word_count { + 12 => MnemonicType::Words12, + 15 => MnemonicType::Words15, + 18 => MnemonicType::Words18, + 21 => MnemonicType::Words21, + 24 => MnemonicType::Words24, + _ => panic!("Invalid word count! Must be one of: 12, 15, 18, 21, or 24."), + }; + + // Create a new randomly generated mnemonic phrase + let mnemonic = Mnemonic::new(m_type, Language::English); + + // Get the phrase as a string + mnemonic.phrase().to_string() +} + fn add(a: u32, b: u32) -> u32 { a + b } diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index eabf638..18c7ae5 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,4 +1,5 @@ namespace mwrust { + string gen_phrase(u32 word_count); u32 add(u32 a, u32 b); }; From ead61333ca81764837f0e4c2ce24b1154b10d826 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 11:18:28 +0700 Subject: [PATCH 14/32] wip --- rust/src/mwrust.udl | 8 ++++---- rust/src/network.rs | 19 ++++++++++++++----- rust/src/wallet/embedded.rs | 10 +++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index 18c7ae5..a7896ed 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,11 +1,11 @@ namespace mwrust { string gen_phrase(u32 word_count); - u32 add(u32 a, u32 b); + MinWallet create_wallet(string phrase, string password, string network_env); }; dictionary MinWallet { string address; - u8 network_id; - string encrypted_key; + u32 network_id; u32 account_index; -}; + string encrypted_key; +}; \ No newline at end of file diff --git a/rust/src/network.rs b/rust/src/network.rs index 2b7194f..2bfa87b 100644 --- a/rust/src/network.rs +++ b/rust/src/network.rs @@ -8,21 +8,30 @@ impl NetworkId { pub fn from_network_environment(network_environment: &NetworkEnvironment) -> Self { match network_environment { NetworkEnvironment::Mainnet => NetworkId::Mainnet, - NetworkEnvironment::TestnetPreprod => NetworkId::Testnet, - NetworkEnvironment::TestnetPreview => NetworkId::Testnet, + NetworkEnvironment::Preprod => NetworkId::Testnet, + NetworkEnvironment::Preview => NetworkId::Testnet, } } } -#[derive(uniffi::Enum)] +#[derive(Debug, PartialEq)] pub enum NetworkEnvironment { Mainnet = 764824073, - TestnetPreprod = 1, - TestnetPreview = 2, + Preprod = 1, + Preview = 2, } impl NetworkEnvironment { pub fn to_network_id(&self) -> NetworkId { NetworkId::from_network_environment(self) } + + pub fn from_string(network: String) -> Result { + match network.to_lowercase().as_str() { + "mainnet" => Ok(NetworkEnvironment::Mainnet), + "preprod" => Ok(NetworkEnvironment::Preprod), + "preview" => Ok(NetworkEnvironment::Preview), + _ => Err(format!("Unknown network environment: {}", network)), + } + } } diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 2134b6b..7cd968d 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -8,7 +8,7 @@ fn harden(index: u32) -> u32 { } pub trait WalletStaticMethods { - fn mnemonic_to_entropy(phrase: &str) -> Vec { + fn phrase_to_entropy(phrase: &str) -> Vec { let mnemonic = Mnemonic::from_phrase(&phrase, Language::English).unwrap(); mnemonic.entropy().to_vec() } @@ -27,7 +27,7 @@ pub trait WalletStaticMethods { .derive(harden(index)) } - fn get_address(account: &Bip32PrivateKey, network_id: u8) -> Address { + fn get_address(account: &Bip32PrivateKey, network_id: u32) -> Address { let payment_key = account.derive(0).derive(0).to_raw_key(); let payment_key_hash = payment_key.to_public().hash(); let payment_credential = Credential::from_keyhash(&payment_key_hash); @@ -36,7 +36,7 @@ pub trait WalletStaticMethods { let stake_key_hash = stake_key.to_public().hash(); let stake_credential = Credential::from_keyhash(&stake_key_hash); - BaseAddress::new(network_id, &payment_credential, &stake_credential).to_address() + BaseAddress::new(network_id as u8, &payment_credential, &stake_credential).to_address() } fn gen_reward_address(account: &Bip32PrivateKey, network_id: u8) -> RewardAddress { @@ -70,7 +70,7 @@ mod tests { fn test_round_trip_root_key() { let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); let password = String::from("helloworld"); - let entropy = TestWallet::mnemonic_to_entropy(&seed); + let entropy = TestWallet::phrase_to_entropy(&seed); let root_key = TestWallet::entropy_to_root_key(&entropy, &password); let encrypted = TestWallet::gen_encrypted_key(&password, &root_key); let decrypted = TestWallet::get_root_key_from_password(&password, &encrypted); @@ -81,7 +81,7 @@ mod tests { fn test_base_address() { let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); let password = String::from("helloworld"); - let entropy = TestWallet::mnemonic_to_entropy(&seed); + let entropy = TestWallet::phrase_to_entropy(&seed); let root_key = TestWallet::entropy_to_root_key(&entropy, &password); assert_eq!(root_key.to_bech32(), "xprv1gre69tdkhwnzsl0spaj9n9ty9gc7yx64fm29ff9hea57sd4q03xuatqlpq7qanpl3dnjzdtchx394gdk9w0c9ezaaau45c2wk5aduyht3kw7659u7gzt4qh37na0dsh66txhajlzssf27ay75s8hpdqqug7vwwy6"); From b47f0831f61e2c50c0afe26265368a7d7707b975 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 11:18:34 +0700 Subject: [PATCH 15/32] wip --- MinWallet/ContentView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MinWallet/ContentView.swift b/MinWallet/ContentView.swift index 5bea563..1e5cf37 100644 --- a/MinWallet/ContentView.swift +++ b/MinWallet/ContentView.swift @@ -6,9 +6,11 @@ struct ContentView: View { VStack { HomeScreen() Button("Tap Me") { - let pharse = genPhrase(wordCount: 12) + let phrase = genPhrase(wordCount: 12) // let result = add(a: 1, b: 2) - print(pharse) + print(phrase) + let wallet = createWallet(phrase: phrase, password: "123456", networkEnv: "preprod") + print(wallet.address) print("DEBUG: Button tapped!") } .padding() From d5eee663bcb42ad17f6781dbf93d6240b1cb9aad Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 11:21:48 +0700 Subject: [PATCH 16/32] export create_wallet --- rust/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 1d6f943..dff7c17 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -26,13 +26,14 @@ fn gen_phrase(word_count: u32) -> String { mnemonic.phrase().to_string() } -fn add(a: u32, b: u32) -> u32 { - a + b +fn create_wallet(phrase: String, password: String, network_env: String) -> MinWallet { + let network_environment = NetworkEnvironment::from_string(network_env).unwrap(); + MinWallet::create(phrase.as_str(), password.as_str(), network_environment) } pub struct MinWallet { address: String, - network_id: u8, + network_id: u32, encrypted_key: String, account_index: u32, } @@ -48,7 +49,7 @@ impl MinWallet { let account_index = 0; // Convert mnemonic to entropy - let entropy = MinWallet::mnemonic_to_entropy(&mnemonic); + let entropy = MinWallet::phrase_to_entropy(&mnemonic); // Derive root key and account key let root_key = MinWallet::entropy_to_root_key(&entropy, &password); @@ -58,7 +59,7 @@ impl MinWallet { let encrypted_key = MinWallet::gen_encrypted_key(password, &root_key); // Derive network ID - let network_id = network_environment.to_network_id() as u8; + let network_id = network_environment.to_network_id() as u32; // Generate addresses let address = MinWallet::get_address(&account_key, network_id); @@ -105,7 +106,7 @@ mod tests { let min_wallet = MinWallet::create( "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", &password, - network::NetworkEnvironment::TestnetPreprod, + network::NetworkEnvironment::Preprod, ); let private_key = min_wallet.get_private_key(&password, 0); assert_eq!(private_key.to_hex(), String::from("f838ddcb280f7c89bf5480591a0b46b2b80602134b19179a61c1991d7639ab549009491d6b359c37f03af6422af350e2e041ecde02a734a4b9dae5a6f7a1bf69")); @@ -117,7 +118,7 @@ mod tests { let min_wallet = MinWallet::create( "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", &password, - NetworkEnvironment::TestnetPreprod, + NetworkEnvironment::Preprod, ); let tx_raw = "84a40081825820dee6b0848594bea01d61450e47827da762947f61ad2387ccf1f8ba629b5252d4020182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a1d16ce6d021a0002917d031a048f683ca0f5f6"; let tx = Transaction::from_hex(tx_raw).unwrap(); From 759e5bd84a304467b59e2ddd8b25ea202fde8932 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 11:22:02 +0700 Subject: [PATCH 17/32] fmt --- rust/src/lib.rs | 19 ++++++++++--------- rust/src/wallet/embedded.rs | 24 ++++++++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index dff7c17..2523dc0 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,12 +1,15 @@ mod crypto; -mod wallet; pub mod network; +mod wallet; -use bip39::{Language, Mnemonic, MnemonicType}; use crate::crypto::blake2b256; use crate::network::NetworkEnvironment; use crate::wallet::embedded::WalletStaticMethods; -use cardano_serialization_lib::{make_vkey_witness, PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; +use bip39::{Language, Mnemonic, MnemonicType}; +use cardano_serialization_lib::{ + make_vkey_witness, PrivateKey, Transaction, TransactionHash, TransactionWitnessSet, + Vkeywitnesses, +}; fn gen_phrase(word_count: u32) -> String { // Match the word_count to the corresponding MnemonicType variant @@ -41,11 +44,7 @@ pub struct MinWallet { impl WalletStaticMethods for MinWallet {} impl MinWallet { - pub fn create( - mnemonic: &str, - password: &str, - network_environment: NetworkEnvironment, - ) -> Self { + pub fn create(mnemonic: &str, password: &str, network_environment: NetworkEnvironment) -> Self { let account_index = 0; // Convert mnemonic to entropy @@ -98,7 +97,9 @@ uniffi::include_scaffolding!("mwrust"); mod tests { use super::*; use crate::crypto::blake2b256; - use cardano_serialization_lib::{make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses}; + use cardano_serialization_lib::{ + make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses, + }; #[test] fn test_get_private_key() { diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 7cd968d..05a60b1 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -13,13 +13,10 @@ pub trait WalletStaticMethods { mnemonic.entropy().to_vec() } - fn entropy_to_root_key(entropy: &[u8], password: &str)-> Bip32PrivateKey { - Bip32PrivateKey::from_bip39_entropy( - entropy, - password.as_bytes() - ) + fn entropy_to_root_key(entropy: &[u8], password: &str) -> Bip32PrivateKey { + Bip32PrivateKey::from_bip39_entropy(entropy, password.as_bytes()) } - + fn get_account(root_key: &Bip32PrivateKey, index: u32) -> Bip32PrivateKey { root_key .derive(harden(1852)) // purpose @@ -31,7 +28,7 @@ pub trait WalletStaticMethods { let payment_key = account.derive(0).derive(0).to_raw_key(); let payment_key_hash = payment_key.to_public().hash(); let payment_credential = Credential::from_keyhash(&payment_key_hash); - + let stake_key = account.derive(2).derive(0).to_raw_key(); let stake_key_hash = stake_key.to_public().hash(); let stake_credential = Credential::from_keyhash(&stake_key_hash); @@ -68,7 +65,9 @@ mod tests { #[test] fn test_round_trip_root_key() { - let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); + let seed = String::from( + "detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount", + ); let password = String::from("helloworld"); let entropy = TestWallet::phrase_to_entropy(&seed); let root_key = TestWallet::entropy_to_root_key(&entropy, &password); @@ -79,7 +78,9 @@ mod tests { #[test] fn test_base_address() { - let seed = String::from("detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount"); + let seed = String::from( + "detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount", + ); let password = String::from("helloworld"); let entropy = TestWallet::phrase_to_entropy(&seed); let root_key = TestWallet::entropy_to_root_key(&entropy, &password); @@ -90,6 +91,9 @@ mod tests { assert_eq!(address.to_bech32(None).unwrap(), "addr1q82vnh5g9epl7x8c3m0zngjtfzcjttt5gjpf8eptvjxk74397eag00jf7yvzj28v38mufm9keaygaywu0eprdwnu40hsm6eekf"); let reward_address = TestWallet::gen_reward_address(&account, 1); - assert_eq!(reward_address.to_address().to_bech32(None).unwrap(), "stake1uyjlv758heylzxpf9rkgna7yajmv7jywj8w8us3khf72hmcmx40fs"); + assert_eq!( + reward_address.to_address().to_bech32(None).unwrap(), + "stake1uyjlv758heylzxpf9rkgna7yajmv7jywj8w8us3khf72hmcmx40fs" + ); } } From 8a0755c181e0f32d27adcbec934fc61cabb28309 Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 11:23:06 +0700 Subject: [PATCH 18/32] fix address --- rust/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 2523dc0..7a646b6 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -64,7 +64,7 @@ impl MinWallet { let address = MinWallet::get_address(&account_key, network_id); MinWallet { - address: address.to_hex(), + address: address.to_bech32(None).unwrap(), network_id, account_index, encrypted_key, From fe496724eab248b88119ef8ae7534923c5a660ef Mon Sep 17 00:00:00 2001 From: tony Date: Mon, 2 Dec 2024 12:20:28 +0700 Subject: [PATCH 19/32] fix create wallet --- rust/src/lib.rs | 30 ++++++++++++++++++++++++------ rust/src/mwrust.udl | 1 + rust/src/wallet/embedded.rs | 9 ++++----- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 7a646b6..17f3966 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -11,6 +11,14 @@ use cardano_serialization_lib::{ Vkeywitnesses, }; +// *************************** EXPORT *************************** +pub struct MinWallet { + address: String, + network_id: u32, + encrypted_key: String, + account_index: u32, +} + fn gen_phrase(word_count: u32) -> String { // Match the word_count to the corresponding MnemonicType variant let m_type = match word_count { @@ -34,12 +42,10 @@ fn create_wallet(phrase: String, password: String, network_env: String) -> MinWa MinWallet::create(phrase.as_str(), password.as_str(), network_environment) } -pub struct MinWallet { - address: String, - network_id: u32, - encrypted_key: String, - account_index: u32, +fn sign_tx(wallet: MinWallet, password: String, account_index: u32, tx_raw: String) -> String { + wallet.sign_tx(password.as_str(), account_index, tx_raw) } +// *************************** END EXPORT *************************** impl WalletStaticMethods for MinWallet {} @@ -51,7 +57,7 @@ impl MinWallet { let entropy = MinWallet::phrase_to_entropy(&mnemonic); // Derive root key and account key - let root_key = MinWallet::entropy_to_root_key(&entropy, &password); + let root_key = MinWallet::entropy_to_root_key(&entropy); let account_key = MinWallet::get_account(&root_key, account_index); // Encrypt root key with password @@ -101,6 +107,18 @@ mod tests { make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses, }; + #[test] + fn test_create_wallet() { + let phrase = "prevent patrol juice fish need fan genre tomorrow fancy voyage elephant idea journey spoil code assist pact barely excite broom heart degree try label"; + let password = "123456"; + let wallet = create_wallet( + phrase.to_string(), + password.to_string(), + "preprod".to_string(), + ); + assert_eq!(wallet.address, "addr_test1qramn7zn2c6frw3p845nwrggkw0yknz4372fwte6t27d9x3gqenr8sqt9tn4d6lfrxn776k4je5mety53psglaz9dgeqhygnh7".to_string()); + } + #[test] fn test_get_private_key() { let password = "Minswap@123456"; diff --git a/rust/src/mwrust.udl b/rust/src/mwrust.udl index a7896ed..7c09f3d 100644 --- a/rust/src/mwrust.udl +++ b/rust/src/mwrust.udl @@ -1,6 +1,7 @@ namespace mwrust { string gen_phrase(u32 word_count); MinWallet create_wallet(string phrase, string password, string network_env); + string sign_tx(MinWallet wallet, string password, u32 account_index, string tx_raw); }; dictionary MinWallet { diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 05a60b1..051b83e 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -13,8 +13,8 @@ pub trait WalletStaticMethods { mnemonic.entropy().to_vec() } - fn entropy_to_root_key(entropy: &[u8], password: &str) -> Bip32PrivateKey { - Bip32PrivateKey::from_bip39_entropy(entropy, password.as_bytes()) + fn entropy_to_root_key(entropy: &[u8]) -> Bip32PrivateKey { + Bip32PrivateKey::from_bip39_entropy(entropy, "".as_bytes()) } fn get_account(root_key: &Bip32PrivateKey, index: u32) -> Bip32PrivateKey { @@ -70,7 +70,7 @@ mod tests { ); let password = String::from("helloworld"); let entropy = TestWallet::phrase_to_entropy(&seed); - let root_key = TestWallet::entropy_to_root_key(&entropy, &password); + let root_key = TestWallet::entropy_to_root_key(&entropy); let encrypted = TestWallet::gen_encrypted_key(&password, &root_key); let decrypted = TestWallet::get_root_key_from_password(&password, &encrypted); assert_eq!(root_key.to_hex(), decrypted.to_hex()); @@ -81,9 +81,8 @@ mod tests { let seed = String::from( "detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount", ); - let password = String::from("helloworld"); let entropy = TestWallet::phrase_to_entropy(&seed); - let root_key = TestWallet::entropy_to_root_key(&entropy, &password); + let root_key = TestWallet::entropy_to_root_key(&entropy); assert_eq!(root_key.to_bech32(), "xprv1gre69tdkhwnzsl0spaj9n9ty9gc7yx64fm29ff9hea57sd4q03xuatqlpq7qanpl3dnjzdtchx394gdk9w0c9ezaaau45c2wk5aduyht3kw7659u7gzt4qh37na0dsh66txhajlzssf27ay75s8hpdqqug7vwwy6"); let account = TestWallet::get_account(&root_key, 0); From 0d78a27fb9271b0e54a993188a8615d74713fec8 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 12 Dec 2024 12:24:46 +0700 Subject: [PATCH 20/32] final --- rust/src/crypto.rs | 7 ++++ rust/src/lib.rs | 66 ++++++++++++++----------------------- rust/src/wallet/embedded.rs | 30 +---------------- 3 files changed, 32 insertions(+), 71 deletions(-) diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs index 574f5dd..bc43136 100644 --- a/rust/src/crypto.rs +++ b/rust/src/crypto.rs @@ -1,3 +1,4 @@ +use cardano_serialization_lib::{TransactionBody, TransactionHash}; use cryptoxide::blake2b::Blake2b; pub(crate) fn blake2b256(data: &[u8]) -> [u8; 32] { @@ -5,3 +6,9 @@ pub(crate) fn blake2b256(data: &[u8]) -> [u8; 32] { Blake2b::blake2b(&mut out, data, &[]); out } + +#[allow(dead_code)] +// Testing Purpose Only +pub fn hash_transaction(tx_body: &TransactionBody) -> TransactionHash { + TransactionHash::from(blake2b256(tx_body.to_bytes().as_ref())) +} diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 17f3966..9695494 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -19,7 +19,7 @@ pub struct MinWallet { account_index: u32, } -fn gen_phrase(word_count: u32) -> String { +pub fn gen_phrase(word_count: u32) -> String { // Match the word_count to the corresponding MnemonicType variant let m_type = match word_count { 12 => MnemonicType::Words12, @@ -37,12 +37,12 @@ fn gen_phrase(word_count: u32) -> String { mnemonic.phrase().to_string() } -fn create_wallet(phrase: String, password: String, network_env: String) -> MinWallet { +pub fn create_wallet(phrase: String, password: String, network_env: String) -> MinWallet { let network_environment = NetworkEnvironment::from_string(network_env).unwrap(); MinWallet::create(phrase.as_str(), password.as_str(), network_environment) } -fn sign_tx(wallet: MinWallet, password: String, account_index: u32, tx_raw: String) -> String { +pub fn sign_tx(wallet: MinWallet, password: String, account_index: u32, tx_raw: String) -> String { wallet.sign_tx(password.as_str(), account_index, tx_raw) } // *************************** END EXPORT *************************** @@ -89,10 +89,10 @@ impl MinWallet { let tx = Transaction::from_hex(tx_raw.as_str()).unwrap(); let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); let mut witness_set = TransactionWitnessSet::new(); - let mut v_key_witness = Vkeywitnesses::new(); - let v_key = make_vkey_witness(&tx_hash, &private_key); - v_key_witness.add(&v_key); - witness_set.set_vkeys(&v_key_witness); + let mut v_key_witnesses = Vkeywitnesses::new(); + let v_key = make_vkey_witness(&tx_hash, private_key); + v_key_witnesses.add(&v_key); + witness_set.set_vkeys(&v_key_witnesses); witness_set.to_hex() } } @@ -102,51 +102,33 @@ uniffi::include_scaffolding!("mwrust"); #[cfg(test)] mod tests { use super::*; - use crate::crypto::blake2b256; - use cardano_serialization_lib::{ - make_vkey_witness, Transaction, TransactionHash, TransactionWitnessSet, Vkeywitnesses, - }; + use crate::crypto::hash_transaction; + use cardano_serialization_lib::Transaction; #[test] - fn test_create_wallet() { - let phrase = "prevent patrol juice fish need fan genre tomorrow fancy voyage elephant idea journey spoil code assist pact barely excite broom heart degree try label"; + fn test_wallet_happy_case() { + let phrase = + "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey"; let password = "123456"; let wallet = create_wallet( phrase.to_string(), password.to_string(), "preprod".to_string(), ); - assert_eq!(wallet.address, "addr_test1qramn7zn2c6frw3p845nwrggkw0yknz4372fwte6t27d9x3gqenr8sqt9tn4d6lfrxn776k4je5mety53psglaz9dgeqhygnh7".to_string()); - } + assert_eq!(wallet.address, "addr_test1qp5cpdqd3n6nuaa8rr8h20lnsxzx2uxdapknyh6fryl7e32e34tccc70arj2f4m9x9zdz4vu29rzzrtszalvqzpx625s2z2338".to_string()); - #[test] - fn test_get_private_key() { - let password = "Minswap@123456"; - let min_wallet = MinWallet::create( - "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", - &password, - network::NetworkEnvironment::Preprod, - ); - let private_key = min_wallet.get_private_key(&password, 0); - assert_eq!(private_key.to_hex(), String::from("f838ddcb280f7c89bf5480591a0b46b2b80602134b19179a61c1991d7639ab549009491d6b359c37f03af6422af350e2e041ecde02a734a4b9dae5a6f7a1bf69")); - } + let prk = wallet.get_private_key(password, 0); + assert_eq!(prk.to_hex(), "28ceeb4ab29780c599235ceac57f28db9939ff722d71dd4ccae6298c06f4c9596bee62e48edf249344602b310231ba80883e1ecb4c7196d192af9ed48d9f9ad5"); - #[test] - fn test_happy_path() { - let password = "Minswap@123456"; - let min_wallet = MinWallet::create( - "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", - &password, - NetworkEnvironment::Preprod, - ); - let tx_raw = "84a40081825820dee6b0848594bea01d61450e47827da762947f61ad2387ccf1f8ba629b5252d4020182825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a00989680825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a91a1d16ce6d021a0002917d031a048f683ca0f5f6"; + let tx_raw = "84a400d9010281825820b92cd85195fcf6bcbab09fbac22b0018a9aad5c7f75d85bcd4ed6538985f7f62020181825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a9821b00000001fa051528a3581cb4dac0cea6dcf6f951a07add2ef6114c41be3cb7b4cfddf06a2eb593a14c0014df104361707962617261191cbb581ce16c2dc8ae937e8d3790c7fd7168d7b994621ba14ca11415f39fed72a4434d494e1a0001c094444d494e7419c53e44744254431909134d0014df104341545448554841491b00000001ad9e7c03581ce4214b7cce62ac6fbba385d164df48e157eae5863521b4b67ca71d86a4582029acf586bf10c3b25c488705a542400178f9c9116f123a581d89fa8fb25ed3fb1a001d53d758203bb0079303c57812462dec9de8fb867cef8fd3768de7f12c77f6f0dd80381d0d1a00022098582044d75b06a5aafc296e094bf3a450734f739449c62183d4e3bbd50c28522afc971a00058bde58205efbe6716c317ee3a9333ca42993b2f9608a0e8a383e8b750312cf4d21970ab41a012318bc021a0002bda9031a04aae41da0f5f6"; let tx = Transaction::from_hex(tx_raw).unwrap(); - let tx_hash = TransactionHash::from(blake2b256(&tx.body().to_bytes())); - let mut witness_set = TransactionWitnessSet::new(); - let mut v_key_witness = Vkeywitnesses::new(); - let private_key = min_wallet.get_private_key(&password, 0); - let v_key = make_vkey_witness(&tx_hash, &private_key); - v_key_witness.add(&v_key); - witness_set.set_vkeys(&v_key_witness); + let tx_hash = hash_transaction(&tx.body()); + assert_eq!( + tx_hash.to_hex().as_str(), + "7de67019c1ee101882736d4f7104f3bbeed33f0d16e30930c0f4b2f944872cff" + ); + + let witness = sign_tx(wallet, password.to_string(), 0, tx_raw.to_string()); + assert_eq!(witness.as_str(), "a100d9010281825820caef3384a369c8267801777c240bf648aa59719a31a3706113bd7cce67d477a45840e2987748dbb198c4ce6f7804a79cea2fe515e7d0730a18352394b6f8aac38d728a579a70ebcb9a0264069d139a1b911effc60e8b8c2513b690577292c8c3d80e"); } } diff --git a/rust/src/wallet/embedded.rs b/rust/src/wallet/embedded.rs index 051b83e..dd49876 100644 --- a/rust/src/wallet/embedded.rs +++ b/rust/src/wallet/embedded.rs @@ -1,5 +1,5 @@ use bip39::{Language, Mnemonic}; -use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credential, RewardAddress}; +use cardano_serialization_lib::{Address, BaseAddress, Bip32PrivateKey, Credential}; use crate::wallet::emip3::{decrypt_password, encrypt_password}; @@ -36,14 +36,6 @@ pub trait WalletStaticMethods { BaseAddress::new(network_id as u8, &payment_credential, &stake_credential).to_address() } - fn gen_reward_address(account: &Bip32PrivateKey, network_id: u8) -> RewardAddress { - let stake_key = account.derive(2).derive(0).to_raw_key(); - let stake_key_hash = stake_key.to_public().hash(); - let stake_credential = Credential::from_keyhash(&stake_key_hash); - - RewardAddress::new(network_id, &stake_credential) - } - fn gen_encrypted_key(password: &str, root_key: &Bip32PrivateKey) -> String { let root_key_hex = root_key.to_hex(); encrypt_password(password, root_key_hex.as_str()) @@ -75,24 +67,4 @@ mod tests { let decrypted = TestWallet::get_root_key_from_password(&password, &encrypted); assert_eq!(root_key.to_hex(), decrypted.to_hex()); } - - #[test] - fn test_base_address() { - let seed = String::from( - "detect amateur eternal elite dad kangaroo usual chase poem detail tumble amount", - ); - let entropy = TestWallet::phrase_to_entropy(&seed); - let root_key = TestWallet::entropy_to_root_key(&entropy); - assert_eq!(root_key.to_bech32(), "xprv1gre69tdkhwnzsl0spaj9n9ty9gc7yx64fm29ff9hea57sd4q03xuatqlpq7qanpl3dnjzdtchx394gdk9w0c9ezaaau45c2wk5aduyht3kw7659u7gzt4qh37na0dsh66txhajlzssf27ay75s8hpdqqug7vwwy6"); - - let account = TestWallet::get_account(&root_key, 0); - let address = TestWallet::get_address(&account, 1); - assert_eq!(address.to_bech32(None).unwrap(), "addr1q82vnh5g9epl7x8c3m0zngjtfzcjttt5gjpf8eptvjxk74397eag00jf7yvzj28v38mufm9keaygaywu0eprdwnu40hsm6eekf"); - - let reward_address = TestWallet::gen_reward_address(&account, 1); - assert_eq!( - reward_address.to_address().to_bech32(None).unwrap(), - "stake1uyjlv758heylzxpf9rkgna7yajmv7jywj8w8us3khf72hmcmx40fs" - ); - } } From c135ae7f6b68dec0c71dabd5f671de60616c1f8a Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 12 Dec 2024 12:36:53 +0700 Subject: [PATCH 21/32] add readme --- rust/README.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 rust/README.md diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 0000000..35dfbdb --- /dev/null +++ b/rust/README.md @@ -0,0 +1,127 @@ +# mwrust Library + +The `mwrust` namespace provides a set of tools for interacting with wallets and signing transactions. This library is designed to facilitate wallet generation, transaction signing, and related functionality in a structured and easy-to-use API. + +## Features + +- Generate mnemonic phrases for wallet creation. +- Create wallets with customizable phrases and passwords. +- Sign raw transactions securely using wallet credentials. + +## Namespace + +The library exposes the `mwrust` namespace with the following functions and types: + +### Functions + +#### `gen_phrase(u32 word_count) -> string` +Generates a mnemonic phrase with the specified word count. + +- **Parameters**: + - `word_count`: Number of words in the generated mnemonic phrase (e.g., 12, 15, 24). +- **Returns**: + - A string containing the generated mnemonic phrase. + +#### Example: +```cpp +string phrase = mwrust::gen_phrase(12); +``` + +--- + +#### `create_wallet(string phrase, string password, string network_env) -> MinWallet` +Creates a wallet based on the provided mnemonic phrase, password, and network environment. + +- **Parameters**: + - `phrase`: The mnemonic phrase used to derive the wallet. + - `password`: A user-defined password for encrypting the wallet's private key. + - `network_env`: The network environment for the wallet (e.g., `"mainnet"` or `"preprod"`). +- **Returns**: + - A `MinWallet` object containing wallet details. + +#### Example: +```cpp +MinWallet wallet = mwrust::create_wallet( + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + "secure_password", + "testnet" +); +``` + +--- + +#### `sign_tx(MinWallet wallet, string password, u32 account_index, string tx_raw) -> string` +Signs a raw transaction using the provided wallet. + +- **Parameters**: + - `wallet`: A `MinWallet` object containing wallet details. + - `password`: The password used to decrypt the wallet's private key. + - `account_index`: The account index to sign the transaction from (default `account_index = 0`). + - `tx_raw`: The raw transaction string to be signed. +- **Returns**: + - A signed transaction string. + +#### Example: +```cpp +string signed_tx = mwrust::sign_tx(wallet, "secure_password", 0, "raw_tx_data"); +``` + +--- + +### Types + +#### `MinWallet` +A dictionary object containing details of a wallet. + +- **Fields**: + - `address` (`string`): The wallet's address. + - `network_id` (`u32`): The ID of the network the wallet belongs to (e.g., `1` for mainnet). + - `account_index` (`u32`): The account index within the wallet. + - `encrypted_key` (`string`): The wallet's encrypted private key. + +#### Example: +```cpp +MinWallet wallet = { + "address": "addr_test1...", + "network_id": 0, + "account_index": 0, + "encrypted_key": "" +}; +``` + +## Usage Examples + +### Generate a Mnemonic Phrase +```cpp +string phrase = mwrust::gen_phrase(24); +``` + +### Create a Wallet +```cpp +MinWallet wallet = mwrust::create_wallet( + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + "secure_password", + "mainnet" +); +``` + +### Sign a Transaction +```cpp +string signed_tx = mwrust::sign_tx( + wallet, + "secure_password", + 0, + "raw_tx_data" +); +``` + +## Requirements +- C++ compiler +- Rust integration (if applicable for `mwrust` implementation) + +## License +This library is licensed under the MIT License. See the LICENSE file for more details. + +## Contributing +Contributions are welcome! Please open an issue or submit a pull request on the repository. + From fa9d87497fbaff224b071c9723323a1308f207ee Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 12 Dec 2024 12:36:57 +0700 Subject: [PATCH 22/32] test --- MinWallet/ContentView.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MinWallet/ContentView.swift b/MinWallet/ContentView.swift index 1e5cf37..bab0574 100644 --- a/MinWallet/ContentView.swift +++ b/MinWallet/ContentView.swift @@ -6,12 +6,15 @@ struct ContentView: View { VStack { HomeScreen() Button("Tap Me") { + print("DEBUG: Button tapped!") let phrase = genPhrase(wordCount: 12) - // let result = add(a: 1, b: 2) print(phrase) - let wallet = createWallet(phrase: phrase, password: "123456", networkEnv: "preprod") + let wallet = createWallet(phrase: "belt change crouch decorate advice emerge tongue loop cute olympic tuna donkey", password: "123456", networkEnv: "preprod") print(wallet.address) - print("DEBUG: Button tapped!") + let txRaw = "84a400d9010281825820b92cd85195fcf6bcbab09fbac22b0018a9aad5c7f75d85bcd4ed6538985f7f62020181825839006980b40d8cf53e77a718cf753ff381846570cde86d325f49193fecc5598d578c63cfe8e4a4d7653144d1559c5146210d70177ec00826d2a9821b00000001fa051528a3581cb4dac0cea6dcf6f951a07add2ef6114c41be3cb7b4cfddf06a2eb593a14c0014df104361707962617261191cbb581ce16c2dc8ae937e8d3790c7fd7168d7b994621ba14ca11415f39fed72a4434d494e1a0001c094444d494e7419c53e44744254431909134d0014df104341545448554841491b00000001ad9e7c03581ce4214b7cce62ac6fbba385d164df48e157eae5863521b4b67ca71d86a4582029acf586bf10c3b25c488705a542400178f9c9116f123a581d89fa8fb25ed3fb1a001d53d758203bb0079303c57812462dec9de8fb867cef8fd3768de7f12c77f6f0dd80381d0d1a00022098582044d75b06a5aafc296e094bf3a450734f739449c62183d4e3bbd50c28522afc971a00058bde58205efbe6716c317ee3a9333ca42993b2f9608a0e8a383e8b750312cf4d21970ab41a012318bc021a0002bda9031a04aae77ca0f5f6" + let witness = signTx(wallet: wallet, password: "123456", accountIndex: 0, txRaw: txRaw) + print(witness) + } .padding() .background(Color.blue) From 46e7028f90ed16fd1ee34e6a19397c4a6209e100 Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 12 Dec 2024 12:47:35 +0700 Subject: [PATCH 23/32] update readme --- rust/README.md | 108 +++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/rust/README.md b/rust/README.md index 35dfbdb..2c21108 100644 --- a/rust/README.md +++ b/rust/README.md @@ -14,56 +14,61 @@ The library exposes the `mwrust` namespace with the following functions and type ### Functions -#### `gen_phrase(u32 word_count) -> string` +#### `genPhrase(wordCount: UInt32) -> String` Generates a mnemonic phrase with the specified word count. - **Parameters**: - - `word_count`: Number of words in the generated mnemonic phrase (e.g., 12, 15, 24). + - `wordCount`: Number of words in the generated mnemonic phrase (e.g., 12, 15, 24). - **Returns**: - - A string containing the generated mnemonic phrase. + - A `String` containing the generated mnemonic phrase. #### Example: -```cpp -string phrase = mwrust::gen_phrase(12); +```swift +let phrase = genPhrase(wordCount: 12) ``` --- -#### `create_wallet(string phrase, string password, string network_env) -> MinWallet` +#### `createWallet(phrase: String, password: String, networkEnv: String) -> MinWallet` Creates a wallet based on the provided mnemonic phrase, password, and network environment. - **Parameters**: - `phrase`: The mnemonic phrase used to derive the wallet. - `password`: A user-defined password for encrypting the wallet's private key. - - `network_env`: The network environment for the wallet (e.g., `"mainnet"` or `"preprod"`). + - `networkEnv`: The network environment for the wallet (e.g., `"mainnet"` or `"preprod"`). - **Returns**: - A `MinWallet` object containing wallet details. #### Example: -```cpp -MinWallet wallet = mwrust::create_wallet( - "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", - "secure_password", - "testnet" -); +```swift +let wallet = createWallet( + phrase: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + password: "secure_password", + networkEnv: "preprod" +) ``` --- -#### `sign_tx(MinWallet wallet, string password, u32 account_index, string tx_raw) -> string` +#### `signTx(wallet: MinWallet, password: String, accountIndex: UInt32, txRaw: String) -> String` Signs a raw transaction using the provided wallet. - **Parameters**: - `wallet`: A `MinWallet` object containing wallet details. - `password`: The password used to decrypt the wallet's private key. - - `account_index`: The account index to sign the transaction from (default `account_index = 0`). - - `tx_raw`: The raw transaction string to be signed. + - `accountIndex`: The account index to sign the transaction from (default `accountIndex = 0`). + - `txRaw`: The raw transaction string to be signed. - **Returns**: - - A signed transaction string. + - A signed transaction `String`. #### Example: -```cpp -string signed_tx = mwrust::sign_tx(wallet, "secure_password", 0, "raw_tx_data"); +```swift +let signedTx = signTx( + wallet: wallet, + password: "secure_password", + accountIndex: 0, + txRaw: "raw_tx_data" +) ``` --- @@ -71,57 +76,46 @@ string signed_tx = mwrust::sign_tx(wallet, "secure_password", 0, "raw_tx_data"); ### Types #### `MinWallet` -A dictionary object containing details of a wallet. +A dictionary-like object containing details of a wallet. - **Fields**: - - `address` (`string`): The wallet's address. - - `network_id` (`u32`): The ID of the network the wallet belongs to (e.g., `1` for mainnet). - - `account_index` (`u32`): The account index within the wallet. - - `encrypted_key` (`string`): The wallet's encrypted private key. + - `address` (`String`): The wallet's address. + - `networkId` (`UInt32`): The ID of the network the wallet belongs to (mainnet: 764824073, preprod: 1). + - `accountIndex` (`UInt32`): The account index within the wallet. + - `encryptedKey` (`UInt32`): The wallet's encrypted private key. #### Example: -```cpp -MinWallet wallet = { - "address": "addr_test1...", - "network_id": 0, - "account_index": 0, - "encrypted_key": "" -}; +```swift +let wallet = MinWallet( + address: "addr_test1...", + networkId: 1, + accountIndex: 0, + encryptedKey: "" +) ``` ## Usage Examples ### Generate a Mnemonic Phrase -```cpp -string phrase = mwrust::gen_phrase(24); +```swift +let phrase = genPhrase(wordCount: UInt32) -> String ``` ### Create a Wallet -```cpp -MinWallet wallet = mwrust::create_wallet( - "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", - "secure_password", - "mainnet" -); +```swift +let wallet = createWallet( + phrase: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + password: "secure_password", + networkEnv: "preprod" +) ``` ### Sign a Transaction -```cpp -string signed_tx = mwrust::sign_tx( - wallet, - "secure_password", - 0, - "raw_tx_data" -); +```swift +let signedTx = signTx( + wallet: wallet, + password: "secure_password", + accountIndex: 0, + txRaw: "raw_tx_data" +) ``` - -## Requirements -- C++ compiler -- Rust integration (if applicable for `mwrust` implementation) - -## License -This library is licensed under the MIT License. See the LICENSE file for more details. - -## Contributing -Contributions are welcome! Please open an issue or submit a pull request on the repository. - From b181fc2536ad97051984e4793b916f3339f9c2db Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 16:20:30 +0700 Subject: [PATCH 24/32] update --- .github/workflows/ci.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6b7cf6b..3700d92 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,5 +23,19 @@ jobs: run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Lint run: swift format lint --strict -r -p MinWallet + build-and-test: + runs-on: macos-latest + steps: + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.0.2" + - uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ssh-strict: true + - name: Select Xcode + run: sudo xcode-select -switch /Applications/Xcode_16.1.app + - name: Build rust + run: cd rust && ./build.sh - name: Build and test run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file From b1653bcaa7e3a21ef59e7deb9c96d1f3de6e2051 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 16:42:34 +0700 Subject: [PATCH 25/32] add cache for rust --- .github/workflows/ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3700d92..0ba0ad8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,6 +35,11 @@ jobs: ssh-strict: true - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app + - name: Setup rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + workspaces: rust + target: aarch64-apple-ios-sim,aarch64-apple-ios - name: Build rust run: cd rust && ./build.sh - name: Build and test From c3989972ccc39a4c976c3a82fc9909184ac2b5de Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 16:45:20 +0700 Subject: [PATCH 26/32] update --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0ba0ad8..0feb8ba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,7 +38,7 @@ jobs: - name: Setup rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - workspaces: rust + cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios - name: Build rust run: cd rust && ./build.sh From 99517d251984a50ac9af91fedbdab53de741fe8c Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 16:57:45 +0700 Subject: [PATCH 27/32] update --- .github/workflows/beta.yaml | 12 +++++++++--- .github/workflows/ci.yaml | 9 ++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index 46fb849..018dd1f 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -15,18 +15,24 @@ jobs: - uses: webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - uses: SwiftyLab/setup-swift@latest - with: - swift-version: "6.0.2" - uses: actions/checkout@v4 with: ssh-key: ${{ secrets.DEPLOY_KEY }} ssh-strict: true + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.0.2" - uses: ruby/setup-ruby@v1 with: bundler-cache: true + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache-workspaces: rust + target: aarch64-apple-ios-sim,aarch64-apple-ios - name: Install Dependencies run: bundle install + - name: Build rust + run: cd rust && ./build.sh - name: Build run: bundle exec fastlane beta env: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0feb8ba..95e2e8f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,17 +26,16 @@ jobs: build-and-test: runs-on: macos-latest steps: - - uses: SwiftyLab/setup-swift@latest - with: - swift-version: "6.0.2" - uses: actions/checkout@v4 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} ssh-strict: true + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.0.2" - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app - - name: Setup rust - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios From 8c6e44e95c12ebb94148c9c22a82f67da426776b Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 17:07:53 +0700 Subject: [PATCH 28/32] update --- .github/workflows/beta.yaml | 3 +++ .github/workflows/ci.yaml | 17 ++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index 018dd1f..cec6e29 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -29,6 +29,9 @@ jobs: with: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios + cache-directories: | + ios + bindings - name: Install Dependencies run: bundle install - name: Build rust diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 95e2e8f..d969848 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,13 +12,13 @@ jobs: lint: runs-on: macos-latest steps: - - uses: SwiftyLab/setup-swift@latest - with: - swift-version: "6.0.2" - uses: actions/checkout@v4 with: ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} ssh-strict: true + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.0.2" - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Lint @@ -33,13 +33,16 @@ jobs: - uses: SwiftyLab/setup-swift@latest with: swift-version: "6.0.2" - - name: Select Xcode - run: sudo xcode-select -switch /Applications/Xcode_16.1.app - uses: actions-rust-lang/setup-rust-toolchain@v1 with: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios + cache-directories: | + ios + bindings + - name: Select Xcode + run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build rust run: cd rust && ./build.sh - - name: Build and test - run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file + # - name: Build and test + # run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file From 249b50a0ad8b46e335ff8d6351b40f658c7963c6 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 17:13:42 +0700 Subject: [PATCH 29/32] update --- .github/workflows/ci.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d969848..96b77a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,9 +13,6 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-strict: true - uses: SwiftyLab/setup-swift@latest with: swift-version: "6.0.2" @@ -27,9 +24,6 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-strict: true - uses: SwiftyLab/setup-swift@latest with: swift-version: "6.0.2" @@ -38,8 +32,8 @@ jobs: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios cache-directories: | - ios - bindings + ./ios + ./bindings - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build rust From f2ffd5a6ef4363041f83871c6cd47003af253994 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 17:23:41 +0700 Subject: [PATCH 30/32] update --- .github/workflows/beta.yaml | 3 --- .github/workflows/ci.yaml | 9 +++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index cec6e29..018dd1f 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -29,9 +29,6 @@ jobs: with: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios - cache-directories: | - ios - bindings - name: Install Dependencies run: bundle install - name: Build rust diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 96b77a0..192b136 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,12 +31,9 @@ jobs: with: cache-workspaces: rust target: aarch64-apple-ios-sim,aarch64-apple-ios - cache-directories: | - ./ios - ./bindings - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build rust - run: cd rust && ./build.sh - # - name: Build and test - # run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file + run: ./rust/build.sh + - name: Build and test + run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file From 93e6b57806b74cc77dd16889432424bb9949fde8 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 17:25:34 +0700 Subject: [PATCH 31/32] update --- .github/workflows/beta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index 018dd1f..dbf2c50 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -32,7 +32,7 @@ jobs: - name: Install Dependencies run: bundle install - name: Build rust - run: cd rust && ./build.sh + run: ./rust/build.sh - name: Build run: bundle exec fastlane beta env: From 5c1eacc30167ab18071a481fddc6f008070948a4 Mon Sep 17 00:00:00 2001 From: Khanh Le Date: Thu, 12 Dec 2024 17:32:20 +0700 Subject: [PATCH 32/32] update --- .github/workflows/beta.yaml | 2 +- .github/workflows/ci.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index dbf2c50..018dd1f 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -32,7 +32,7 @@ jobs: - name: Install Dependencies run: bundle install - name: Build rust - run: ./rust/build.sh + run: cd rust && ./build.sh - name: Build run: bundle exec fastlane beta env: diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 192b136..5ab9131 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,6 +34,6 @@ jobs: - name: Select Xcode run: sudo xcode-select -switch /Applications/Xcode_16.1.app - name: Build rust - run: ./rust/build.sh + run: cd rust && ./build.sh - name: Build and test run: xcodebuild -scheme MinWallet CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED="NO" -disable-concurrent-destination-testing test -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro Max,OS=18.1" \ No newline at end of file