fix(transactions): add ConflictingNonceInMempool to TxRejectedReason … - #1829
fix(transactions): add ConflictingNonceInMempool to TxRejectedReason …#1829Wutche wants to merge 2 commits into
Conversation
|
|
||
| export type ConflictingNonceInMempoolRejection = { | ||
| reason: 'ConflictingNonceInMempool'; | ||
| reason_data: { |
There was a problem hiding this comment.
There is no such field like expected and actual. See https://github.com/stacks-network/stacks-core/blob/e6c240e0c0dc763b1cff8fd5fca7b4c237da8bdb/stackslib/src/core/mempool.rs#L2217C24-L2217C40
…enum Adds the missing ConflictingNonceInMempool error type that can be returned when broadcasting a transaction with a conflicting nonce in the mempool. Closes stx-labs#1801
75438a7 to
ce03642
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds support for the ConflictingNonceInMempool error type to the transaction broadcast error handling in Stacks.js, addressing issue #1801. The changes enable developers to properly handle transactions that have a conflicting nonce with another transaction already in the mempool.
Changes:
- Added
ConflictingNonceInMempoolenum value toTxRejectedReasonin constants.ts - Added
ConflictingNonceInMempoolRejectiontype definition in types.ts - Added the new rejection type to the
TxBroadcastResultRejectedunion type
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/transactions/src/constants.ts | Added ConflictingNonceInMempool enum value to TxRejectedReason |
| packages/transactions/src/types.ts | Added ConflictingNonceInMempoolRejection type and added it to TxBroadcastResultRejected union |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } & BaseRejection; | ||
|
|
||
| export type ConflictingNonceInMempoolRejection = { | ||
| reason: 'ConflictingNonceInMempool'; |
There was a problem hiding this comment.
The ConflictingNonceInMempoolRejection type is missing the reason_data property that should contain the conflicting nonce information. The PR description's example code shows accessing result.reason_data.expected and result.reason_data.actual, but the type definition doesn't include these fields. This should match the pattern of similar rejection types like BadNonceRejection which includes reason_data with expected and actual fields. Without this, TypeScript will report errors when accessing these properties and the type will not accurately reflect the API response structure.
| reason: 'ConflictingNonceInMempool'; | |
| reason: 'ConflictingNonceInMempool'; | |
| reason_data: { | |
| expected: number; | |
| actual: number; | |
| }; |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export type ConflictingNonceInMempoolRejection = { | ||
| reason: 'ConflictingNonceInMempool'; | ||
| } & BaseRejection; |
There was a problem hiding this comment.
The PR description/example indicates this rejection includes structured reason_data (e.g., expected/actual nonce), but the new ConflictingNonceInMempoolRejection type doesn’t add any reason_data shape beyond what BaseRejection provides. If the node returns nonce details, please model them here (e.g., add a typed reason_data field) so TS users can safely access result.reason_data.expected/actual; otherwise, update the PR description/example to match the actual payload.
Description
Adds the missing ConflictingNonceInMempool error type to the
TxRejectedReasonenum and the corresponding ConflictingNonceInMempoolRejection type to TxBroadcastResultRejected.This error can be returned by Stacks nodes when broadcasting a transaction that has a conflicting nonce with another transaction already in the mempool.
Changes:
TxRejectedReasonenum in constants.tsCloses #1801
Breaking change?
None - this is purely additive.
@janniks @zone117x
Example
Checklist