Skip to content

fix: allow opt-out warning for same-asset ManageOffer instead of hard error - #892

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
Speedable2:fix/offer-manager-same-asset-validation
Oct 27, 2026
Merged

Just-Bamford merged 1 commit into
Sorokit:mainfrom
Speedable2:fix/offer-manager-same-asset-validation

Conversation

@Speedable2

Copy link
Copy Markdown
Contributor

Summary

buildManageOfferTransaction already rejected offers where the selling and buying asset are identical, but only as a hard TX_BUILD_FAILED error with no way to opt out. This adds a configurable opt-out, matching the existing suppressPriceWarnings convention on the same params object.

closes #841

Changes

  • ManageOfferParams.allowSameAsset?: boolean (src/transaction/types.ts): when true, downgrades the same-asset check from a hard error to a console.warn and proceeds with building the transaction; defaults to false/unset (current error behavior unchanged).
  • buildManageOfferTransaction (src/transaction/buildTransaction.ts): same-asset check now branches on allowSameAsset.
  • Tests added in src/tests/manageOffer.test.ts: warn-and-succeed when allowSameAsset: true, and still-error when explicitly false.

Test plan

  • npm run typecheck: clean.
  • npm run lint: clean.
  • npm run test: 3943 passed / 2 failed / 80 skipped. The 2 failures are in simulateTransactionCache.test.ts and pre-exist on a clean main checkout (verified via git stash + rerun), unrelated to this change.
  • npm run build: succeeds.

… error

Buying asset == selling asset is now still rejected with TX_BUILD_FAILED
by default, but callers can pass allowSameAsset: true to downgrade this
to a console warning (matching the existing suppressPriceWarnings
convention) and build the transaction anyway.
@Just-Bamford
Just-Bamford merged commit 730d595 into Sorokit:main Oct 27, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OfferManager does not validate that buying and selling assets are different — allows nonsensical offers

2 participants