From c6e78a21f44223172f47fa5479f0fab199145b03 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 15 Jan 2025 12:39:26 +0100 Subject: [PATCH] invoice: use CallScope from sonic library --- Cargo.lock | 74 ++++++++++++++++++++++++---------------------- invoice/src/lib.rs | 34 ++------------------- 2 files changed, 42 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1cb1180..89a10ec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,11 +122,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys", ] @@ -525,7 +526,7 @@ dependencies = [ [[package]] name = "hypersonic" version = "0.12.0-beta.4" -source = "git+https://github.com/AluVM/sonic#13c444a07eae5d2face6a5b5c461513f05082214" +source = "git+https://github.com/AluVM/sonic#ae093ac9c360835621a1e11492b6303cee233a8b" dependencies = [ "aluvm", "amplify", @@ -590,9 +591,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -606,9 +607,9 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" @@ -815,6 +816,12 @@ dependencies = [ "digest", ] +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + [[package]] name = "ryu" version = "1.0.18" @@ -830,12 +837,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "secp256k1" version = "0.30.0" @@ -951,7 +952,7 @@ dependencies = [ [[package]] name = "sonic-api" version = "0.12.0-beta.4" -source = "git+https://github.com/AluVM/sonic#13c444a07eae5d2face6a5b5c461513f05082214" +source = "git+https://github.com/AluVM/sonic#ae093ac9c360835621a1e11492b6303cee233a8b" dependencies = [ "aluvm", "amplify", @@ -970,7 +971,7 @@ dependencies = [ [[package]] name = "sonic-callreq" version = "0.12.0-beta.4" -source = "git+https://github.com/AluVM/sonic#13c444a07eae5d2face6a5b5c461513f05082214" +source = "git+https://github.com/AluVM/sonic#ae093ac9c360835621a1e11492b6303cee233a8b" dependencies = [ "amplify", "baid64", @@ -1130,7 +1131,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ultrasonic" version = "0.12.0-beta.4" -source = "git+https://github.com/AluVM/ultrasonic#8ff8e764bf9f8b5e72965f0eceebb114ca8ec498" +source = "git+https://github.com/AluVM/ultrasonic#32950ebd8c9ec32c8ef469107aab7744a7d37fab" dependencies = [ "amplify", "baid64", @@ -1194,20 +1195,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", @@ -1219,9 +1221,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -1232,9 +1234,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1242,9 +1244,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -1255,19 +1257,21 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.49" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d44563646eb934577f2772656c7ad5e9c90fac78aa8013d776fcdaf24625d" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ "js-sys", "minicov", - "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -1275,9 +1279,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.49" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54171416ce73aa0b9c377b51cc3cb542becee1cd678204812e8392e5b0e4a031" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", @@ -1286,9 +1290,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/invoice/src/lib.rs b/invoice/src/lib.rs index 2f5d5539..aa3c1349 100644 --- a/invoice/src/lib.rs +++ b/invoice/src/lib.rs @@ -38,39 +38,11 @@ use core::fmt::{self, Display, Formatter}; use core::str::FromStr; use baid64::Baid64ParseError; -use hypersonic::{AuthToken, ContractId}; +use hypersonic::AuthToken; use rgbcore::{SealType, UnknownType}; -use sonic_callreq::CallRequest; +use sonic_callreq::{CallRequest, CallScope}; -pub type RgbInvoice = CallRequest; - -#[derive(Clone, Eq, PartialEq, Debug, Display)] -pub enum RgbScope { - #[display(inner)] - ContractId(ContractId), - - #[display("contract:{seal}")] - ContractQuery { seal: SealType, testnet: bool }, -} - -impl FromStr for RgbScope { - type Err = ParseInvoiceError; - - fn from_str(s: &str) -> Result { - if !s.starts_with("contract:") { - return Err(ParseInvoiceError::NoScheme); - } - match ContractId::from_str(s) { - Err(err1) => { - let s = s.trim_start_matches("contract:"); - let query = ContractQuery::from_str(s) - .map_err(|_| ParseInvoiceError::Unrecognizable(err1))?; - Ok(Self::ContractQuery { seal: query.seal, testnet: query.testnet }) - } - Ok(id) => Ok(Self::ContractId(id)), - } - } -} +pub type RgbInvoice = CallRequest; #[derive(Clone, Eq, PartialEq, Debug, Display)] #[display(inner)]