Skip to content

Commit

Permalink
chore: update to latest RGB core
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Apr 9, 2023
1 parent 80bd970 commit f7f50b7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ContractId, Vec<Outpoint>>::new();
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions std/src/containers/consignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ impl<const TYPE: bool> Consignment<TYPE> {
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 {
Expand Down
13 changes: 7 additions & 6 deletions std/src/interface/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,7 +139,7 @@ impl ContractBuilder {
pub struct TransitionBuilder {
builder: OperationBuilder<GraphSeal>,
transition_type: Option<TransitionType>,
inputs: PrevOuts,
inputs: Inputs,
}

impl TransitionBuilder {
Expand All @@ -156,7 +156,7 @@ impl TransitionBuilder {
}

pub fn add_input(mut self, opout: Opout) -> Result<Self, BuilderError> {
self.inputs.push(opout)?;
self.inputs.push(Input::with(opout))?;
Ok(self)
}

Expand Down Expand Up @@ -251,13 +251,14 @@ impl TransitionBuilder {
.ok_or(BuilderError::NoOperationSubtype)
}

pub fn complete_transition(self) -> Result<Transition, BuilderError> {
pub fn complete_transition(self, contract_id: ContractId) -> Result<Transition, BuilderError> {
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,
Expand Down
4 changes: 2 additions & 2 deletions std/src/persistence/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ pub trait Inventory: Deref<Target = Self::Stash> {
// 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)
Expand Down

0 comments on commit f7f50b7

Please sign in to comment.