pub fn create_pymtchan(
    from_address: String,
    to_address: String,
    value: String,
    nonce: u64,
    gas_limit: i64,
    gas_fee_cap: String,
    gas_premium: String,
    network: String,
) -> Result<Message, SignerError> {
    let from = fvm_shared::address::Address::from_str(&from_address)?;
    let to = fvm_shared::address::Address::from_str(&to_address)?;

    let create_payment_channel_params = paych::ConstructorParams { from, to };

    let serialized_constructor_params =
        RawBytes::serialize::<paych::ConstructorParams>(create_payment_channel_params)
            .map_err(|err| SignerError::GenericString(err.to_string()))?;

    let cid_string = ACTOR_CODE_CIDS["paymentchannel"][network]
        .as_str()
        .ok_or(SignerError::GenericString("network unknown".to_string()))?;

    let message_params_create_pymtchan = ExecParams {
        code_cid: Cid::from_str(cid_string)?,
        constructor_params: serialized_constructor_params,
    };

    let serialized_params = RawBytes::serialize(message_params_create_pymtchan)
        .map_err(|err| SignerError::GenericString(err.to_string()))?;

    let mut init_actor_address = fvm_shared::address::Address::from_str("f01")?;
    init_actor_address.set_network(from.network());

    let pch_create_message_api = Message {
        version: 0,
        to: init_actor_address,
        from: fvm_shared::address::Address::from_str(&from_address)?,
        sequence: nonce,
        value: fvm_shared::econ::TokenAmount::from_str(&value)?,
        gas_limit,
        gas_fee_cap: fvm_shared::econ::TokenAmount::from_str(&gas_fee_cap)?,
        gas_premium: fvm_shared::econ::TokenAmount::from_str(&gas_premium)?,
        method_num: MethodInit::Exec as u64,
        params: serialized_params,
    };

    Ok(pch_create_message_api)
}
/// Utility function to create a payment channel creation message.  Returns unsigned message.
///
/// # Arguments
///
/// * `from_address` - A string address
/// * `to_address` - A string address
/// * `value` - Amount to put in the payment channel initially
/// * `nonce` - Nonce of the message; should be from_address's MpoolGetNonce() value
///
Utility function to create a payment channel creation message.  Returns unsigned message.
Utility function to create a payment channel creation message . Returns unsigned message .
pub fn create_pymtchan(
    from_address: String,
    to_address: String,
    value: String,
    nonce: u64,
    gas_limit: i64,
    gas_fee_cap: String,
    gas_premium: String,
    network: String,
) -> Result<Message, SignerError> {
    let from = fvm_shared::address::Address::from_str(&from_address)?;
    let to = fvm_shared::address::Address::from_str(&to_address)?;
    let create_payment_channel_params = paych::ConstructorParams { from, to };
    let serialized_constructor_params =
        RawBytes::serialize::<paych::ConstructorParams>(create_payment_channel_params)
            .map_err(|err| SignerError::GenericString(err.to_string()))?;
    let cid_string = ACTOR_CODE_CIDS["paymentchannel"][network]
        .as_str()
        .ok_or(SignerError::GenericString("network unknown".to_string()))?;
    let message_params_create_pymtchan = ExecParams {
        code_cid: Cid::from_str(cid_string)?,
        constructor_params: serialized_constructor_params,
    };
    let serialized_params = RawBytes::serialize(message_params_create_pymtchan)
        .map_err(|err| SignerError::GenericString(err.to_string()))?;
    let mut init_actor_address = fvm_shared::address::Address::from_str("f01")?;
    init_actor_address.set_network(from.network());
    let pch_create_message_api = Message {
        version: 0,
        to: init_actor_address,
        from: fvm_shared::address::Address::from_str(&from_address)?,
        sequence: nonce,
        value: fvm_shared::econ::TokenAmount::from_str(&value)?,
        gas_limit,
        gas_fee_cap: fvm_shared::econ::TokenAmount::from_str(&gas_fee_cap)?,
        gas_premium: fvm_shared::econ::TokenAmount::from_str(&gas_premium)?,
        method_num: MethodInit::Exec as u64,
        params: serialized_params,
    };
    Ok(pch_create_message_api)
}
pub fn create_pymtchan ( from_address : String , to_address : String , value : String , nonce : u64 , gas_limit : i64 , gas_fee_cap : String , gas_premium : String , network : String , ) -> Result < Message , SignerError > { let from = fvm_shared :: address :: Address :: from_str ( & from_address ) ? ; let to = fvm_shared :: address :: Address :: from_str ( & to_address ) ? ; let create_payment_channel_params = paych :: ConstructorParams { from , to } ; let serialized_constructor_params = RawBytes :: serialize :: < paych :: ConstructorParams > ( create_payment_channel_params ) . map_err ( | err | SignerError :: GenericString ( err . to_string ( ) ) ) ? ; let cid_string = ACTOR_CODE_CIDS [ " " ] [ network ] . as_str ( ) . ok_or ( SignerError :: GenericString ( " " . to_string ( ) ) ) ? ; let message_params_create_pymtchan = ExecParams { code_cid : Cid :: from_str ( cid_string ) ? , constructor_params : serialized_constructor_params , } ; let serialized_params = RawBytes :: serialize ( message_params_create_pymtchan ) . map_err ( | err | SignerError :: GenericString ( err . to_string ( ) ) ) ? ; let mut init_actor_address = fvm_shared :: address :: Address :: from_str ( " " ) ? ; init_actor_address . set_network ( from . network ( ) ) ; let pch_create_message_api = Message { version : 0 , to : init_actor_address , from : fvm_shared :: address :: Address :: from_str ( & from_address ) ? , sequence : nonce , value : fvm_shared :: econ :: TokenAmount :: from_str ( & value ) ? , gas_limit , gas_fee_cap : fvm_shared :: econ :: TokenAmount :: from_str ( & gas_fee_cap ) ? , gas_premium : fvm_shared :: econ :: TokenAmount :: from_str ( & gas_premium ) ? , method_num : MethodInit :: Exec as u64 , params : serialized_params , } ; Ok ( pch_create_message_api ) }
Utility function to create a payment channel creation message.
Utility function to create a payment channel creation message .
from_address
String
to_address
String
value
String
nonce
u64
gas_limit
i64
gas_fee_cap
String
gas_premium
String
network
String
from_address
String
to_address
String
value
String
nonce
u64
gas_limit
i64
gas_fee_cap
String
gas_premium
String
network
String