/// Create a Request to Fetch Metadata
Create a Request to Fetch Metadata
Create a Request to Fetch Metadata
pub async fn construction_preprocess(
        &self,
        msg: models::ConstructionPreprocessRequest,
    ) -> Result<ConstructionPreprocessResponse, ApiError> {
        verify_network_id(self.ledger.ledger_canister_id(), &msg.network_identifier)?;
        let transfers = convert::from_operations(&msg.operations, true, self.ledger.token_name())?;
        let options = Some(ConstructionMetadataRequestOptions {
            request_types: transfers
                .iter()
                .map(|r| r.request_type())
                .collect::<Result<_, _>>()?,
        });
        let required_public_keys: Result<HashSet<ledger_canister::AccountIdentifier>, ApiError> =
            transfers
                .into_iter()
                .map(|transfer| match transfer {
                    Request::Transfer(Operation::Transfer { from, .. }) => Ok(from),
                    Request::Stake(Stake { account, .. })
                    | Request::SetDissolveTimestamp(SetDissolveTimestamp { account, .. })
                    | Request::StartDissolve(StartDissolve { account, .. })
                    | Request::StopDissolve(StopDissolve { account, .. })
                    | Request::Disburse(Disburse { account, .. })
                    | Request::AddHotKey(AddHotKey { account, .. })
                    | Request::Spawn(Spawn { account, .. })
                    | Request::MergeMaturity(MergeMaturity { account, .. }) => Ok(account),
                    Request::Transfer(Operation::Burn { .. }) => Err(ApiError::invalid_request(
                        "Burn operations are not supported through rosetta",
                    )),
                    Request::Transfer(Operation::Mint { .. }) => Err(ApiError::invalid_request(
                        "Mint operations are not supported through rosetta",
                    )),
                })
                .collect();
        let keys: Vec<_> = required_public_keys?
            .into_iter()
            .map(|x| to_model_account_identifier(&x))
            .collect();
        Ok(ConstructionPreprocessResponse {
            required_public_keys: Some(keys),
            options,
        })
    }
pub async fn construction_preprocess ( & self , msg : models :: ConstructionPreprocessRequest , ) -> Result < ConstructionPreprocessResponse , ApiError > { verify_network_id ( self . ledger . ledger_canister_id ( ) , & msg . network_identifier ) ? ; let transfers = convert :: from_operations ( & msg . operations , true , self . ledger . token_name ( ) ) ? ; let options = Some ( ConstructionMetadataRequestOptions { request_types : transfers . iter ( ) . map ( | r | r . request_type ( ) ) . collect :: < Result < _ , _ > > ( ) ? , } ) ; let required_public_keys : Result < HashSet < ledger_canister :: AccountIdentifier > , ApiError > = transfers . into_iter ( ) . map ( | transfer | match transfer { Request :: Transfer ( Operation :: Transfer { from , .. } ) => Ok ( from ) , Request :: Stake ( Stake { account , .. } ) | Request :: SetDissolveTimestamp ( SetDissolveTimestamp { account , .. } ) | Request :: StartDissolve ( StartDissolve { account , .. } ) | Request :: StopDissolve ( StopDissolve { account , .. } ) | Request :: Disburse ( Disburse { account , .. } ) | Request :: AddHotKey ( AddHotKey { account , .. } ) | Request :: Spawn ( Spawn { account , .. } ) | Request :: MergeMaturity ( MergeMaturity { account , .. } ) => Ok ( account ) , Request :: Transfer ( Operation :: Burn { .. } ) => Err ( ApiError :: invalid_request ( " " , ) ) , Request :: Transfer ( Operation :: Mint { .. } ) => Err ( ApiError :: invalid_request ( " " , ) ) , } ) . collect ( ) ; let keys : Vec < _ > = required_public_keys ? . into_iter ( ) . map ( | x | to_model_account_identifier ( & x ) ) . collect ( ) ; Ok ( ConstructionPreprocessResponse { required_public_keys : Some ( keys ) , options , } ) }
Create a Request to Fetch Metadata
Create a Request to Fetch Metadata
&self
msg
models::ConstructionPreprocessRequest