diff --git a/Cargo.lock b/Cargo.lock index fe59be48..9e226ce5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.10.0-rc.2" -source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.10.0-release#9c9afc5262596ebe6f25c404cde99c55b63a2b6d" +source = "git+https://github.com/RGB-WG/rgb-core?branch=v0.10.0-release#40d4af5ecde086ed6eb6e6f1ca1c28d2599b48de" dependencies = [ "aluvm", "amplify", diff --git a/src/pay.rs b/src/pay.rs index 3e80e2b2..6348439d 100644 --- a/src/pay.rs +++ b/src/pay.rs @@ -188,7 +188,7 @@ pub trait InventoryWallet: Inventory { } let transition = main_builder .add_raw_state(assignment_id, beneficiary, TypedState::Amount(invoice.value))? - .complete_transition()?; + .complete_transition(contract_id)?; // 3. Prepare and self-consume other transitions let mut contract_inputs = HashMap::>::new(); @@ -221,7 +221,7 @@ pub trait InventoryWallet: Inventory { .add_raw_state(opout.ty, seal, state)?; } - other_transitions.insert(id, blank_builder.complete_transition()?); + other_transitions.insert(id, blank_builder.complete_transition(contract_id)?); } // 4. Add transitions to PSBT diff --git a/std/src/containers/consignment.rs b/std/src/containers/consignment.rs index 0dca4f15..b8493d15 100644 --- a/std/src/containers/consignment.rs +++ b/std/src/containers/consignment.rs @@ -194,8 +194,8 @@ impl Consignment { if *used { continue; } - for opout in &transition.inputs { - if opout.op == *id { + for input in &transition.inputs { + if input.prev_out.op == *id { *used = true; if let Some(ord) = ordered_extensions.get_mut(id) { if *ord > ord_txid { diff --git a/std/src/interface/builder.rs b/std/src/interface/builder.rs index e15abafe..769ad257 100644 --- a/std/src/interface/builder.rs +++ b/std/src/interface/builder.rs @@ -26,9 +26,9 @@ use amplify::{confinement, Wrapper}; use bp::secp256k1::rand::thread_rng; use bp::Chain; use rgb::{ - Assign, AssignmentType, Assignments, ExposedSeal, FungibleType, Genesis, GenesisSeal, - GlobalState, GraphSeal, Opout, PrevOuts, RevealedValue, StateSchema, SubSchema, Transition, - TransitionType, TypedAssigns, BLANK_TRANSITION_ID, + Assign, AssignmentType, Assignments, ContractId, ExposedSeal, FungibleType, Genesis, + GenesisSeal, GlobalState, GraphSeal, Input, Inputs, Opout, RevealedValue, StateSchema, + SubSchema, Transition, TransitionType, TypedAssigns, BLANK_TRANSITION_ID, }; use strict_encoding::{SerializeError, StrictSerialize, TypeName}; use strict_types::decode; @@ -139,7 +139,7 @@ impl ContractBuilder { pub struct TransitionBuilder { builder: OperationBuilder, transition_type: Option, - inputs: PrevOuts, + inputs: Inputs, } impl TransitionBuilder { @@ -156,7 +156,7 @@ impl TransitionBuilder { } pub fn add_input(mut self, opout: Opout) -> Result { - self.inputs.push(opout)?; + self.inputs.push(Input::with(opout))?; Ok(self) } @@ -251,13 +251,14 @@ impl TransitionBuilder { .ok_or(BuilderError::NoOperationSubtype) } - pub fn complete_transition(self) -> Result { + pub fn complete_transition(self, contract_id: ContractId) -> Result { let transition_type = self.transition_type()?; let (_, _, global, assignments) = self.builder.complete(); let transition = Transition { ffv: none!(), + contract_id, transition_type, metadata: empty!(), globals: global, diff --git a/std/src/persistence/inventory.rs b/std/src/persistence/inventory.rs index bafb72e4..6644320b 100644 --- a/std/src/persistence/inventory.rs +++ b/std/src/persistence/inventory.rs @@ -463,14 +463,14 @@ pub trait Inventory: Deref { // 3. Collect all state transitions between terminals and genesis let mut ids = vec![]; for transition in transitions.values() { - ids.extend(transition.prev_outs().iter().map(|opout| opout.op)); + ids.extend(transition.inputs().iter().map(|input| input.prev_out.op)); } while let Some(id) = ids.pop() { if id == contract_id { continue; // we skip genesis since it will be present anywhere } let transition = self.transition(id)?; - ids.extend(transition.prev_outs().iter().map(|opout| opout.op)); + ids.extend(transition.inputs().iter().map(|input| input.prev_out.op)); transitions.insert(id, transition.clone()); anchored_bundles .entry(id)