Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return DispatchError in dry-run endpoint #1533

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Nov 4, 2024

Description

Closes #1532

Testing

Connected to Westend Asset Hub, when requesting:

curl -X 'POST' \
  'http://127.0.0.1:8080/transaction/dry-run' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "senderAddress": "5F9aniqTwLsRn5ybqSeB2srKfaRXCLeNDSPPHQxPeuGw5Y8a",
  "tx": "0x0a0000fe06fc3db07fb1a4ce89a76eaed1e54519b5940d2652b8d6794ad4ddfcdcb16c0f00d0eca2b99401"
  }'

Before the change we would get the response :

{"at":{"hash":"","height":"0"},"result":{"resultType":"DispatchError","result":{"postInfo":{"actualWeight":null,"paysFee":"Yes"},"error":{"token":"FundsUnavailable"}}}}
{"code":400,"error":"Unable to dry-run transaction","transaction":"0x0a0000fe06fc3db07fb1a4ce89a76eaed1e54519b5940d2652b8d6794ad4ddfcdcb16c0f00d0eca2b99401","cause":"Cannot extract Ok value from Err result, check isOk first","stack":"Error: Cannot extract Ok value from Err result, check isOk first\n    at get asOk [as asOk] (/Users/dominique/Documents/Parity/side-aaFresko/node_modules/@polkadot/types-codec/cjs/base/Result.js:37:19)\n    at TransactionDryRunService.dryRuntExtrinsic (/Users/dominique/Documents/Parity/side-aaFresko/build/src/services/transaction/TransactionDryRunService.js:45:75)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async TransactionDryRunController.dryRunTransaction (/Users/dominique/Documents/Parity/side-aaFresko/build/src/controllers/transaction/TransactionDryRunController.js:62:60)\n    at async /Users/dominique/Documents/Parity/side-aaFresko/build/src/controllers/AbstractController.js:222:9","at":{}}zsh: command not found: at:hash:,result:resultType:DispatchError

After the change we get :

{"at":{"hash":"","height":"0"},"result":{"resultType":"DispatchError","result":{"postInfo":{"actualWeight":null,"paysFee":"Yes"},"error":{"token":"FundsUnavailable"}}}}

@Imod7 Imod7 requested a review from a team as a code owner November 4, 2024 12:52
@filvecchiato filvecchiato self-requested a review November 5, 2024 15:49
Copy link
Contributor

@filvecchiato filvecchiato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! LGTM

@Imod7 Imod7 merged commit c43a26b into master Nov 5, 2024
15 checks passed
@Imod7 Imod7 deleted the domi-dryrun-fix branch November 5, 2024 16:14
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.

DispatchError is not returned in dry-run endpoint
4 participants