pub fn try_from_envelope(
        request_type: RequestType,
        signed_transaction: &HttpRequestEnvelope<HttpSubmitContent>,
    ) -> Result<TransactionIdentifier, ApiError> {
        match request_type {
            RequestType::Send => {
                let HttpSubmitContent::Call { update } = &signed_transaction.content;
                let from = PrincipalId::try_from(update.sender.clone().0)
                    .map_err(|e| ApiError::internal_error(e.to_string()))?;
                let SendArgs {
                    memo,
                    amount,
                    fee,
                    from_subaccount,
                    to,
                    created_at_time,
                } = convert::from_arg(update.arg.clone().0)?;
                let created_at_time = created_at_time.ok_or_else(|| ApiError::internal_error(
                    "A transaction ID cannot be generated from a constructed transaction without an explicit 'created_at_time'"
            ))?;

                let from = ledger_canister::AccountIdentifier::new(from, from_subaccount);

                let hash = Transaction::new(from, to, amount, fee, memo, created_at_time).hash();

                Ok(TransactionIdentifier::from(&hash))
            }
            RequestType::Stake { .. }
            | RequestType::StartDissolve { .. }
            | RequestType::StopDissolve { .. }
            | RequestType::SetDissolveTimestamp { .. }
            | RequestType::Disburse { .. }
            | RequestType::AddHotKey { .. }
            | RequestType::Spawn { .. }
            | RequestType::MergeMaturity { .. } => {
                // Unfortunately, staking operations don't really have a transaction ID
                Ok(TransactionIdentifier {
                    hash: NEURON_MANAGEMEN_PSEUDO_HASH.to_string(),
                })
            }
        }
    }
/// This could be `TryFrom<&HttpRequestEnvelope<HttpSubmitContent>>`,
/// but double checking `RequestType` instead of using the canister method
/// string is nice.
This could be `TryFrom<&HttpRequestEnvelope>`,
but double checking `RequestType` instead of using the canister method
string is nice.
This could be ` TryFrom<&HttpRequestEnvelope > ` but double checking ` RequestType ` instead of using the canister method string is nice .
pub fn try_from_envelope(
        request_type: RequestType,
        signed_transaction: &HttpRequestEnvelope<HttpSubmitContent>,
    ) -> Result<TransactionIdentifier, ApiError> {
        match request_type {
            RequestType::Send => {
                let HttpSubmitContent::Call { update } = &signed_transaction.content;
                let from = PrincipalId::try_from(update.sender.clone().0)
                    .map_err(|e| ApiError::internal_error(e.to_string()))?;
                let SendArgs {
                    memo,
                    amount,
                    fee,
                    from_subaccount,
                    to,
                    created_at_time,
                } = convert::from_arg(update.arg.clone().0)?;
                let created_at_time = created_at_time.ok_or_else(|| ApiError::internal_error(
                    "A transaction ID cannot be generated from a constructed transaction without an explicit 'created_at_time'"
            ))?;
                let from = ledger_canister::AccountIdentifier::new(from, from_subaccount);
                let hash = Transaction::new(from, to, amount, fee, memo, created_at_time).hash();
                Ok(TransactionIdentifier::from(&hash))
            }
            RequestType::Stake { .. }
            | RequestType::StartDissolve { .. }
            | RequestType::StopDissolve { .. }
            | RequestType::SetDissolveTimestamp { .. }
            | RequestType::Disburse { .. }
            | RequestType::AddHotKey { .. }
            | RequestType::Spawn { .. }
            | RequestType::MergeMaturity { .. } => {
                // Unfortunately, staking operations don't really have a transaction ID
                Ok(TransactionIdentifier {
                    hash: NEURON_MANAGEMEN_PSEUDO_HASH.to_string(),
                })
            }
        }
    }
pub fn try_from_envelope ( request_type : RequestType , signed_transaction : & HttpRequestEnvelope < HttpSubmitContent > , ) -> Result < TransactionIdentifier , ApiError > { match request_type { RequestType :: Send => { let HttpSubmitContent :: Call { update } = & signed_transaction . content ; let from = PrincipalId :: try_from ( update . sender . clone ( ) . 0 ) . map_err ( | e | ApiError :: internal_error ( e . to_string ( ) ) ) ? ; let SendArgs { memo , amount , fee , from_subaccount , to , created_at_time , } = convert :: from_arg ( update . arg . clone ( ) . 0 ) ? ; let created_at_time = created_at_time . ok_or_else ( | | ApiError :: internal_error ( " " ) ) ? ; let from = ledger_canister :: AccountIdentifier :: new ( from , from_subaccount ) ; let hash = Transaction :: new ( from , to , amount , fee , memo , created_at_time ) . hash ( ) ; Ok ( TransactionIdentifier :: from ( & hash ) ) } RequestType :: Stake { .. } | RequestType :: StartDissolve { .. } | RequestType :: StopDissolve { .. } | RequestType :: SetDissolveTimestamp { .. } | RequestType :: Disburse { .. } | RequestType :: AddHotKey { .. } | RequestType :: Spawn { .. } | RequestType :: MergeMaturity { .. } => { // Unfortunately, staking operations don't really have a transaction ID Ok ( TransactionIdentifier { hash : NEURON_MANAGEMEN_PSEUDO_HASH . to_string ( ) , } ) } } }
This could be `TryFrom<&HttpRequestEnvelope<HttpSubmitContent>>`,
but double checking `RequestType` instead of using the canister method
string is nice.
This could be ` TryFrom<&HttpRequestEnvelope<HttpSubmitContent >> ` but double checking ` RequestType ` instead of using the canister method string is nice .
request_type
RequestType
signed_transaction
&HttpRequestEnvelope<HttpSubmitContent>
request_type
RequestType
signed_transaction
&HttpRequestEnvelope<HttpSubmitContent>