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

Adding send raw tx #156

Closed EdsonAlcala closed 1 month ago

EdsonAlcala commented 1 month ago

Hello, I'm currently working in a chain signatures library to create transaction payloads for multiple Blockchains (including Near itself).

As part of the omni library, I included a way to build a signed payload for Near transactions that can be propagated.

Screenshot 2024-09-09 at 08 29 14

Source: https://github.com/EdsonAlcala/omni-transaction-rs/blob/master/src/near/near_transaction.rs#L37

In the image above, if you notice, the return type of build_with_signature is a Vec< u8 >. Then if I want to send it to a Near network using near-jsonrpc-client-rs, it won't be possible (or perhaps I'm missing something). But I saw that send_tx only accepts a SignedTransaction. However my transaction payload is already signed.

So I thought about adding a send_raw_tx, that only encodes to base 64 and send the payload to the network.

Screenshot 2024-09-09 at 08 38 45

Source: https://github.com/near/near-jsonrpc-client-rs/commit/613a0b2fcb7667da4ab8a5eceb84dd6cc2e4386a

Notice the encode_signed_transaction function:

Screenshot 2024-09-09 at 08 44 02

You can see how I used it here https://github.com/EdsonAlcala/omni-transaction-rs/blob/master/tests/near_integration_test.rs#L91.

So my goal with this issue is:

Thanks

frol commented 1 month ago

@EdsonAlcala I would suggest to just use any API in this case:

https://github.com/near/near-jsonrpc-client-rs/blob/d7ceafd0fcc36d8170ba4c730f071fb7dcbee7b5/src/methods/any/mod.rs#L39-L49

I don’t see value in adding a dedicated method for raw-transactions specifically. I believe any should cover it well, so I will close this issue, but if you disagree, please, reopen it