FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.39k stars 1.32k forks source link

docs: add `Provider` doc section for `cacheUtxo` #2598

Closed Torres-ssf closed 2 days ago

Torres-ssf commented 1 week ago
Torres-ssf commented 6 days ago

@danielbate

First pass, couple comments and questions.

  1. If I have one utxo and am submitting multiple transactions, cacheUtxo has no effect, and in fact we risk the second tx failing but we would be able to fund both txs initially?

If you have just one UTXO and you fund and submit 2 TXs simultaneously:

When you have just one UTXO, you cannot send multiple TXs without waiting for the first one to complete. It will always fail

  1. Why would you not want to cacheUtxos?

The only reason that comes to mind would be in a situation where your first TX failed, and then your UTXO that was not being spent is now unusable until the cache for it got whipped.

Also, the error message is different. Maybe you have just one UTXO and since the cache is being used by default, and you are completely unaware of it, if you try to send 2 transactions in a row the error message would be not enough balance to fit the target instead of UTXO not existent.

This flag makes it possible for users that own multiple UTXOs to submit multiple TXs in a row, without waiting for each one to be processed, and without running into the error UTXO non-existent.

This error will likely happen, as the TXs are going to be funded automatically, and TX1 and TX2 can be funded with the same UTXO(s). Then, when TX1 is processed, that specific UTXO will be spent, and TX2 will fail.

github-actions[bot] commented 2 days ago

Coverage Report:

Lines Branches Functions Statements
79.54%(+0%) 71.37%(+0%) 76.91%(+0%) 79.62%(+0%)
Changed Files: Coverage values did not change👌.