From f11cd3930bc8e5d19a509553968459e32e4927ee Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 18 Apr 2024 19:52:27 +0200 Subject: [PATCH] containers: fix anchor set merge-reveal operation Closes #195 --- Cargo.lock | 50 +++++++++++++++++++-------------------- src/containers/anchors.rs | 12 ++++++---- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7642618c..76eacc1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "aluvm" version = "0.11.0-beta.5" -source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#a08387f744f6679b6ee308e70f99099c318824db" +source = "git+https://github.com/AluVM/rust-aluvm?branch=v0.11#d18ea84836a8a96f3dfe61c99b94f2eab1417819" dependencies = [ "amplify", "ascii-armor", @@ -230,7 +230,7 @@ dependencies = [ [[package]] name = "bp-consensus" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#3e373d2926f5519bae39055fbe2864e3fcce2677" dependencies = [ "amplify", "chrono", @@ -244,7 +244,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#3e373d2926f5519bae39055fbe2864e3fcce2677" dependencies = [ "amplify", "bp-consensus", @@ -262,7 +262,7 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#3e373d2926f5519bae39055fbe2864e3fcce2677" dependencies = [ "amplify", "base85", @@ -288,7 +288,7 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.11.0-beta.5" -source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#40d155151b57325ad82edf838196b52ad27af188" +source = "git+https://github.com/BP-WG/bp-core?branch=v0.11#3e373d2926f5519bae39055fbe2864e3fcce2677" dependencies = [ "amplify", "baid58", @@ -321,9 +321,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d04d43504c61aa6c7531f1871dd0d418d91130162063b789da00fd7057a5e" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -336,7 +336,7 @@ dependencies = [ [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#4ca5963fbf6d57138f5b81ebe70aa095a79d0d9d" dependencies = [ "amplify", "amplify_syn", @@ -348,7 +348,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#4ca5963fbf6d57138f5b81ebe70aa095a79d0d9d" dependencies = [ "amplify", "commit_encoding_derive", @@ -596,9 +596,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -801,29 +801,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -876,7 +876,7 @@ dependencies = [ [[package]] name = "single_use_seals" version = "0.11.0-beta.5" -source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#503e5da35642f52b090f7e232a8aeaccb05463cc" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=v0.11#4ca5963fbf6d57138f5b81ebe70aa095a79d0d9d" dependencies = [ "amplify_derive", ] @@ -949,9 +949,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -975,7 +975,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1073,7 +1073,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -1107,7 +1107,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1140,7 +1140,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] diff --git a/src/containers/anchors.rs b/src/containers/anchors.rs index 2d372cca..bebc9676 100644 --- a/src/containers/anchors.rs +++ b/src/containers/anchors.rs @@ -264,21 +264,23 @@ impl AnchorSet { impl AnchorSet { pub fn merge_reveal(self, other: Self) -> Result { match (self, other) { - (Self::Tapret(anchor), Self::Tapret(a)) if a == anchor => Ok(Self::Tapret(anchor)), - (Self::Opret(anchor), Self::Opret(a)) if a == anchor => Ok(Self::Opret(anchor)), + (Self::Tapret(anchor), Self::Tapret(a)) if a.matches(&anchor) => { + Ok(Self::Tapret(anchor)) + } + (Self::Opret(anchor), Self::Opret(a)) if a.matches(&anchor) => Ok(Self::Opret(anchor)), (Self::Tapret(tapret), Self::Opret(opret)) | (Self::Opret(opret), Self::Tapret(tapret)) => Ok(Self::Double { tapret, opret }), (Self::Double { tapret, opret }, Self::Tapret(t)) | (Self::Tapret(t), Self::Double { tapret, opret }) - if tapret == t => + if t.matches(&tapret) => { Ok(Self::Double { tapret, opret }) } (Self::Double { tapret, opret }, Self::Opret(o)) | (Self::Opret(o), Self::Double { tapret, opret }) - if opret == o => + if o.matches(&opret) => { Ok(Self::Double { tapret, opret }) } @@ -289,7 +291,7 @@ impl AnchorSet { tapret: t, opret: o, }, - ) if tapret == t && opret == o => Ok(Self::Double { tapret, opret }), + ) if t.matches(&tapret) && o.matches(&opret) => Ok(Self::Double { tapret, opret }), _ => Err(MergeRevealError::AnchorsMismatch), }