pub async fn send_batch_confirm(
    contact: &Contact,
    eth_private_key: EthPrivateKey,
    fee: Coin,
    transaction_batches: Vec<TransactionBatch>,
    private_key: PrivateKey,
    gravity_id: String,
) -> Result<TxResponse, CosmosGrpcError> {
    let our_address = private_key
        .to_public_key()
        .expect("Invalid private key!")
        .to_address();
    let our_eth_address = eth_private_key.to_public_key().unwrap();

    let fee = Fee {
        amount: vec![fee],
        gas_limit: 500_000_000u64,
        granter: None,
        payer: None,
    };

    let mut messages = Vec::new();

    for batch in transaction_batches {
        trace!("Submitting signature for batch {:?}", batch);
        let message = encode_tx_batch_confirm(gravity_id.clone(), batch.clone());
        let eth_signature = eth_private_key.sign_ethereum_msg(&message);
        trace!(
            "Sending batch update with address {} and sig {}",
            our_eth_address,
            bytes_to_hex_str(&eth_signature.to_bytes())
        );
        let confirm = MsgConfirmBatch {
            token_contract: batch.token_contract.to_string(),
            orchestrator: our_address.to_string(),
            eth_signer: our_eth_address.to_string(),
            nonce: batch.nonce,
            signature: bytes_to_hex_str(&eth_signature.to_bytes()),
        };
        let msg = Msg::new("/gravity.v1.MsgConfirmBatch", confirm);
        messages.push(msg);
    }
    let args = contact.get_message_args(our_address, fee).await?;
    trace!("got optional tx info");

    let msg_bytes = private_key.sign_std_msg(&messages, args, MEMO)?;

    let mut txrpc = TxServiceClient::connect(contact.get_url()).await?;
    let response = txrpc
        .broadcast_tx(BroadcastTxRequest {
            tx_bytes: msg_bytes,
            mode: BroadcastMode::Sync.into(),
        })
        .await?;
    let response = response.into_inner();

    contact
        .wait_for_tx(response.tx_response.unwrap(), TIMEOUT)
        .await
}
/// Send in a confirmation for a specific transaction batch
Send in a confirmation for a specific transaction batch
Send in a confirmation for a specific transaction batch
pub async fn send_batch_confirm(
    contact: &Contact,
    eth_private_key: EthPrivateKey,
    fee: Coin,
    transaction_batches: Vec<TransactionBatch>,
    private_key: PrivateKey,
    gravity_id: String,
) -> Result<TxResponse, CosmosGrpcError> {
    let our_address = private_key
        .to_public_key()
        .expect("Invalid private key!")
        .to_address();
    let our_eth_address = eth_private_key.to_public_key().unwrap();
    let fee = Fee {
        amount: vec![fee],
        gas_limit: 500_000_000u64,
        granter: None,
        payer: None,
    };
    let mut messages = Vec::new();
    for batch in transaction_batches {
        trace!("Submitting signature for batch {:?}", batch);
        let message = encode_tx_batch_confirm(gravity_id.clone(), batch.clone());
        let eth_signature = eth_private_key.sign_ethereum_msg(&message);
        trace!(
            "Sending batch update with address {} and sig {}",
            our_eth_address,
            bytes_to_hex_str(&eth_signature.to_bytes())
        );
        let confirm = MsgConfirmBatch {
            token_contract: batch.token_contract.to_string(),
            orchestrator: our_address.to_string(),
            eth_signer: our_eth_address.to_string(),
            nonce: batch.nonce,
            signature: bytes_to_hex_str(&eth_signature.to_bytes()),
        };
        let msg = Msg::new("/gravity.v1.MsgConfirmBatch", confirm);
        messages.push(msg);
    }
    let args = contact.get_message_args(our_address, fee).await?;
    trace!("got optional tx info");
    let msg_bytes = private_key.sign_std_msg(&messages, args, MEMO)?;
    let mut txrpc = TxServiceClient::connect(contact.get_url()).await?;
    let response = txrpc
        .broadcast_tx(BroadcastTxRequest {
            tx_bytes: msg_bytes,
            mode: BroadcastMode::Sync.into(),
        })
        .await?;
    let response = response.into_inner();
    contact
        .wait_for_tx(response.tx_response.unwrap(), TIMEOUT)
        .await
}
pub async fn send_batch_confirm ( contact : & Contact , eth_private_key : EthPrivateKey , fee : Coin , transaction_batches : Vec < TransactionBatch > , private_key : PrivateKey , gravity_id : String , ) -> Result < TxResponse , CosmosGrpcError > { let our_address = private_key . to_public_key ( ) . expect ( " " ) . to_address ( ) ; let our_eth_address = eth_private_key . to_public_key ( ) . unwrap ( ) ; let fee = Fee { amount : vec ! [ fee ] , gas_limit : 500_000_000u64 , granter : None , payer : None , } ; let mut messages = Vec :: new ( ) ; for batch in transaction_batches { trace ! ( " " batch ) ; let message = encode_tx_batch_confirm ( gravity_id . clone ( ) , batch . clone ( ) ) ; let eth_signature = eth_private_key . sign_ethereum_msg ( & message ) ; trace ! ( " " our_eth_address bytes_to_hex_str ( eth_signature to_bytes ( ) ) ) ; let confirm = MsgConfirmBatch { token_contract : batch . token_contract . to_string ( ) , orchestrator : our_address . to_string ( ) , eth_signer : our_eth_address . to_string ( ) , nonce : batch . nonce , signature : bytes_to_hex_str ( & eth_signature . to_bytes ( ) ) , } ; let msg = Msg :: new ( " " , confirm ) ; messages . push ( msg ) ; } let args = contact . get_message_args ( our_address , fee ) . await ? ; trace ! ( " " ) ; let msg_bytes = private_key . sign_std_msg ( & messages , args , MEMO ) ? ; let mut txrpc = TxServiceClient :: connect ( contact . get_url ( ) ) . await ? ; let response = txrpc . broadcast_tx ( BroadcastTxRequest { tx_bytes : msg_bytes , mode : BroadcastMode :: Sync . into ( ) , } ) . await ? ; let response = response . into_inner ( ) ; contact . wait_for_tx ( response . tx_response . unwrap ( ) , TIMEOUT ) . await }
Send in a confirmation for a specific transaction batch
Send in a confirmation for a specific transaction batch
contact
&Contact
eth_private_key
EthPrivateKey
fee
Coin
transaction_batches
Vec<TransactionBatch>
private_key
PrivateKey
gravity_id
String