Skip to content

Commit

Permalink
feat: support for UDA payments
Browse files Browse the repository at this point in the history
  • Loading branch information
crisdut committed May 26, 2024
1 parent 4a498cc commit f5b731e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/pay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ use rgbstd::containers::Transfer;
use rgbstd::interface::{OutpointFilter, WitnessFilter};
use rgbstd::invoice::{Amount, Beneficiary, InvoiceState, RgbInvoice};
use rgbstd::persistence::{IndexProvider, StashProvider, StateProvider, Stock};
use rgbstd::{ContractId, XChain, XOutpoint};
use rgbstd::{ContractId, DataState, XChain, XOutpoint};

use crate::invoice::NonFungible;
use crate::wallet::WalletWrapper;
use crate::{CompletionError, CompositionError, DescriptorRgb, PayError, RgbKeychain, Txid};

Expand Down Expand Up @@ -182,6 +183,22 @@ where Self::Descr: DescriptorRgb<K>
.map(|(_, seal, _)| *seal)
.collect::<BTreeSet<_>>()
}
InvoiceState::Data(NonFungible::RGB21(allocation)) => {
let filter = ContractOutpointsFilter {
contract_id,
stock,
wallet: self,
_phantom: PhantomData,
};
let state = contract.data(assignment_name, &filter)?.collect::<Vec<_>>();

let data_state = DataState::from(allocation);
state
.into_iter()
.filter(|x| x.state == data_state)
.map(|x| x.seal)
.collect::<BTreeSet<_>>()

Check warning on line 200 in src/pay.rs

View check run for this annotation

Codecov / codecov/patch

src/pay.rs#L186-L200

Added lines #L186 - L200 were not covered by tests
}
_ => return Err(CompositionError::Unsupported),
};
let beneficiaries = match invoice.beneficiary.into_inner() {
Expand Down

0 comments on commit f5b731e

Please sign in to comment.