Skip to content

Commit

Permalink
iface: make history methods free of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 20, 2024
1 parent d5170f9 commit 4edbacf
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/interface/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,27 +400,26 @@ impl<S: ContractStateRead> ContractIface<S> {
&self,
filter_outpoints: impl AssignmentsFilter + Clone,
filter_witnesses: impl AssignmentsFilter + Clone,
) -> Result<Vec<ContractOp>, ContractError> {
Ok(self
.history_fungible(filter_outpoints.clone(), filter_witnesses.clone())?
) -> Vec<ContractOp> {
self.history_fungible(filter_outpoints.clone(), filter_witnesses.clone())
.into_iter()
.map(ContractOp::Fungible)
.chain(
self.history_rights(filter_outpoints.clone(), filter_witnesses.clone())?
self.history_rights(filter_outpoints.clone(), filter_witnesses.clone())
.into_iter()
.map(ContractOp::Rights),
)
.chain(
self.history_data(filter_outpoints.clone(), filter_witnesses.clone())?
self.history_data(filter_outpoints.clone(), filter_witnesses.clone())
.into_iter()
.map(ContractOp::Data),
)
.chain(
self.history_attach(filter_outpoints, filter_witnesses)?
self.history_attach(filter_outpoints, filter_witnesses)
.into_iter()
.map(ContractOp::Attach),
)
.collect())
.collect()
}

Check warning on line 423 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L399-L423

Added lines #L399 - L423 were not covered by tests

fn operations<
Expand All @@ -433,7 +432,7 @@ impl<S: ContractStateRead> ContractIface<S> {
state: impl Fn(&'c S) -> I,
filter_outpoints: impl AssignmentsFilter,
filter_witnesses: impl AssignmentsFilter,
) -> Result<Vec<Op>, ContractError>
) -> Vec<Op>

Check warning on line 435 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L432-L435

Added lines #L432 - L435 were not covered by tests
where
Op::State: From<T>,

Check warning on line 437 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L437

Added line #L437 was not covered by tests
{
Expand Down Expand Up @@ -505,38 +504,38 @@ impl<S: ContractStateRead> ContractIface<S> {
};
}

Ok(ops)
ops
}

pub fn history_fungible(
&self,
filter_outpoints: impl AssignmentsFilter,
filter_witnesses: impl AssignmentsFilter,
) -> Result<Vec<FungibleOp>, ContractError> {
) -> Vec<FungibleOp> {
self.operations(|state| state.fungible_all(), filter_outpoints, filter_witnesses)

Check warning on line 515 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L510-L515

Added lines #L510 - L515 were not covered by tests
}

pub fn history_rights(
&self,
filter_outpoints: impl AssignmentsFilter,
filter_witnesses: impl AssignmentsFilter,
) -> Result<Vec<NonFungibleOp<VoidState>>, ContractError> {
) -> Vec<NonFungibleOp<VoidState>> {
self.operations(|state| state.rights_all(), filter_outpoints, filter_witnesses)

Check warning on line 523 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L518-L523

Added lines #L518 - L523 were not covered by tests
}

pub fn history_data(
&self,
filter_outpoints: impl AssignmentsFilter,
filter_witnesses: impl AssignmentsFilter,
) -> Result<Vec<NonFungibleOp<DataState>>, ContractError> {
) -> Vec<NonFungibleOp<DataState>> {
self.operations(|state| state.data_all(), filter_outpoints, filter_witnesses)

Check warning on line 531 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L526-L531

Added lines #L526 - L531 were not covered by tests
}

pub fn history_attach(
&self,
filter_outpoints: impl AssignmentsFilter,
filter_witnesses: impl AssignmentsFilter,
) -> Result<Vec<NonFungibleOp<AttachState>>, ContractError> {
) -> Vec<NonFungibleOp<AttachState>> {
self.operations(|state| state.attach_all(), filter_outpoints, filter_witnesses)
}

Check warning on line 540 in src/interface/contract.rs

View check run for this annotation

Codecov / codecov/patch

src/interface/contract.rs#L534-L540

Added lines #L534 - L540 were not covered by tests

Expand Down

0 comments on commit 4edbacf

Please sign in to comment.