Skip to content

Commit f2f8e0d

Browse files
Update transaction/dry-run docs; Bump deps (#240)
* save * Update docs for transaction/dry-run * Update src/controllers/transaction/TransactionDryRunController.ts Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
1 parent 104dde8 commit f2f8e0d

File tree

5 files changed

+91
-79
lines changed

5 files changed

+91
-79
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ a 32-byte hex string (`0x` followed by 64 hexadecimal digits) that denotes the b
155155
}
156156
```
157157
158+
- [`transaction/dry-run` dry run a transaction to check if it is valid.](src/controllers/transaction/TransactionDryRunController.ts)
159+
Expects a string with hex-encoded transaction in a JSON POST
160+
body:
161+
```
162+
curl localhost:8080/transaction/dry-run -X POST --data '{"tx": "0x..."}' -H 'Content-Type: application/json'
163+
```
164+
See [here for details](src/controllers/transaction/TransactionDryRunController.ts) on expected result.
165+
158166
## Chain compatibility
159167
160168
Sidecar should be compatible with any [Substrate](https://substrate.dev/) based chain, given

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polkadot-rpc-proxy",
3-
"version": "0.14.0",
3+
"version": "0.15.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -34,15 +34,15 @@
3434
"@types/http-errors": "^1.6.3",
3535
"@types/jest": "^26.0.10",
3636
"@types/morgan": "^1.9.1",
37-
"@typescript-eslint/eslint-plugin": "^3.10.0",
38-
"@typescript-eslint/parser": "^3.10.0",
37+
"@typescript-eslint/eslint-plugin": "^3.10.1",
38+
"@typescript-eslint/parser": "^3.10.1",
3939
"eslint": "^7.7.0",
4040
"eslint-config-prettier": "^6.11.0",
4141
"eslint-plugin-prettier": "^3.1.4",
4242
"eslint-plugin-simple-import-sort": "^5.0.3",
4343
"jest": "^26.4.2",
44-
"prettier": "^2.1.0",
45-
"ts-jest": "^26.2.0",
44+
"prettier": "^2.1.1",
45+
"ts-jest": "^26.3.0",
4646
"tsc-watch": "^4.2.9",
4747
"typescript": "^4.0.2"
4848
}

src/controllers/transaction/TransactionDryRunController.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ import { TransactionDryRunService } from '../../services';
55
import { IPostRequestHandler, ITx } from '../../types/requests';
66
import AbstractController from '../AbstractController';
77

8+
/**
9+
* Dry run an transaction.
10+
*
11+
* Returns:
12+
* - `at`:
13+
* - `hash`: The block's hash.
14+
* - `height`: The block's height.
15+
* - `dryRunResult`:
16+
* - `resultType`: Either `DispatchOutcome` if the construction is valid
17+
* or `TransactionValidityError` if the transaction has invalid construction.
18+
* - `result`: If there was an error it will be the cause of the error. If the
19+
* transaction executed correctly it will be `Ok: []`.
20+
* - `validityErrorType`: Only present if the `resultType` is
21+
* `TransactionValidityError`. Either `InvalidTransaction` or `UnknownTransaction`.
22+
*
23+
* References:
24+
* - `UnknownTransaction`: https://crates.parity.io/sp_runtime/transaction_validity/enum.UnknownTransaction.html
25+
* - `InvalidTransaction`: https://crates.parity.io/sp_runtime/transaction_validity/enum.InvalidTransaction.html
26+
*
27+
* Note: If you get the error `-32601: Method not found` it means that the node sidecar
28+
* is connected to does not expose the `system_dryRun` RPC. One way to resolve this
29+
* issue is to pass the `--rpc-external` flag to that node.
30+
*/
831
export default class TransactionDryRunController extends AbstractController<
932
TransactionDryRunService
1033
> {

src/services/transaction/TransactionDryRunService.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,6 @@ import {
88
import { AbstractService } from '../AbstractService';
99
import { extractCauseAndStack } from './extractCauseAndStack';
1010

11-
/**
12-
* Dry run an extrinsic.
13-
*
14-
* Returns:
15-
* - `at`:
16-
* - `hash`: The block's hash.
17-
* - `height`: The block's height.
18-
* - `dryRunResult`:
19-
* - `resultType`: Either `DispatchOutcome` if the construction is valid
20-
* or `TransactionValidityError` if the transaction has invalid construction.
21-
* - `result`: If there was an error it will be the cause of the error. If the
22-
* transaction executed correctly it will be `Ok: []`.
23-
* - `validityErrorType`: Only present if the `resultType` is
24-
* `TransactionValidityError`. Either `InvalidTransaction` or `UnknownTransaction`.
25-
*
26-
* References:
27-
* - `UnknownTransaction`: https://crates.parity.io/sp_runtime/transaction_validity/enum.UnknownTransaction.html
28-
* - `InvalidTransaction`: https://crates.parity.io/sp_runtime/transaction_validity/enum.InvalidTransaction.html
29-
*/
3011
export class TransactionDryRunService extends AbstractService {
3112
async dryRuntExtrinsic(
3213
hash: BlockHash,

yarn.lock

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@
622622
ip-regex "^4.1.0"
623623

624624
"@polkadot/wasm-crypto@^1.3.1":
625-
version "1.3.1"
626-
resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-1.3.1.tgz#975cbe97ffbd2f7f12e5b196c3bbf3f1435fe35c"
627-
integrity sha512-AI90G2y9EXpjdWFfmxNRmhhei1OaWcNyuYferg/MEtqDQpkif+RlDw3sXfOHzdlIiWtL+IvXXltJPPbkhS0ycg==
625+
version "1.4.1"
626+
resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-1.4.1.tgz#0a053d0c2587da30fb5313cef81f8d9a52029c68"
627+
integrity sha512-GPBCh8YvQmA5bobI4rqRkUhrEHkEWU1+lcJVPbZYsa7jiHFaZpzCLrGQfiqW/vtbU1aBS2wmJ0x1nlt33B9QqQ==
628628

629629
"@sinonjs/commons@^1.7.0":
630630
version "1.8.1"
@@ -792,9 +792,9 @@
792792
"@types/node" "*"
793793

794794
"@types/node@*":
795-
version "14.6.0"
796-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
797-
integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==
795+
version "14.6.1"
796+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.1.tgz#fdf6f6c6c73d3d8eee9c98a9a0485bc524b048d7"
797+
integrity sha512-HnYlg/BRF8uC1FyKRFZwRaCPTPYKa+6I8QiUZFLredaGOou481cgFS4wKRFyKvQtX8xudqkSdBczJHIYSQYKrQ==
798798

799799
"@types/node@11.11.6":
800800
version "11.11.6"
@@ -807,9 +807,9 @@
807807
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
808808

809809
"@types/prettier@^2.0.0":
810-
version "2.0.2"
811-
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.2.tgz#5bb52ee68d0f8efa9cc0099920e56be6cc4e37f3"
812-
integrity sha512-IkVfat549ggtkZUthUzEX49562eGikhSYeVGX97SkMFn+sTZrgRewXjQ4tPKFPCykZHkX1Zfd9OoELGqKU2jJA==
810+
version "2.1.0"
811+
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.0.tgz#5f96562c1075ee715a5b138f0b7f591c1f40f6b8"
812+
integrity sha512-hiYA88aHiEIgDmeKlsyVsuQdcFn3Z2VuFd/Xm/HCnGnPD8UFU5BM128uzzRVVGEzKDKYUrRsRH9S2o+NUy/3IA==
813813

814814
"@types/qs@*":
815815
version "6.9.4"
@@ -853,63 +853,63 @@
853853
dependencies:
854854
"@types/yargs-parser" "*"
855855

856-
"@typescript-eslint/eslint-plugin@^3.10.0":
857-
version "3.10.0"
858-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.0.tgz#40fd53e81639c0d1a515b44e5fdf4c03dfd3cd39"
859-
integrity sha512-Bbeg9JAnSzZ85Y0gpInZscSpifA6SbEgRryaKdP5ZlUjhTKsvZS4GUIE6xAZCjhNTrf4zXXsySo83ZdHL7it0w==
856+
"@typescript-eslint/eslint-plugin@^3.10.1":
857+
version "3.10.1"
858+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz#7e061338a1383f59edc204c605899f93dc2e2c8f"
859+
integrity sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==
860860
dependencies:
861-
"@typescript-eslint/experimental-utils" "3.10.0"
861+
"@typescript-eslint/experimental-utils" "3.10.1"
862862
debug "^4.1.1"
863863
functional-red-black-tree "^1.0.1"
864864
regexpp "^3.0.0"
865865
semver "^7.3.2"
866866
tsutils "^3.17.1"
867867

868-
"@typescript-eslint/experimental-utils@3.10.0":
869-
version "3.10.0"
870-
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.0.tgz#f97a669a84a78319ab324cd51169d0c52853a360"
871-
integrity sha512-e5ZLSTuXgqC/Gq3QzK2orjlhTZVXzwxDujQmTBOM1NIVBZgW3wiIZjaXuVutk9R4UltFlwC9UD2+bdxsA7yyNg==
868+
"@typescript-eslint/experimental-utils@3.10.1":
869+
version "3.10.1"
870+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz#e179ffc81a80ebcae2ea04e0332f8b251345a686"
871+
integrity sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==
872872
dependencies:
873873
"@types/json-schema" "^7.0.3"
874-
"@typescript-eslint/types" "3.10.0"
875-
"@typescript-eslint/typescript-estree" "3.10.0"
874+
"@typescript-eslint/types" "3.10.1"
875+
"@typescript-eslint/typescript-estree" "3.10.1"
876876
eslint-scope "^5.0.0"
877877
eslint-utils "^2.0.0"
878878

879-
"@typescript-eslint/parser@^3.10.0":
880-
version "3.10.0"
881-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.0.tgz#820322d990a82265a78f4c1fc9aae03ce95b76ac"
882-
integrity sha512-iJyf3f2HVwscvJR7ySGMXw2DJgIAPKEz8TeU17XVKzgJRV4/VgCeDFcqLzueRe7iFI2gv+Tln4AV88ZOnsCNXg==
879+
"@typescript-eslint/parser@^3.10.1":
880+
version "3.10.1"
881+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.10.1.tgz#1883858e83e8b442627e1ac6f408925211155467"
882+
integrity sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==
883883
dependencies:
884884
"@types/eslint-visitor-keys" "^1.0.0"
885-
"@typescript-eslint/experimental-utils" "3.10.0"
886-
"@typescript-eslint/types" "3.10.0"
887-
"@typescript-eslint/typescript-estree" "3.10.0"
885+
"@typescript-eslint/experimental-utils" "3.10.1"
886+
"@typescript-eslint/types" "3.10.1"
887+
"@typescript-eslint/typescript-estree" "3.10.1"
888888
eslint-visitor-keys "^1.1.0"
889889

890-
"@typescript-eslint/types@3.10.0":
891-
version "3.10.0"
892-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.0.tgz#b81906674eca94a884345ba0bc1aaf6cd4da912a"
893-
integrity sha512-ktUWSa75heQNwH85GRM7qP/UUrXqx9d6yIdw0iLO9/uE1LILW+i+3+B64dUodUS2WFWLzKTlwfi9giqrODibWg==
890+
"@typescript-eslint/types@3.10.1":
891+
version "3.10.1"
892+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727"
893+
integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==
894894

895-
"@typescript-eslint/typescript-estree@3.10.0":
896-
version "3.10.0"
897-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.0.tgz#65df13579a5e53c12afb4f1c5309589e3855a5de"
898-
integrity sha512-yjuY6rmVHRhcUKgXaSPNVloRueGWpFNhxR5EQLzxXfiFSl1U/+FBqHhbaGwtPPEgCSt61QNhZgiFjWT27bgAyw==
895+
"@typescript-eslint/typescript-estree@3.10.1":
896+
version "3.10.1"
897+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz#fd0061cc38add4fad45136d654408569f365b853"
898+
integrity sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==
899899
dependencies:
900-
"@typescript-eslint/types" "3.10.0"
901-
"@typescript-eslint/visitor-keys" "3.10.0"
900+
"@typescript-eslint/types" "3.10.1"
901+
"@typescript-eslint/visitor-keys" "3.10.1"
902902
debug "^4.1.1"
903903
glob "^7.1.6"
904904
is-glob "^4.0.1"
905905
lodash "^4.17.15"
906906
semver "^7.3.2"
907907
tsutils "^3.17.1"
908908

909-
"@typescript-eslint/visitor-keys@3.10.0":
910-
version "3.10.0"
911-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.0.tgz#6c0cac867e705a42e2c71b359bf6a10a88a28985"
912-
integrity sha512-g4qftk8lWb/rHZe9uEp8oZSvsJhUvR2cfp7F7qE6DyUD2SsovEs8JDQTRP1xHzsD+pERsEpYNqkDgQXW6+ob5A==
909+
"@typescript-eslint/visitor-keys@3.10.1":
910+
version "3.10.1"
911+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931"
912+
integrity sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==
913913
dependencies:
914914
eslint-visitor-keys "^1.1.0"
915915

@@ -2002,9 +2002,9 @@ event-stream@=3.3.4:
20022002
through "~2.3.1"
20032003

20042004
eventemitter3@^4.0.5:
2005-
version "4.0.5"
2006-
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.5.tgz#51d81e4f1ccc8311a04f0c20121ea824377ea6d9"
2007-
integrity sha512-QR0rh0YiPuxuDQ6+T9GAO/xWTExXpxIes1Nl9RykNGTnE1HJmkuEfxJH9cubjIOQZ/GH4qNBR4u8VSHaKiWs4g==
2005+
version "4.0.7"
2006+
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"
2007+
integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==
20082008

20092009
exec-sh@^0.3.2:
20102010
version "0.3.4"
@@ -3964,10 +3964,10 @@ prettier-linter-helpers@^1.0.0:
39643964
dependencies:
39653965
fast-diff "^1.1.2"
39663966

3967-
prettier@^2.1.0:
3968-
version "2.1.0"
3969-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.0.tgz#5a9789f767a243118c60f3e56d95cb6544914fbb"
3970-
integrity sha512-lz28cCbA1cDFHVuY8vvj6QuqOwIpyIfPUYkSl8AZ/vxH8qBXMMjE2knfLHCrZCmUsK/H1bg1P0tOo0dJkTJHvw==
3967+
prettier@^2.1.1:
3968+
version "2.1.1"
3969+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6"
3970+
integrity sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==
39713971

39723972
pretty-format@^25.2.1, pretty-format@^25.5.0:
39733973
version "25.5.0"
@@ -4813,10 +4813,10 @@ tr46@^2.0.2:
48134813
dependencies:
48144814
punycode "^2.1.1"
48154815

4816-
ts-jest@^26.2.0:
4817-
version "26.2.0"
4818-
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.2.0.tgz#7ec22faceb05ee1467fdb5265d1b33c27441f163"
4819-
integrity sha512-9+y2qwzXdAImgLSYLXAb/Rhq9+K4rbt0417b8ai987V60g2uoNWBBmMkYgutI7D8Zhu+IbCSHbBtrHxB9d7xyA==
4816+
ts-jest@^26.3.0:
4817+
version "26.3.0"
4818+
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.3.0.tgz#6b2845045347dce394f069bb59358253bc1338a9"
4819+
integrity sha512-Jq2uKfx6bPd9+JDpZNMBJMdMQUC3sJ08acISj8NXlVgR2d5OqslEHOR2KHMgwymu8h50+lKIm0m0xj/ioYdW2Q==
48204820
dependencies:
48214821
"@types/jest" "26.x"
48224822
bs-logger "0.x"
@@ -5095,9 +5095,9 @@ whatwg-mimetype@^2.3.0:
50955095
integrity sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==
50965096

50975097
whatwg-url@^8.0.0:
5098-
version "8.2.0"
5099-
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.2.0.tgz#89383f80ea3888734d1cf29526c135d52e60166d"
5100-
integrity sha512-Sl4svq71j4kzaFD13uxkVl2AIsbj/xwp8NTM1VMhFRyNT1ZMTWaV6+Pva0fQs7y8+cAEPrDGfCAFLvJejhT79g==
5098+
version "8.2.1"
5099+
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.2.1.tgz#ed73417230784b281fb2a32c3c501738b46167c3"
5100+
integrity sha512-ZmVCr6nfBeaMxEHALLEGy0LszYjpJqf6PVNQUQ1qd9Et+q7Jpygd4rGGDXgHjD8e99yLFseD69msHDM4YwPZ4A==
51015101
dependencies:
51025102
lodash.sortby "^4.7.0"
51035103
tr46 "^2.0.2"

0 commit comments

Comments
 (0)