pub fn is_config_compliant(
        &self,
        chain_name: &str,
        config: &DeployConfig,
        max_associated_keys: u32,
    ) -> Result<(), DeployConfigurationFailure> {
        self.is_valid_size(config.max_deploy_size)?;

        let header = self.header();
        if header.chain_name() != chain_name {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                chain_name = %header.chain_name(),
                "invalid chain identifier"
            );
            return Err(DeployConfigurationFailure::InvalidChainName {
                expected: chain_name.to_string(),
                got: header.chain_name().to_string(),
            });
        }

        if header.dependencies().len() > config.max_dependencies as usize {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                max_dependencies = %config.max_dependencies,
                "deploy dependency ceiling exceeded"
            );
            return Err(DeployConfigurationFailure::ExcessiveDependencies {
                max_dependencies: config.max_dependencies,
                got: header.dependencies().len(),
            });
        }

        if header.ttl() > config.max_ttl {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                max_ttl = %config.max_ttl,
                "deploy ttl excessive"
            );
            return Err(DeployConfigurationFailure::ExcessiveTimeToLive {
                max_ttl: config.max_ttl,
                got: header.ttl(),
            });
        }

        if self.approvals.len() > max_associated_keys as usize {
            info!(
                deploy_hash = %self.id(),
                number_of_associated_keys = %self.approvals.len(),
                max_associated_keys = %max_associated_keys,
                "number of associated keys exceeds the maximum limit"
            );
            return Err(DeployConfigurationFailure::ExcessiveApprovals {
                got: self.approvals.len() as u32,
                max_associated_keys,
            });
        }

        // Transfers have a fixed cost and won't blow the block gas limit.
        // Other deploys can, therefore, statically check the payment amount
        // associated with the deploy.
        if !self.session().is_transfer() {
            let value = self
                .payment()
                .args()
                .get(ARG_AMOUNT)
                .ok_or(DeployConfigurationFailure::MissingPaymentAmount)?;
            let payment_amount = value
                .clone()
                .into_t::<U512>()
                .map_err(|_| DeployConfigurationFailure::FailedToParsePaymentAmount)?;
            if payment_amount > U512::from(config.block_gas_limit) {
                info!(
                    amount = %payment_amount,
                    block_gas_limit = %config.block_gas_limit, "payment amount exceeds block gas limit"
                );
                return Err(DeployConfigurationFailure::ExceededBlockGasLimit {
                    block_gas_limit: config.block_gas_limit,
                    got: payment_amount,
                });
            }
        }

        let payment_args_length = self.payment().args().serialized_length();
        if payment_args_length > config.payment_args_max_length as usize {
            info!(
                payment_args_length,
                payment_args_max_length = config.payment_args_max_length,
                "payment args excessive"
            );
            return Err(DeployConfigurationFailure::ExcessivePaymentArgsLength {
                max_length: config.payment_args_max_length as usize,
                got: payment_args_length,
            });
        }

        let session_args_length = self.session().args().serialized_length();
        if session_args_length > config.session_args_max_length as usize {
            info!(
                session_args_length,
                session_args_max_length = config.session_args_max_length,
                "session args excessive"
            );
            return Err(DeployConfigurationFailure::ExcessiveSessionArgsLength {
                max_length: config.session_args_max_length as usize,
                got: session_args_length,
            });
        }

        if self.session().is_transfer() {
            let item = self.session().clone();
            let attempted = item
                .args()
                .get(ARG_AMOUNT)
                .ok_or_else(|| {
                    info!("missing transfer 'amount' runtime argument");
                    DeployConfigurationFailure::MissingTransferAmount
                })?
                .clone()
                .into_t::<U512>()
                .map_err(|_| {
                    info!("failed to parse transfer 'amount' runtime argument as a U512");
                    DeployConfigurationFailure::FailedToParseTransferAmount
                })?;
            let minimum = U512::from(config.native_transfer_minimum_motes);
            if attempted < minimum {
                info!(
                    minimum = %config.native_transfer_minimum_motes,
                    amount = %attempted,
                    "insufficient transfer amount"
                );
                return Err(DeployConfigurationFailure::InsufficientTransferAmount {
                    minimum,
                    attempted,
                });
            }
        }

        Ok(())
    }
/// Returns true if and only if:
///   * the chain_name is correct,
///   * the configured parameters are complied with,
Returns true if and only if:
the chain_name is correct,
the configured parameters are complied with.
Returns true if and only if : the chain_name is correct the configured parameters are complied with .
pub fn is_config_compliant(
        &self,
        chain_name: &str,
        config: &DeployConfig,
        max_associated_keys: u32,
    ) -> Result<(), DeployConfigurationFailure> {
        self.is_valid_size(config.max_deploy_size)?;
        let header = self.header();
        if header.chain_name() != chain_name {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                chain_name = %header.chain_name(),
                "invalid chain identifier"
            );
            return Err(DeployConfigurationFailure::InvalidChainName {
                expected: chain_name.to_string(),
                got: header.chain_name().to_string(),
            });
        }
        if header.dependencies().len() > config.max_dependencies as usize {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                max_dependencies = %config.max_dependencies,
                "deploy dependency ceiling exceeded"
            );
            return Err(DeployConfigurationFailure::ExcessiveDependencies {
                max_dependencies: config.max_dependencies,
                got: header.dependencies().len(),
            });
        }
        if header.ttl() > config.max_ttl {
            info!(
                deploy_hash = %self.id(),
                deploy_header = %header,
                max_ttl = %config.max_ttl,
                "deploy ttl excessive"
            );
            return Err(DeployConfigurationFailure::ExcessiveTimeToLive {
                max_ttl: config.max_ttl,
                got: header.ttl(),
            });
        }
        if self.approvals.len() > max_associated_keys as usize {
            info!(
                deploy_hash = %self.id(),
                number_of_associated_keys = %self.approvals.len(),
                max_associated_keys = %max_associated_keys,
                "number of associated keys exceeds the maximum limit"
            );
            return Err(DeployConfigurationFailure::ExcessiveApprovals {
                got: self.approvals.len() as u32,
                max_associated_keys,
            });
        }
        // Transfers have a fixed cost and won't blow the block gas limit.
        // Other deploys can, therefore, statically check the payment amount
        // associated with the deploy.
        if !self.session().is_transfer() {
            let value = self
                .payment()
                .args()
                .get(ARG_AMOUNT)
                .ok_or(DeployConfigurationFailure::MissingPaymentAmount)?;
            let payment_amount = value
                .clone()
                .into_t::<U512>()
                .map_err(|_| DeployConfigurationFailure::FailedToParsePaymentAmount)?;
            if payment_amount > U512::from(config.block_gas_limit) {
                info!(
                    amount = %payment_amount,
                    block_gas_limit = %config.block_gas_limit, "payment amount exceeds block gas limit"
                );
                return Err(DeployConfigurationFailure::ExceededBlockGasLimit {
                    block_gas_limit: config.block_gas_limit,
                    got: payment_amount,
                });
            }
        }
        let payment_args_length = self.payment().args().serialized_length();
        if payment_args_length > config.payment_args_max_length as usize {
            info!(
                payment_args_length,
                payment_args_max_length = config.payment_args_max_length,
                "payment args excessive"
            );
            return Err(DeployConfigurationFailure::ExcessivePaymentArgsLength {
                max_length: config.payment_args_max_length as usize,
                got: payment_args_length,
            });
        }
        let session_args_length = self.session().args().serialized_length();
        if session_args_length > config.session_args_max_length as usize {
            info!(
                session_args_length,
                session_args_max_length = config.session_args_max_length,
                "session args excessive"
            );
            return Err(DeployConfigurationFailure::ExcessiveSessionArgsLength {
                max_length: config.session_args_max_length as usize,
                got: session_args_length,
            });
        }
        if self.session().is_transfer() {
            let item = self.session().clone();
            let attempted = item
                .args()
                .get(ARG_AMOUNT)
                .ok_or_else(|| {
                    info!("missing transfer 'amount' runtime argument");
                    DeployConfigurationFailure::MissingTransferAmount
                })?
                .clone()
                .into_t::<U512>()
                .map_err(|_| {
                    info!("failed to parse transfer 'amount' runtime argument as a U512");
                    DeployConfigurationFailure::FailedToParseTransferAmount
                })?;
            let minimum = U512::from(config.native_transfer_minimum_motes);
            if attempted < minimum {
                info!(
                    minimum = %config.native_transfer_minimum_motes,
                    amount = %attempted,
                    "insufficient transfer amount"
                );
                return Err(DeployConfigurationFailure::InsufficientTransferAmount {
                    minimum,
                    attempted,
                });
            }
        }
        Ok(())
    }
pub fn is_config_compliant ( & self , chain_name : & str , config : & DeployConfig , max_associated_keys : u32 , ) -> Result < ( ) , DeployConfigurationFailure > { self . is_valid_size ( config . max_deploy_size ) ? ; let header = self . header ( ) ; if header . chain_name ( ) != chain_name { info ! ( deploy_hash self id ( ) deploy_header header chain_name header chain_name ( ) " " ) ; return Err ( DeployConfigurationFailure :: InvalidChainName { expected : chain_name . to_string ( ) , got : header . chain_name ( ) . to_string ( ) , } ) ; } if header . dependencies ( ) . len ( ) > config . max_dependencies as usize { info ! ( deploy_hash self id ( ) deploy_header header max_dependencies config max_dependencies " " ) ; return Err ( DeployConfigurationFailure :: ExcessiveDependencies { max_dependencies : config . max_dependencies , got : header . dependencies ( ) . len ( ) , } ) ; } if header . ttl ( ) > config . max_ttl { info ! ( deploy_hash self id ( ) deploy_header header max_ttl config max_ttl " " ) ; return Err ( DeployConfigurationFailure :: ExcessiveTimeToLive { max_ttl : config . max_ttl , got : header . ttl ( ) , } ) ; } if self . approvals . len ( ) > max_associated_keys as usize { info ! ( deploy_hash self id ( ) number_of_associated_keys self approvals len ( ) max_associated_keys max_associated_keys " " ) ; return Err ( DeployConfigurationFailure :: ExcessiveApprovals { got : self . approvals . len ( ) as u32 , max_associated_keys , } ) ; } // Transfers have a fixed cost and won't blow the block gas limit. // Other deploys can, therefore, statically check the payment amount // associated with the deploy. if ! self . session ( ) . is_transfer ( ) { let value = self . payment ( ) . args ( ) . get ( ARG_AMOUNT ) . ok_or ( DeployConfigurationFailure :: MissingPaymentAmount ) ? ; let payment_amount = value . clone ( ) . into_t :: < U512 > ( ) . map_err ( | _ | DeployConfigurationFailure :: FailedToParsePaymentAmount ) ? ; if payment_amount > U512 :: from ( config . block_gas_limit ) { info ! ( amount payment_amount block_gas_limit config block_gas_limit " " ) ; return Err ( DeployConfigurationFailure :: ExceededBlockGasLimit { block_gas_limit : config . block_gas_limit , got : payment_amount , } ) ; } } let payment_args_length = self . payment ( ) . args ( ) . serialized_length ( ) ; if payment_args_length > config . payment_args_max_length as usize { info ! ( payment_args_length payment_args_max_length config payment_args_max_length " " ) ; return Err ( DeployConfigurationFailure :: ExcessivePaymentArgsLength { max_length : config . payment_args_max_length as usize , got : payment_args_length , } ) ; } let session_args_length = self . session ( ) . args ( ) . serialized_length ( ) ; if session_args_length > config . session_args_max_length as usize { info ! ( session_args_length session_args_max_length config session_args_max_length " " ) ; return Err ( DeployConfigurationFailure :: ExcessiveSessionArgsLength { max_length : config . session_args_max_length as usize , got : session_args_length , } ) ; } if self . session ( ) . is_transfer ( ) { let item = self . session ( ) . clone ( ) ; let attempted = item . args ( ) . get ( ARG_AMOUNT ) . ok_or_else ( | | { info ! ( " " ) ; DeployConfigurationFailure :: MissingTransferAmount } ) ? . clone ( ) . into_t :: < U512 > ( ) . map_err ( | _ | { info ! ( " " ) ; DeployConfigurationFailure :: FailedToParseTransferAmount } ) ? ; let minimum = U512 :: from ( config . native_transfer_minimum_motes ) ; if attempted < minimum { info ! ( minimum config native_transfer_minimum_motes amount attempted " " ) ; return Err ( DeployConfigurationFailure :: InsufficientTransferAmount { minimum , attempted , } ) ; } } Ok ( ( ) ) }
Returns true if and only if:
 the chain_name is correct,
 the configured parameters are complied with,
Returns true if and only if : the chain_name is correct the configured parameters are complied with
&self
chain_name
&str
config
&DeployConfig
max_associated_keys
u32
&self
chain_name
&str
config
&DeployConfig
max_associated_keys
u32