From f312aa349606d3bb0f49a01086bee60e5e9d434e Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 1 Nov 2024 18:40:45 +0100 Subject: [PATCH] resolvers: remove consignment-based resolver Closes #280 --- src/containers/consignment.rs | 5 ---- src/lib.rs | 1 - src/resolvers.rs | 54 ----------------------------------- 3 files changed, 60 deletions(-) delete mode 100644 src/resolvers.rs diff --git a/src/containers/consignment.rs b/src/containers/consignment.rs index f76d4162..d1e85fcd 100644 --- a/src/containers/consignment.rs +++ b/src/containers/consignment.rs @@ -49,7 +49,6 @@ use super::{ }; use crate::interface::{Iface, IfaceImpl}; use crate::persistence::{MemContract, MemContractState}; -use crate::resolvers::ConsignmentResolver; use crate::{SecretSeal, LIB_NAME_RGB_STD}; pub type Transfer = Consignment; @@ -331,10 +330,6 @@ impl Consignment { testnet: bool, ) -> Result, (validation::Status, Consignment)> { let index = IndexedConsignment::new(&self); - let resolver = ConsignmentResolver { - consignment: &index, - fallback: resolver, - }; let mut status = Validator::, _, _>::validate( &index, &resolver, diff --git a/src/lib.rs b/src/lib.rs index d428aa06..746c7ac4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,7 +41,6 @@ pub mod stl; pub mod interface; pub mod containers; pub mod persistence; -pub mod resolvers; mod contract; pub mod info; diff --git a/src/resolvers.rs b/src/resolvers.rs deleted file mode 100644 index 76dc5e7b..00000000 --- a/src/resolvers.rs +++ /dev/null @@ -1,54 +0,0 @@ -// RGB standard library for working with smart contracts on Bitcoin & Lightning -// -// SPDX-License-Identifier: Apache-2.0 -// -// Written in 2019-2024 by -// Dr Maxim Orlovsky -// -// Copyright (C) 2019-2024 LNP/BP Standards Association. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use rgb::validation::{ResolveWitness, WitnessResolverError}; -use rgb::vm::{WitnessOrd, XWitnessId, XWitnessTx}; - -use crate::containers::IndexedConsignment; - -// TODO: Implement caching witness resolver - -pub(crate) struct ConsignmentResolver<'cons, R: ResolveWitness, const TRANSFER: bool> { - pub consignment: &'cons IndexedConsignment<'cons, TRANSFER>, - pub fallback: R, -} - -impl<'cons, R: ResolveWitness, const TRANSFER: bool> ResolveWitness - for ConsignmentResolver<'cons, R, TRANSFER> -{ - fn resolve_pub_witness( - &self, - witness_id: XWitnessId, - ) -> Result { - self.consignment - .pub_witness(witness_id) - .and_then(|p| p.map_ref(|pw| pw.tx().cloned()).transpose()) - .ok_or(WitnessResolverError::Unknown(witness_id)) - .or_else(|_| self.fallback.resolve_pub_witness(witness_id)) - } - - fn resolve_pub_witness_ord( - &self, - witness_id: XWitnessId, - ) -> Result { - self.fallback.resolve_pub_witness_ord(witness_id) - } -}