Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: generic Transaction::initial
Fintan Halpenny committed 1 year ago
commit dd5f7396306612665babf751eda5d472470f5496
parent 170915ffcf61406aa1239555625152e6b0649111
1 file changed +6 -3
modified radicle/src/cob/store.rs
@@ -314,20 +314,23 @@ where
    T: Cob + cob::Evaluate<R>,
{
    /// Create a new transaction to be used as the initial set of operations for a COB.
-
    pub fn initial<G, F>(
+
    pub fn initial<G, F, Tx>(
        message: &str,
        store: &mut Store<T, R>,
        signer: &G,
        operations: F,
    ) -> Result<(ObjectId, T), Error>
    where
+
        Tx: From<Self>,
+
        Self: From<Tx>,
        G: Signer,
-
        F: FnOnce(&mut Self, &R) -> Result<(), Error>,
+
        F: FnOnce(&mut Tx, &R) -> Result<(), Error>,
        R: ReadRepository + SignRepository + cob::Store,
        T::Action: Serialize + Clone,
    {
-
        let mut tx = Transaction::default();
+
        let mut tx = Tx::from(Transaction::default());
        operations(&mut tx, store.as_ref())?;
+
        let tx = Self::from(tx);

        let actions = NonEmpty::from_vec(tx.actions)
            .expect("Transaction::initial: transaction must contain at least one action");