Repository navigation
fix(tron): fail when the broadcast is rejected - #1145
pedromcunha-uneven merged 3 commits into
Conversation
|
@erkancamli is attempting to deploy a commit to the Uneven Labs Team on Vercel. A member of the Team first needs to authorize it. |
[Medium impact] The PR appears safe to merge.
|
TronWeb's sendRawTransaction resolves with the node's error instead of throwing, so the adapter returned the txid of a transaction that was never accepted and the SDK waited for the confirmation timeout.
DUP_TRANSACTION_ERROR means the node already has the transaction, so it is not a rejection; return the txid and confirm as before.
bd595fe to
cc388c8
Compare
| const code = String(receipt?.code ?? '') | ||
| const isDuplicate = code === 'DUP_TRANSACTION_ERROR' || code === '5' | ||
| if (!receipt?.result && !isDuplicate) { | ||
| const reason = receipt?.message |
There was a problem hiding this comment.
Small one: if message isn't hex, this decodes to an empty string and the error is just Broadcast failed: . Could we fall back to receipt.code when the decoded reason is empty?
There was a problem hiding this comment.
Done: when message is not hex the decode comes back empty, so the reason now falls back to receipt.code, and to "Unknown broadcast error" if that is missing too.
…not hex Buffer.from(message, 'hex') returns an empty string for a message that is not hex, which left the error as just "Broadcast failed: ".
TronWeb's
sendRawTransactiondoes not throw when the node rejects a transaction; it resolves with the node's response, for example{ code: 'TRANSACTION_EXPIRATION_ERROR', txid, message: <hex> }withresultunset. The adapter returnedreceipt.txidanyway, so the SDK indexed a hash that was never accepted and waited the full confirmation timeout before failing withTransaction confirmation timed out. Leaving the wallet prompt open past the transaction's expiry is enough to hit it.The adapter now throws
Broadcast failed: <decoded message or code>whenresultis not set, the same way the trigger step already decodes its errors. Changeset included; typecheck and build pass. The tron package has no test runner, so the mock based check stays local.