Skip to content

Expand CONTRACT_ERROR_MESSAGES with real pool contract error codes - #181

Merged
prodbycorne merged 7 commits into
SmartDropLabs:mainfrom
richardtoms100:fix/contract-error-messages-146
Aug 18, 2026
Merged

Expand CONTRACT_ERROR_MESSAGES with real pool contract error codes#181
prodbycorne merged 7 commits into
SmartDropLabs:mainfrom
richardtoms100:fix/contract-error-messages-146

Conversation

@richardtoms100

Copy link
Copy Markdown
Contributor

Summary

CONTRACT_ERROR_MESSAGES had exactly one entry despite substantial, purpose-built XDR error-extraction machinery (findContractErrorCode/extractContractErrorCodeFromXdr/extractContractErrorCode/normalizeContractErrorCode) — every other on-chain lock/unlock/boost failure fell through to a generic, actionless Transaction {hash} failed on-chain message.

  • Expanded the table with codes 2-9, sourced directly from the deployed farming-pool contract's real PoolError enum (SmartDropLabs/smartdrop-contracts, soroban/contracts/farming-pool/src/types.rs) rather than guessed — I have direct, current knowledge of that enum from working on that exact contract earlier. Code '1' is left unchanged: the real contract's code 1 is AlreadyInitialized, which doesn't match the existing "Assets are still locked" message, and that specific failure is actually a plain assert! in the current contract rather than a typed error — documented in a comment rather than silently reinterpreted, since there's no way to confirm from here whether it reflects an older contract build's mapping.
  • getContractErrorMessage now logs unmapped codes via console.warn('[SmartDrop] Unmapped contract error code:', ...) so gaps are discoverable from real usage instead of requiring a user complaint first.
  • The generic on-chain-failure fallback (lockAssets, unlockAssets) now includes the raw error code when one was extracted, via a small genericOnChainFailureMessage helper.
  • setBoost previously returned success immediately after submission, without ever polling for on-chain confirmation or extracting a contract error code — unlike lockAssets/unlockAssets. Extended it to poll and map errors the same way, per the issue's explicit callout that this gap would otherwise persist once boost UI ships.

Test plan

  • New soroban.contractErrors.test.ts enumerates every entry in the updated table via getContractErrorMessage, plus unmapped-code warning behavior and hex/embedded-code normalization
  • Updated setBoost's existing success test for the new confirmation fields; added a new test proving its on-chain failure path now decodes contract errors the same way lockAssets does
  • npx vitest run — 247/248 passing (the one failure, soroban-parsers.test.ts's decodeScString test, is pre-existing and unrelated — confirmed present on a clean, unmodified upstream/main checkout)
  • npx tsc --noEmit — clean
  • npx next lint — clean (only pre-existing warnings in files this PR doesn't touch)
  • npx next build — succeeds

Closes #146

@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for spiffy-melomakarona-eb1e8a ready!

Name Link
🔨 Latest commit d57daf2
🔍 Latest deploy log https://app.netlify.com/projects/spiffy-melomakarona-eb1e8a/deploys/6a84c66a002c300008693c53
😎 Deploy Preview https://deploy-preview-181--spiffy-melomakarona-eb1e8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for smart-drop ready!

Name Link
🔨 Latest commit d57daf2
🔍 Latest deploy log https://app.netlify.com/projects/smart-drop/deploys/6a84c66ae777a80008538c26
😎 Deploy Preview https://deploy-preview-181--smart-drop.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@prodbycorne

Copy link
Copy Markdown
Contributor

ci passed

@prodbycorne
prodbycorne merged commit 4fa917c into SmartDropLabs:main Aug 18, 2026
9 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

2 participants