From c6c125abee832d5ff0e1cd43f3bff4ee7fbf66a7 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 17 Apr 2024 22:56:44 +0200 Subject: [PATCH 1/3] iface: complete deterministic builder. Closes #111 --- src/interface/builder.rs | 387 +++++++++++++++++++++++++++++++++------ 1 file changed, 326 insertions(+), 61 deletions(-) diff --git a/src/interface/builder.rs b/src/interface/builder.rs index 27d2abb4..a45609f3 100644 --- a/src/interface/builder.rs +++ b/src/interface/builder.rs @@ -153,6 +153,21 @@ impl ContractBuilder { } } + pub fn deterministic( + iface: Iface, + schema: Schema, + iimpl: IfaceImpl, + types: TypeSystem, + scripts: Scripts, + ) -> Self { + Self { + builder: OperationBuilder::deterministic(iface, schema, iimpl, types), + testnet: true, + alt_layers1: none!(), + scripts, + } + } + pub fn type_system(&self) -> &TypeSystem { self.builder.type_system() } pub fn set_mainnet(mut self) -> Self { @@ -232,32 +247,29 @@ impl ContractBuilder { mut self, name: impl Into, seal: impl Into>, - value: u64, + value: impl Into, ) -> Result { let name = name.into(); let seal = seal.into(); self.check_layer1(seal.layer1())?; - let type_id = self - .builder - .assignments_type(&name) - .ok_or(BuilderError::AssignmentNotFound(name.clone()))?; - let tag = match self.builder.asset_tags.get(&type_id) { - Some(asset_tag) => *asset_tag, - None => { - let asset_tag = AssetTag::new_random( - format!( - "{}/{}", - self.builder.schema.schema_id(), - self.builder.iface.iface_id() - ), - type_id, - ); - self.builder.asset_tags.insert(type_id, asset_tag)?; - asset_tag - } - }; + self.builder.init_asset_tag(name.clone())?; + self.builder = self.builder.add_fungible_state(name, seal, value)?; + Ok(self) + } - self.builder = self.builder.add_fungible_state(name, seal, value, tag)?; + pub fn add_fungible_state_det( + mut self, + name: impl Into, + seal: impl Into>, + value: impl Into, + blinding: BlindingFactor, + ) -> Result { + let name = name.into(); + let seal = seal.into(); + self.check_layer1(seal.layer1())?; + let tag = self.builder.init_asset_tag(name.clone())?; + let state = RevealedValue::with_blinding(value.into(), blinding, tag); + self.builder = self.builder.add_fungible_state_det(name, seal, state)?; Ok(self) } @@ -273,6 +285,18 @@ impl ContractBuilder { Ok(self) } + pub fn add_data_det( + mut self, + name: impl Into, + seal: impl Into>, + data: RevealedData, + ) -> Result { + let seal = seal.into(); + self.check_layer1(seal.layer1())?; + self.builder = self.builder.add_data_det(name, seal, data)?; + Ok(self) + } + pub fn add_attachment( mut self, name: impl Into, @@ -285,7 +309,23 @@ impl ContractBuilder { Ok(self) } + pub fn add_attachment_det( + mut self, + name: impl Into, + seal: impl Into>, + attachment: RevealedAttach, + ) -> Result { + let seal = seal.into(); + self.check_layer1(seal.layer1())?; + self.builder = self.builder.add_attachment_det(name, seal, attachment)?; + Ok(self) + } + pub fn issue_contract(self) -> Result, BuilderError> { + debug_assert!( + !self.builder.deterministic, + "for issuing deterministic contracts please use issue_contract_det method" + ); self.issue_contract_det(Utc::now().timestamp()) } @@ -293,6 +333,14 @@ impl ContractBuilder { self, timestamp: i64, ) -> Result, BuilderError> { + debug_assert!( + self.builder.deterministic, + "for issuing deterministic contracts please use deterministic constructor" + ); + self.issue_contract_raw(timestamp) + } + + fn issue_contract_raw(self, timestamp: i64) -> Result, BuilderError> { let (schema, iface, iimpl, global, assignments, types, asset_tags) = self.builder.complete(None); @@ -361,6 +409,16 @@ impl TransitionBuilder { Self::with(contract_id, iface, schema, iimpl, TransitionType::BLANK, types) } + pub fn blank_transition_det( + contract_id: ContractId, + iface: Iface, + schema: Schema, + iimpl: IfaceImpl, + types: TypeSystem, + ) -> Self { + Self::deterministic(contract_id, iface, schema, iimpl, TransitionType::BLANK, types) + } + pub fn default_transition( contract_id: ContractId, iface: Iface, @@ -376,6 +434,21 @@ impl TransitionBuilder { Ok(Self::with(contract_id, iface, schema, iimpl, transition_type, types)) } + pub fn default_transition_det( + contract_id: ContractId, + iface: Iface, + schema: Schema, + iimpl: IfaceImpl, + types: TypeSystem, + ) -> Result { + let transition_type = iface + .default_operation + .as_ref() + .and_then(|name| iimpl.transition_type(name)) + .ok_or(BuilderError::NoOperationSubtype)?; + Ok(Self::deterministic(contract_id, iface, schema, iimpl, transition_type, types)) + } + pub fn named_transition( contract_id: ContractId, iface: Iface, @@ -391,6 +464,21 @@ impl TransitionBuilder { Ok(Self::with(contract_id, iface, schema, iimpl, transition_type, types)) } + pub fn named_transition_det( + contract_id: ContractId, + iface: Iface, + schema: Schema, + iimpl: IfaceImpl, + transition_name: impl Into, + types: TypeSystem, + ) -> Result { + let transition_name = transition_name.into(); + let transition_type = iimpl + .transition_type(&transition_name) + .ok_or(BuilderError::TransitionNotFound(transition_name))?; + Ok(Self::deterministic(contract_id, iface, schema, iimpl, transition_type, types)) + } + fn with( contract_id: ContractId, iface: Iface, @@ -407,6 +495,22 @@ impl TransitionBuilder { } } + fn deterministic( + contract_id: ContractId, + iface: Iface, + schema: Schema, + iimpl: IfaceImpl, + transition_type: TransitionType, + types: TypeSystem, + ) -> Self { + Self { + contract_id, + builder: OperationBuilder::deterministic(iface, schema, iimpl, types), + transition_type, + inputs: none!(), + } + } + pub fn type_system(&self) -> &TypeSystem { self.builder.type_system() } pub fn transition_type(&self) -> TransitionType { self.transition_type } @@ -506,24 +610,32 @@ impl TransitionBuilder { self.add_fungible_state(assignment_name, seal.into(), value) } - pub fn add_fungible_state_raw( + pub fn add_fungible_default_state_det( + self, + seal: impl Into>, + value: u64, + blinding: BlindingFactor, + ) -> Result { + let assignment_name = self.default_assignment()?.clone(); + self.add_fungible_state_det(assignment_name, seal.into(), value, blinding) + } + + pub fn add_fungible_state( mut self, - type_id: AssignmentType, + name: impl Into, seal: impl Into>, value: impl Into, - blinding: BlindingFactor, ) -> Result { - let tag = self.builder.asset_tag_raw(type_id)?; - let state = RevealedValue::with_blinding(value.into(), blinding, tag); - self.builder = self.builder.add_fungible_state_raw(type_id, seal, state)?; + self.builder = self.builder.add_fungible_state(name.into(), seal, value)?; Ok(self) } - pub fn add_fungible_state( + pub fn add_fungible_state_det( mut self, name: impl Into, seal: impl Into>, - value: u64, + value: impl Into, + blinding: BlindingFactor, ) -> Result { let name = name.into(); let type_id = self @@ -531,8 +643,22 @@ impl TransitionBuilder { .assignments_type(&name) .ok_or(BuilderError::AssignmentNotFound(name.clone()))?; let tag = self.builder.asset_tag_raw(type_id)?; + let state = RevealedValue::with_blinding(value.into(), blinding, tag); - self.builder = self.builder.add_fungible_state(name, seal, value, tag)?; + self.builder = self.builder.add_fungible_state_det(name, seal, state)?; + Ok(self) + } + + pub fn add_fungible_state_raw( + mut self, + type_id: AssignmentType, + seal: impl Into>, + value: impl Into, + blinding: BlindingFactor, + ) -> Result { + let tag = self.builder.asset_tag_raw(type_id)?; + let state = RevealedValue::with_blinding(value.into(), blinding, tag); + self.builder = self.builder.add_fungible_state_raw(type_id, seal, state)?; Ok(self) } @@ -546,6 +672,16 @@ impl TransitionBuilder { Ok(self) } + pub fn add_data_det( + mut self, + name: impl Into, + seal: impl Into>, + data: RevealedData, + ) -> Result { + self.builder = self.builder.add_data_det(name, seal, data)?; + Ok(self) + } + pub fn add_data_raw( mut self, type_id: AssignmentType, @@ -577,6 +713,16 @@ impl TransitionBuilder { Ok(self) } + pub fn add_attachment_det( + mut self, + name: impl Into, + seal: impl Into>, + attachment: RevealedAttach, + ) -> Result { + self.builder = self.builder.add_attachment_det(name, seal, attachment)?; + Ok(self) + } + pub fn complete_transition(self) -> Result { let (_, _, _, global, assignments, _, _) = self.builder.complete(Some(&self.inputs)); @@ -606,6 +752,7 @@ pub struct OperationBuilder { iface: Iface, iimpl: IfaceImpl, asset_tags: AssetTags, + deterministic: bool, global: GlobalState, rights: TinyOrdMap>, 1, U16>>, @@ -625,6 +772,25 @@ impl OperationBuilder { iface, iimpl, asset_tags: none!(), + deterministic: false, + + global: none!(), + rights: none!(), + fungible: none!(), + attachments: none!(), + data: none!(), + + types, + } + } + + fn deterministic(iface: Iface, schema: Schema, iimpl: IfaceImpl, types: TypeSystem) -> Self { + OperationBuilder { + schema, + iface, + iimpl, + asset_tags: none!(), + deterministic: true, global: none!(), rights: none!(), @@ -702,6 +868,24 @@ impl OperationBuilder { Ok(self) } + pub fn init_asset_tag(&mut self, name: impl Into) -> Result { + let name = name.into(); + let type_id = self + .assignments_type(&name) + .ok_or(BuilderError::AssignmentNotFound(name))?; + + if let Some(tag) = self.asset_tags.get(&type_id) { + Ok(*tag) + } else { + let asset_tag = AssetTag::new_random( + format!("{}/{}", self.schema.schema_id(), self.iface.iface_id()), + type_id, + ); + self.asset_tags.insert(type_id, asset_tag)?; + Ok(asset_tag) + } + } + // TODO: Add methods for adding metadata pub fn add_global_state( @@ -742,6 +926,11 @@ impl OperationBuilder { seal: impl Into>, state: PersistedState, ) -> Result { + debug_assert!( + self.deterministic, + "to add owned state in deterministic way the builder has to be created using `*_det` \ + constructor" + ); let name = name.into(); let type_id = self .assignments_type(&name) @@ -779,6 +968,20 @@ impl OperationBuilder { } } + fn add_rights( + self, + name: impl Into, + seal: impl Into>, + ) -> Result { + let name = name.into(); + + let type_id = self + .assignments_type(&name) + .ok_or(BuilderError::AssignmentNotFound(name))?; + + self.add_rights_raw(type_id, seal) + } + fn add_rights_raw( mut self, type_id: AssignmentType, @@ -802,18 +1005,46 @@ impl OperationBuilder { Ok(self) } - fn add_rights( + fn add_fungible_state( self, name: impl Into, seal: impl Into>, + value: impl Into, ) -> Result { + debug_assert!( + !self.deterministic, + "for adding state to deterministic contracts you have to use add_*_det methods" + ); + let name = name.into(); let type_id = self .assignments_type(&name) .ok_or(BuilderError::AssignmentNotFound(name))?; + let tag = self.asset_tag_raw(type_id)?; - self.add_rights_raw(type_id, seal) + let state = RevealedValue::new_random_blinding(value.into(), tag); + self.add_fungible_state_raw(type_id, seal, state) + } + + fn add_fungible_state_det( + self, + name: impl Into, + seal: impl Into>, + state: RevealedValue, + ) -> Result { + debug_assert!( + self.deterministic, + "to add owned state in deterministic way the builder has to be created using `*_det` \ + constructor" + ); + + let name = name.into(); + + let type_id = self + .assignments_type(&name) + .ok_or(BuilderError::AssignmentNotFound(name))?; + self.add_fungible_state_raw(type_id, seal, state) } fn add_fungible_state_raw( @@ -841,21 +1072,46 @@ impl OperationBuilder { Ok(self) } - fn add_fungible_state( + fn add_data( self, name: impl Into, seal: impl Into>, - value: u64, - tag: AssetTag, + value: impl StrictSerialize, ) -> Result { + debug_assert!( + !self.deterministic, + "for adding state to deterministic contracts you have to use add_*_det methods" + ); + let name = name.into(); + let serialized = value.to_strict_serialized::()?; + let state = DataState::from(serialized); let type_id = self .assignments_type(&name) .ok_or(BuilderError::AssignmentNotFound(name))?; - let state = RevealedValue::new_random_blinding(value, tag); - self.add_fungible_state_raw(type_id, seal, state) + self.add_data_raw(type_id, seal, RevealedData::new_random_salt(state)) + } + + fn add_data_det( + self, + name: impl Into, + seal: impl Into>, + state: RevealedData, + ) -> Result { + debug_assert!( + self.deterministic, + "to add owned state in deterministic way the builder has to be created using `*_det` \ + constructor" + ); + + let name = name.into(); + let type_id = self + .assignments_type(&name) + .ok_or(BuilderError::AssignmentNotFound(name))?; + + self.add_data_raw(type_id, seal, state) } fn add_data_raw( @@ -881,21 +1137,49 @@ impl OperationBuilder { Ok(self) } - fn add_data( + fn add_attachment( self, name: impl Into, seal: impl Into>, - value: impl StrictSerialize, + state: AttachedState, ) -> Result { + debug_assert!( + !self.deterministic, + "for adding state to deterministic contracts you have to use add_*_det methods" + ); + let name = name.into(); - let serialized = value.to_strict_serialized::()?; - let state = DataState::from(serialized); let type_id = self .assignments_type(&name) .ok_or(BuilderError::AssignmentNotFound(name))?; - self.add_data_raw(type_id, seal, RevealedData::new_random_salt(state)) + self.add_attachment_raw( + type_id, + seal, + RevealedAttach::new_random_salt(state.id, state.media_type), + ) + } + + fn add_attachment_det( + self, + name: impl Into, + seal: impl Into>, + state: RevealedAttach, + ) -> Result { + debug_assert!( + self.deterministic, + "to add owned state in deterministic way the builder has to be created using `*_det` \ + constructor" + ); + + let name = name.into(); + + let type_id = self + .assignments_type(&name) + .ok_or(BuilderError::AssignmentNotFound(name))?; + + self.add_attachment_raw(type_id, seal, state) } fn add_attachment_raw( @@ -922,25 +1206,6 @@ impl OperationBuilder { Ok(self) } - fn add_attachment( - self, - name: impl Into, - seal: impl Into>, - state: AttachedState, - ) -> Result { - let name = name.into(); - - let type_id = self - .assignments_type(&name) - .ok_or(BuilderError::AssignmentNotFound(name))?; - - self.add_attachment_raw( - type_id, - seal, - RevealedAttach::new_random_salt(state.id, state.media_type), - ) - } - fn complete( self, inputs: Option<&TinyOrdMap>, From 6341d2a240ef612571b20fd7c18423f960453146 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 19 Apr 2024 20:57:01 +0200 Subject: [PATCH 2/3] iface: fix deterministic contract issuance --- src/interface/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interface/builder.rs b/src/interface/builder.rs index a45609f3..52169171 100644 --- a/src/interface/builder.rs +++ b/src/interface/builder.rs @@ -326,7 +326,7 @@ impl ContractBuilder { !self.builder.deterministic, "for issuing deterministic contracts please use issue_contract_det method" ); - self.issue_contract_det(Utc::now().timestamp()) + self.issue_contract_raw(Utc::now().timestamp()) } pub fn issue_contract_det( From 5ffe44195176abab8eb9160f69f30a23794d25a3 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 22 Apr 2024 12:15:00 +0200 Subject: [PATCH 3/3] chore: fix dependnecies --- Cargo.lock | 113 +++++++++++++++++++++++--------------- src/interface/builder.rs | 3 +- src/interface/contract.rs | 4 +- 3 files changed, 72 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 164fb445..812fff16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,10 +5,10 @@ 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", + "ascii-armor 0.2.0", "baid58", "blake3", "getrandom", @@ -132,6 +132,19 @@ dependencies = [ "strict_encoding", ] +[[package]] +name = "ascii-armor" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44ce552de9efa4fdee1a7920f3587e17689bf4a4ba149a7892f91820673c1e29" +dependencies = [ + "amplify", + "baid58", + "base85", + "sha2", + "strict_encoding", +] + [[package]] name = "autocfg" version = "1.2.0" @@ -230,7 +243,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#722dd940ccb231faeab249a64a782d7f90fba935" dependencies = [ "amplify", "chrono", @@ -244,7 +257,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#722dd940ccb231faeab249a64a782d7f90fba935" dependencies = [ "amplify", "bp-consensus", @@ -262,7 +275,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#722dd940ccb231faeab249a64a782d7f90fba935" dependencies = [ "amplify", "base85", @@ -288,7 +301,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#722dd940ccb231faeab249a64a782d7f90fba935" dependencies = [ "amplify", "baid58", @@ -309,9 +322,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" [[package]] name = "cfg-if" @@ -321,9 +334,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 +349,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#f51e1e0d010b1531acc939d2443af552e8755bb7" dependencies = [ "amplify", "amplify_syn", @@ -348,7 +361,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#f51e1e0d010b1531acc939d2443af552e8755bb7" dependencies = [ "amplify", "commit_encoding_derive", @@ -596,9 +609,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", ] @@ -645,11 +658,11 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#f071856b400dca9b2a708399869a840094864ad1" +source = "git+https://github.com/RGB-WG/rgb-core?branch=script-refactor#938248bb981bc4a82f06cc0e694c3c7f9e4dcda7" dependencies = [ "aluvm", "amplify", - "ascii-armor", + "ascii-armor 0.2.0", "baid58", "bp-core", "chrono", @@ -687,7 +700,7 @@ version = "0.11.0-beta.5" dependencies = [ "aluvm", "amplify", - "ascii-armor", + "ascii-armor 0.2.0", "baid58", "base85", "bp-core", @@ -801,29 +814,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,15 +889,16 @@ 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#f51e1e0d010b1531acc939d2443af552e8755bb7" dependencies = [ "amplify_derive", ] [[package]] name = "strict_encoding" -version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" +version = "2.7.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c463f8ea993e323740d78544473e791adb91ac659f5bf2c1a59db64a34f99fc" dependencies = [ "amplify", "half", @@ -894,8 +908,9 @@ dependencies = [ [[package]] name = "strict_encoding_derive" -version = "2.7.0-beta.1" -source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" +version = "2.7.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "475fa6f1fdde6e0555422b5111ad34bde30a1459af3599f920c3af9829772c0e" dependencies = [ "amplify_syn", "heck", @@ -906,11 +921,11 @@ dependencies = [ [[package]] name = "strict_types" -version = "2.7.0-beta.2" -source = "git+https://github.com/strict-types/strict-types?branch=develop#2e6b57b7b46efe9b6db430b56ba4a83f2c7776be" +version = "2.7.0-beta.3" +source = "git+https://github.com/strict-types/strict-types?branch=develop#acc3a7508c49c34c3344e2dd4359e1ade08fae67" dependencies = [ "amplify", - "ascii-armor", + "ascii-armor 0.3.0", "baid58", "half", "indexmap", @@ -946,9 +961,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", @@ -957,22 +972,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -998,9 +1013,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap", "serde", @@ -1070,7 +1085,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -1104,7 +1119,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1137,7 +1152,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.60", ] [[package]] @@ -1231,3 +1246,13 @@ checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] + +[[patch.unused]] +name = "strict_encoding" +version = "2.7.0-beta.1" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" + +[[patch.unused]] +name = "strict_encoding_derive" +version = "2.7.0-beta.1" +source = "git+https://github.com/strict-types/strict-encoding?branch=rstring#89ea1c2f02402cbda8bbe78ae9a629446f84e474" diff --git a/src/interface/builder.rs b/src/interface/builder.rs index 52169171..b52803dd 100644 --- a/src/interface/builder.rs +++ b/src/interface/builder.rs @@ -914,8 +914,7 @@ impl OperationBuilder { .sem_id; self.types.strict_deserialize_type(sem_id, &serialized)?; - self.global - .add_state(type_id, RevealedData::new_random_salt(serialized))?; + self.global.add_state(type_id, serialized.into())?; Ok(self) } diff --git a/src/interface/contract.rs b/src/interface/contract.rs index 68dbe6bb..be5539e0 100644 --- a/src/interface/contract.rs +++ b/src/interface/contract.rs @@ -258,9 +258,9 @@ impl ContractIface { let state = unsafe { self.state.global_unchecked(type_id) }; let state = state .into_iter() - .map(|revealed| { + .map(|data| { self.types - .strict_deserialize_type(type_schema.sem_id, revealed.value.as_ref()) + .strict_deserialize_type(type_schema.sem_id, data.as_ref()) .map(TypedVal::unbox) }) .take(type_schema.max_items as usize)