pub fn from_asset(
        asset: &Asset,
        table_asset: &SqlAsset,
        connection: &SqliteConnection,
    ) -> Result<Vec<Self>, SqlCacheError> {
        // get the last issue and increase id from there
        let last_issue = sql_issue_table
            .load::<SqlIssue>(connection)?
            .last()
            .cloned();

        let asset_issues = asset.known_issues();

        let mut result = vec![];

        for (index, issue) in asset_issues.into_iter().enumerate() {
            result.push(Self {
                id: match last_issue.clone() {
                    Some(issue) => issue.id + index as i32 + 1,
                    None => 0 + index as i32,
                },
                sql_asset_id: table_asset.id,
                node_id: issue.id().to_hex(),
                contract_id: issue.asset_id().to_hex(),
                amount: issue.amount().accounting_value() as i64,
                origin_txid: match issue.origin() {
                    Some(outpoint) => Some(outpoint.txid.to_hex()),
                    None => None,
                },
                origin_vout: match issue.origin() {
                    Some(outpoint) => Some(outpoint.vout as i32),
                    None => None,
                },
            })
        }
        Ok(result)
    }
/// Create vectro of Issue table entries from a given Asset data
Create vectro of Issue table entries from a given Asset data
Create vectro of Issue table entries from a given Asset data
pub fn from_asset(
        asset: &Asset,
        table_asset: &SqlAsset,
        connection: &SqliteConnection,
    ) -> Result<Vec<Self>, SqlCacheError> {
        // get the last issue and increase id from there
        let last_issue = sql_issue_table
            .load::<SqlIssue>(connection)?
            .last()
            .cloned();
        let asset_issues = asset.known_issues();
        let mut result = vec![];
        for (index, issue) in asset_issues.into_iter().enumerate() {
            result.push(Self {
                id: match last_issue.clone() {
                    Some(issue) => issue.id + index as i32 + 1,
                    None => 0 + index as i32,
                },
                sql_asset_id: table_asset.id,
                node_id: issue.id().to_hex(),
                contract_id: issue.asset_id().to_hex(),
                amount: issue.amount().accounting_value() as i64,
                origin_txid: match issue.origin() {
                    Some(outpoint) => Some(outpoint.txid.to_hex()),
                    None => None,
                },
                origin_vout: match issue.origin() {
                    Some(outpoint) => Some(outpoint.vout as i32),
                    None => None,
                },
            })
        }
        Ok(result)
    }
pub fn from_asset ( asset : & Asset , table_asset : & SqlAsset , connection : & SqliteConnection , ) -> Result < Vec < Self > , SqlCacheError > { // get the last issue and increase id from there let last_issue = sql_issue_table . load :: < SqlIssue > ( connection ) ? . last ( ) . cloned ( ) ; let asset_issues = asset . known_issues ( ) ; let mut result = vec ! [ ] ; for ( index , issue ) in asset_issues . into_iter ( ) . enumerate ( ) { result . push ( Self { id : match last_issue . clone ( ) { Some ( issue ) => issue . id + index as i32 + 1 , None => 0 + index as i32 , } , sql_asset_id : table_asset . id , node_id : issue . id ( ) . to_hex ( ) , contract_id : issue . asset_id ( ) . to_hex ( ) , amount : issue . amount ( ) . accounting_value ( ) as i64 , origin_txid : match issue . origin ( ) { Some ( outpoint ) => Some ( outpoint . txid . to_hex ( ) ) , None => None , } , origin_vout : match issue . origin ( ) { Some ( outpoint ) => Some ( outpoint . vout as i32 ) , None => None , } , } ) } Ok ( result ) }
Create vectro of Issue table entries from a given Asset data
Create vectro of Issue table entries from a given Asset data
asset
&Asset
table_asset
&SqlAsset
connection
&SqliteConnection
asset
&Asset
table_asset
&SqlAsset
connection
&SqliteConnection