near / near-jsonrpc-client-rs

Lower-level API for interfacing with the NEAR Protocol via JSONRPC.
https://docs.rs/near-jsonrpc-client
Apache License 2.0
47 stars 41 forks source link

broadcast_tx_async should have default wait_until value of NONE, it is currently the default (ExecutedOptimistic) #143

Closed jaswinder6991 closed 6 months ago

jaswinder6991 commented 6 months ago

According to the RPC specs published here:

Using send_tx with wait_until = NONE is equal to legacy broadcast_tx_async method. Using send_tx with finality wait_until = EXECUTED_OPTIMISTIC is equal to legacy broadcast_tx_commit method.

In the current src/methods/broadcast_tx_async.rs the From trait isn't implemented correctly as the wait_until is set to the default transaction status = ExecutedOptimistic

impl From<RpcBroadcastTxAsyncRequest>
    for near_jsonrpc_primitives::types::transactions::RpcSendTransactionRequest
{
    fn from(this: RpcBroadcastTxAsyncRequest) -> Self {
        Self {
            signed_transaction: this.signed_transaction,
            wait_until: near_primitives::views::TxExecutionStatus::default(),
        }
    }
}

It should be implemented as

impl From<RpcBroadcastTxAsyncRequest>
    for near_jsonrpc_primitives::types::transactions::RpcSendTransactionRequest
{
    fn from(this: RpcBroadcastTxAsyncRequest) -> Self {
        Self {
            signed_transaction: this.signed_transaction,
            wait_until: near_primitives::views::TxExecutionStatus::None,
        }
    }
}

Addressed in this PR.