@substrate/api-sidecar 14.1.2 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/package.json +7 -5
  2. package/build/src/chains-config/defaultControllers.js +1 -0
  3. package/build/src/chains-config/defaultControllers.js.map +1 -1
  4. package/build/src/controllers/AbstractController.d.ts +9 -0
  5. package/build/src/controllers/AbstractController.js +14 -0
  6. package/build/src/controllers/AbstractController.js.map +1 -1
  7. package/build/src/controllers/contracts/ContractsInkController.d.ts +14 -0
  8. package/build/src/controllers/contracts/ContractsInkController.js +58 -0
  9. package/build/src/controllers/contracts/ContractsInkController.js.map +1 -0
  10. package/build/src/controllers/contracts/index.d.ts +1 -0
  11. package/build/src/controllers/contracts/index.js +9 -0
  12. package/build/src/controllers/contracts/index.js.map +1 -0
  13. package/build/src/controllers/index.d.ts +2 -0
  14. package/build/src/controllers/index.js +2 -0
  15. package/build/src/controllers/index.js.map +1 -1
  16. package/build/src/services/contracts/ContractsInkService.d.ts +16 -0
  17. package/build/src/services/contracts/ContractsInkService.js +51 -0
  18. package/build/src/services/contracts/ContractsInkService.js.map +1 -0
  19. package/build/src/services/contracts/ContractsInkService.spec.d.ts +1 -0
  20. package/build/src/services/contracts/ContractsInkService.spec.js +67 -0
  21. package/build/src/services/contracts/ContractsInkService.spec.js.map +1 -0
  22. package/build/src/services/contracts/index.d.ts +1 -0
  23. package/build/src/services/contracts/index.js +33 -0
  24. package/build/src/services/contracts/index.js.map +1 -0
  25. package/build/src/services/index.d.ts +1 -0
  26. package/build/src/services/index.js +1 -0
  27. package/build/src/services/index.js.map +1 -1
  28. package/build/src/types/requests.d.ts +11 -1
  29. package/package.json +7 -5
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "14.1.2",
2
+ "version": "14.2.0",
3
3
  "name": "@substrate/api-sidecar",
4
4
  "description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
5
5
  "homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
@@ -36,6 +36,7 @@
36
36
  "dev": "tsc-watch --onSuccess \"yarn run main\"",
37
37
  "test": "NODE_ENV=test substrate-exec-jest --detectOpenHandles",
38
38
  "test:watch": "NODE_ENV=test substrate-exec-jest --watch",
39
+ "test:ci": "NODE_ENV=test substrate-exec-jest --runInBand",
39
40
  "lint:e2e-tests": "cd e2e-tests && substrate-dev-run-lint",
40
41
  "build:e2e-tests": "substrate-exec-tsc --project e2e-tests/tsconfig.json",
41
42
  "test:e2e-tests": "yarn build:e2e-tests && node ./e2e-tests/build/index.js --config=./e2e-tests/jest.config.js",
@@ -45,7 +46,7 @@
45
46
  "test:init-e2e-tests:westend": "yarn test:init-e2e-tests --chain westend",
46
47
  "test:init-e2e-tests:statemine": "yarn test:init-e2e-tests --chain statemine",
47
48
  "test:init-e2e-tests:statemint": "yarn test:init-e2e-tests --chain statemint",
48
- "start:e2e-scripts": "yarn build:scripts && node scripts/build/runChainTests.js",
49
+ "start:e2e-scripts": "yarn build:scripts && node scripts/build/runE2eTests.js",
49
50
  "build:scripts": "substrate-exec-rimraf scripts/build/ && substrate-exec-tsc --project scripts/tsconfig.json",
50
51
  "lint:scripts": "cd scripts && substrate-dev-run-lint",
51
52
  "start:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js",
@@ -53,9 +54,10 @@
53
54
  "update-pjs-deps": "substrate-update-pjs-deps && yarn"
54
55
  },
55
56
  "dependencies": {
56
- "@polkadot/api": "^9.9.1",
57
- "@polkadot/util-crypto": "^10.1.13",
58
- "@substrate/calc": "^0.3.0",
57
+ "@polkadot/api": "^9.10.1",
58
+ "@polkadot/api-contract": "^9.10.1",
59
+ "@polkadot/util-crypto": "^10.2.1",
60
+ "@substrate/calc": "^0.3.1",
59
61
  "argparse": "^2.0.1",
60
62
  "confmgr": "1.0.9",
61
63
  "express": "^4.18.1",
@@ -31,6 +31,7 @@ exports.defaultControllers = {
31
31
  'AccountsVestingInfo',
32
32
  'Blocks',
33
33
  'BlocksExtrinsics',
34
+ 'ContractsInk',
34
35
  'NodeNetwork',
35
36
  'NodeTransactionPool',
36
37
  'NodeVersion',
@@ -1 +1 @@
1
- {"version":3,"file":"defaultControllers.js","sourceRoot":"","sources":["../../../src/chains-config/defaultControllers.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;AAGxE,mCAA6D;AAE7D;;;GAGG;AACU,QAAA,kBAAkB,GAAqB;IACnD,WAAW,EAAE;QACZ,gBAAgB;QAChB,qBAAqB;QACrB,qBAAqB;QACrB,wBAAwB;QACxB,kBAAkB;QAClB,qBAAqB;QACrB,QAAQ;QACR,kBAAkB;QAClB,aAAa;QACb,qBAAqB;QACrB,aAAa;QACb,eAAe;QACf,wBAAwB;QACxB,gBAAgB;QAChB,OAAO;QACP,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,mBAAmB;QACnB,wBAAwB;QACxB,qBAAqB;QACrB,mBAAmB;KACnB;IACD,OAAO,EAAE;QACR,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,IAAA,oBAAY,GAAE;QAC1B,cAAc,EAAE,IAAI,4BAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;KACpD;CACD,CAAC"}
1
+ {"version":3,"file":"defaultControllers.js","sourceRoot":"","sources":["../../../src/chains-config/defaultControllers.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;AAGxE,mCAA6D;AAE7D;;;GAGG;AACU,QAAA,kBAAkB,GAAqB;IACnD,WAAW,EAAE;QACZ,gBAAgB;QAChB,qBAAqB;QACrB,qBAAqB;QACrB,wBAAwB;QACxB,kBAAkB;QAClB,qBAAqB;QACrB,QAAQ;QACR,kBAAkB;QAClB,cAAc;QACd,aAAa;QACb,qBAAqB;QACrB,aAAa;QACb,eAAe;QACf,wBAAwB;QACxB,gBAAgB;QAChB,OAAO;QACP,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,mBAAmB;QACnB,wBAAwB;QACxB,qBAAqB;QACrB,mBAAmB;KACnB;IACD,OAAO,EAAE;QACR,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,IAAA,oBAAY,GAAE;QAC1B,cAAc,EAAE,IAAI,4BAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;KACpD;CACD,CAAC"}
@@ -33,6 +33,15 @@ export default abstract class AbstractController<T extends AbstractService> {
33
33
  * base path (use empty string if no suffix) and the get request handler function.
34
34
  */
35
35
  protected safeMountAsyncGetHandlers(pathsAndHandlers: [string, SidecarRequestHandler][]): void;
36
+ /**
37
+ * Safely mount async POST routes by wrapping them with an express
38
+ * handler friendly try / catch block and then mounting on the controllers
39
+ * router.
40
+ *
41
+ * @param pathsAndHandlers array of tuples containing the suffix to the controller
42
+ * base path (use empty string if no suffix) and the get request handler function.
43
+ */
44
+ protected safeMountAsyncPostHandlers(pathsAndHandlers: [string, SidecarRequestHandler][]): void;
36
45
  /**
37
46
  * Wrapper for any asynchronous RequestHandler function. Pipes errors
38
47
  * to downstream error handling middleware.
@@ -75,6 +75,20 @@ class AbstractController {
75
75
  this.router.get(`${this.path}${pathSuffix}`, AbstractController.catchWrap(handler));
76
76
  }
77
77
  }
78
+ /**
79
+ * Safely mount async POST routes by wrapping them with an express
80
+ * handler friendly try / catch block and then mounting on the controllers
81
+ * router.
82
+ *
83
+ * @param pathsAndHandlers array of tuples containing the suffix to the controller
84
+ * base path (use empty string if no suffix) and the get request handler function.
85
+ */
86
+ safeMountAsyncPostHandlers(pathsAndHandlers) {
87
+ for (const pathAndHandler of pathsAndHandlers) {
88
+ const [pathSuffix, handler] = pathAndHandler;
89
+ this.router.post(`${this.path}${pathSuffix}`, AbstractController.catchWrap(handler));
90
+ }
91
+ }
78
92
  /**
79
93
  * Create or retrieve the corresponding BlockHash for the given block identifier.
80
94
  * This also acts as a validation for string based block identifiers.
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractController.js","sourceRoot":"","sources":["../../../src/controllers/AbstractController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;;;;;;;;;;;;;;;;;;;;;AAIxE,yCAAuC;AAEvC,iDAAmC;AACnC,6CAAyE;AAYzE,0CAA8C;AAC9C,4CAAqD;AAErD,0DAA2E;AAW3E;;GAEG;AACH,MAA8B,kBAAkB;IAE/C,YACW,GAAe,EACjB,KAAa,EACX,OAAU;QAFV,QAAG,GAAH,GAAG,CAAY;QACjB,UAAK,GAAL,KAAK,CAAQ;QACX,YAAO,GAAP,OAAO,CAAG;QAJb,YAAO,GAAW,OAAO,CAAC,MAAM,EAAE,CAAC;IAKxC,CAAC;IAEJ,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAUD;;;;;;;OAOG;IACO,yBAAyB,CAClC,gBAAmD;QAEnD,KAAK,MAAM,cAAc,IAAI,gBAAgB,EAAE;YAC9C,MAAM,CAAC,UAAU,EAAE,OAAO,CAA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AC,EAAW;QACxC,OAAO,OAAO,EAAE,KAAK,QAAQ;YAC5B,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAChC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CACnB,GAAsB,EACtB,IAAO,EACP,UAA4B,EAAE;QAE9B,GAAG,CAAC,IAAI,CAAC,IAAA,0BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,CAAC;;AA7OF,qCA8OC;;AAlMA;;;;;GAKG;AACc,4BAAS,GACzB,CAAC,EAAkB,EAAkB,EAAE,CACvC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAiB,EAAE;IACvC,IAAI;QACH,6DAA6D;QAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;KACzB;IAAC,OAAO,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,CAAC;KACV;AACF,CAAE,CAAA"}
1
+ {"version":3,"file":"AbstractController.js","sourceRoot":"","sources":["../../../src/controllers/AbstractController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;;;;;;;;;;;;;;;;;;;;;AAIxE,yCAAuC;AAEvC,iDAAmC;AACnC,6CAAyE;AAYzE,0CAA8C;AAC9C,4CAAqD;AAErD,0DAA2E;AAW3E;;GAEG;AACH,MAA8B,kBAAkB;IAE/C,YACW,GAAe,EACjB,KAAa,EACX,OAAU;QAFV,QAAG,GAAH,GAAG,CAAY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AE;IACvC,IAAI;QACH,6DAA6D;QAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;KACzB;IAAC,OAAO,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,CAAC,CAAC;KACV;AACF,CAAE,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { ApiPromise } from '@polkadot/api';
2
+ import { ContractsInkService } from '../../services';
3
+ import AbstractController from '../AbstractController';
4
+ export default class ContractsInkController extends AbstractController<ContractsInkService> {
5
+ constructor(api: ApiPromise);
6
+ protected initRoutes(): void;
7
+ /**
8
+ * Send a message call to a contract. It defaults to get if nothing is inputted.
9
+ *
10
+ * @param _req
11
+ * @param res
12
+ */
13
+ private callContractQuery;
14
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // Copyright 2017-2022 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const api_contract_1 = require("@polkadot/api-contract");
22
+ const http_errors_1 = require("http-errors");
23
+ const middleware_1 = require("../../middleware");
24
+ const services_1 = require("../../services");
25
+ const AbstractController_1 = __importDefault(require("../AbstractController"));
26
+ class ContractsInkController extends AbstractController_1.default {
27
+ constructor(api) {
28
+ super(api, '/contracts/ink/:address', new services_1.ContractsInkService(api));
29
+ /**
30
+ * Send a message call to a contract. It defaults to get if nothing is inputted.
31
+ *
32
+ * @param _req
33
+ * @param res
34
+ */
35
+ this.callContractQuery = async ({ params: { address }, body, query: { method = 'get', gasLimit, storageDepositLimit, args }, }, res) => {
36
+ const { api } = this;
37
+ const argsArray = Array.isArray(args) ? args : [];
38
+ const contract = new api_contract_1.ContractPromise(api, body, address);
39
+ if (!contract.query[method]) {
40
+ throw new http_errors_1.BadRequest(`Invalid Method: Contract does not have the given ${method} message.`);
41
+ }
42
+ const callMeta = contract.query[method].meta;
43
+ if (callMeta.isPayable || callMeta.isMutating) {
44
+ throw new http_errors_1.BadRequest(`Invalid Method: This endpoint does not handle mutating or payable calls.`);
45
+ }
46
+ ContractsInkController.sanitizedSend(res, await this.service.fetchContractCall(contract, address, method, argsArray, gasLimit, storageDepositLimit));
47
+ };
48
+ this.initRoutes();
49
+ }
50
+ initRoutes() {
51
+ this.router.use(this.path, middleware_1.validateAddress);
52
+ this.safeMountAsyncPostHandlers([
53
+ ['/query', this.callContractQuery],
54
+ ]);
55
+ }
56
+ }
57
+ exports.default = ContractsInkController;
58
+ //# sourceMappingURL=ContractsInkController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractsInkController.js","sourceRoot":"","sources":["../../../../src/controllers/contracts/ContractsInkController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;AAGxE,yDAAyD;AAEzD,6CAAyC;AAEzC,iDAAmD;AACnD,6CAAqD;AAMrD,+EAAuD;AAEvD,MAAqB,sBAAuB,SAAQ,4BAAuC;IAC1F,YAAY,GAAe;QAC1B,KAAK,CAAC,GAAG,EAAE,yBAAyB,E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EAAE,IAAI,CAAC,iBAAmC,CAAC;SACpD,CAAC,CAAC;IACJ,CAAC;CA+CD;AA1DD,yCA0DC"}
@@ -0,0 +1 @@
1
+ export { default as ContractsInk } from './ContractsInkController';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ContractsInk = void 0;
7
+ var ContractsInkController_1 = require("./ContractsInkController");
8
+ Object.defineProperty(exports, "ContractsInk", { enumerable: true, get: function () { return __importDefault(ContractsInkController_1).default; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/contracts/index.ts"],"names":[],"mappings":";;;;;;AAAA,mEAAmE;AAA1D,uIAAA,OAAO,OAAgB"}
@@ -1,5 +1,6 @@
1
1
  import { AccountsAssets, AccountsBalanceInfo, AccountsConvert, AccountsStakingInfo, AccountsStakingPayouts, AccountsValidate, AccountsVestingInfo } from './accounts';
2
2
  import { Blocks, BlocksExtrinsics, BlocksTrace } from './blocks';
3
+ import { ContractsInk } from './contracts';
3
4
  import { NodeNetwork, NodeTransactionPool, NodeVersion } from './node';
4
5
  import { PalletsAssets, PalletsStakingProgress, PalletsStorage } from './pallets';
5
6
  import { Paras } from './paras';
@@ -19,6 +20,7 @@ export declare const controllers: {
19
20
  AccountsValidate: typeof AccountsValidate;
20
21
  AccountsVestingInfo: typeof AccountsVestingInfo;
21
22
  AccountsStakingPayouts: typeof AccountsStakingPayouts;
23
+ ContractsInk: typeof ContractsInk;
22
24
  PalletsAssets: typeof PalletsAssets;
23
25
  PalletsStakingProgress: typeof PalletsStakingProgress;
24
26
  PalletsStorage: typeof PalletsStorage;
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.controllers = void 0;
19
19
  const accounts_1 = require("./accounts");
20
20
  const blocks_1 = require("./blocks");
21
+ const contracts_1 = require("./contracts");
21
22
  const node_1 = require("./node");
22
23
  const pallets_1 = require("./pallets");
23
24
  const paras_1 = require("./paras");
@@ -37,6 +38,7 @@ exports.controllers = {
37
38
  AccountsValidate: accounts_1.AccountsValidate,
38
39
  AccountsVestingInfo: accounts_1.AccountsVestingInfo,
39
40
  AccountsStakingPayouts: accounts_1.AccountsStakingPayouts,
41
+ ContractsInk: contracts_1.ContractsInk,
40
42
  PalletsAssets: pallets_1.PalletsAssets,
41
43
  PalletsStakingProgress: pallets_1.PalletsStakingProgress,
42
44
  PalletsStorage: pallets_1.PalletsStorage,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controllers/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;AAExE,yCAQoB;AACpB,qCAAiE;AACjE,iCAAuE;AACvE,uCAImB;AACnB,mCAAgC;AAChC,uCAAsE;AACtE,+CAKuB;AAEvB;;GAEG;AACU,QAAA,WAAW,GAAG;IAC1B,MAAM,EAAN,eAAM;IACN,gBAAgB,EAAhB,yBAAgB;IAChB,WAAW,EAAX,oBAAW;IACX,cAAc,EAAd,yBAAc;IACd,mBAAmB,EAAnB,8BAAmB;IACnB,eAAe,EAAf,0BAAe;IACf,mBAAmB,EAAnB,8BAAmB;IACnB,gBAAgB,EAAhB,2BAAgB;IAChB,mBAAmB,EAAnB,8BAAmB;IACnB,sBAAsB,EAAtB,iCAAsB;IACtB,aAAa,EAAb,uBAAa;IACb,sBAAsB,EAAtB,gCAAsB;IACtB,cAAc,EAAd,wBAAc;IACd,WAAW,EAAX,kBAAW;IACX,mBAAmB,EAAnB,0BAAmB;IACnB,WAAW,EAAX,kBAAW;IACX,WAAW,EAAX,qBAAW;IACX,eAAe,EAAf,yBAAe;IACf,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,+BAAiB;IACjB,sBAAsB,EAAtB,oCAAsB;IACtB,mBAAmB,EAAnB,iCAAmB;IACnB,iBAAiB,EAAjB,+BAAiB;IACjB,KAAK,EAAL,aAAK;CACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controllers/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;AAExE,yCAQoB;AACpB,qCAAiE;AACjE,2CAA2C;AAC3C,iCAAuE;AACvE,uCAImB;AACnB,mCAAgC;AAChC,uCAAsE;AACtE,+CAKuB;AAEvB;;GAEG;AACU,QAAA,WAAW,GAAG;IAC1B,MAAM,EAAN,eAAM;IACN,gBAAgB,EAAhB,yBAAgB;IAChB,WAAW,EAAX,oBAAW;IACX,cAAc,EAAd,yBAAc;IACd,mBAAmB,EAAnB,8BAAmB;IACnB,eAAe,EAAf,0BAAe;IACf,mBAAmB,EAAnB,8BAAmB;IACnB,gBAAgB,EAAhB,2BAAgB;IAChB,mBAAmB,EAAnB,8BAAmB;IACnB,sBAAsB,EAAtB,iCAAsB;IACtB,YAAY,EAAZ,wBAAY;IACZ,aAAa,EAAb,uBAAa;IACb,sBAAsB,EAAtB,gCAAsB;IACtB,cAAc,EAAd,wBAAc;IACd,WAAW,EAAX,kBAAW;IACX,mBAAmB,EAAnB,0BAAmB;IACnB,WAAW,EAAX,kBAAW;IACX,WAAW,EAAX,qBAAW;IACX,eAAe,EAAf,yBAAe;IACf,WAAW,EAAX,qBAAW;IACX,iBAAiB,EAAjB,+BAAiB;IACjB,sBAAsB,EAAtB,oCAAsB;IACtB,mBAAmB,EAAnB,iCAAmB;IACnB,iBAAiB,EAAjB,+BAAiB;IACjB,KAAK,EAAL,aAAK;CACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { ContractPromise } from '@polkadot/api-contract';
2
+ import { ContractCallOutcome } from '@polkadot/api-contract/types';
3
+ import { AbstractService } from '../AbstractService';
4
+ export declare class ContractsInkService extends AbstractService {
5
+ /**
6
+ * Query a given message method.
7
+ *
8
+ * @param contract ContractPromise that has decorated querys.
9
+ * @param address Address to query with the contract.
10
+ * @param method Message that will be queried.
11
+ * @param args Args to attach to the query.
12
+ * @param gasLimit Gas limit which will default to -1.
13
+ * @param storageDepositLimit Storage Deposit Limit that will default to null.
14
+ */
15
+ fetchContractCall(contract: ContractPromise, address: string, method: string, args?: unknown[], gasLimit?: string, storageDepositLimit?: string): Promise<ContractCallOutcome>;
16
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ // Copyright 2017-2022 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ContractsInkService = void 0;
19
+ const AbstractService_1 = require("../AbstractService");
20
+ class ContractsInkService extends AbstractService_1.AbstractService {
21
+ /**
22
+ * Query a given message method.
23
+ *
24
+ * @param contract ContractPromise that has decorated querys.
25
+ * @param address Address to query with the contract.
26
+ * @param method Message that will be queried.
27
+ * @param args Args to attach to the query.
28
+ * @param gasLimit Gas limit which will default to -1.
29
+ * @param storageDepositLimit Storage Deposit Limit that will default to null.
30
+ */
31
+ async fetchContractCall(contract, address, method, args, gasLimit, storageDepositLimit) {
32
+ const options = {
33
+ gasLimit: gasLimit || -1,
34
+ storageDepositLimit: storageDepositLimit || null,
35
+ };
36
+ const callResult = args && args.length > 0
37
+ ? await contract.query[method](address, options, args)
38
+ : await contract.query[method](address, options);
39
+ const { debugMessage, gasConsumed, gasRequired, output, result, storageDeposit, } = callResult;
40
+ return {
41
+ debugMessage,
42
+ gasConsumed,
43
+ gasRequired,
44
+ output,
45
+ result,
46
+ storageDeposit,
47
+ };
48
+ }
49
+ }
50
+ exports.ContractsInkService = ContractsInkService;
51
+ //# sourceMappingURL=ContractsInkService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractsInkService.js","sourceRoot":"","sources":["../../../../src/services/contracts/ContractsInkService.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;AAKxE,wDAAqD;AAErD,MAAa,mBAAoB,SAAQ,iCAAe;IACvD;;;;;;;;;OASG;IACI,KAAK,CAAC,iBAAiB,CAC7B,QAAyB,EACzB,OAAe,EACf,MAAc,EACd,IAAgB,EAChB,QAAiB,EACjB,mBAA4B;QAE5B,MAAM,OAAO,GAAG;YACf,QAAQ,EAAE,QAAQ,IAAI,CAAC,CAAC;YACxB,mBAAmB,EAAE,mBAAmB,IAAI,IAAI;SAChD,CAAC;QAEF,MAAM,UAAU,GACf,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;YACtD,CAAC,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAEnD,MAAM,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,MAAM,EACN,MAAM,EACN,cAAc,GACd,GAAG,UAAU,CAAC;QAEf,OAAO;YACN,YAAY;YACZ,WAAW;YACX,WAAW;YACX,MAAM;YACN,MAAM;YACN,cAAc;SACd,CAAC;IACH,CAAC;CACD;AA/CD,kDA+CC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ // Copyright 2017-2022 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const sanitizeNumbers_1 = require("../../sanitize/sanitizeNumbers");
19
+ const registries_1 = require("../../test-helpers/registries");
20
+ const mock_1 = require("../test-helpers/mock");
21
+ const _1 = require(".");
22
+ const contractInkService = new _1.ContractsInkService(mock_1.defaultMockApi);
23
+ const getFlipper = () => Promise.resolve().then(() => {
24
+ return {
25
+ debugMessage: registries_1.polkadotRegistryV9190.createType('Text', ''),
26
+ gasConsumed: registries_1.polkadotRegistryV9190.createType('u64', '7437907045'),
27
+ gasRequired: registries_1.polkadotRegistryV9190.createType('u64', '74999922688'),
28
+ output: true,
29
+ result: registries_1.polkadotRegistryV9190.createType('ContractExecResultResult', {
30
+ ok: {
31
+ flags: [],
32
+ data: '0x01',
33
+ },
34
+ }),
35
+ storageDeposit: registries_1.polkadotRegistryV9190.createType('StorageDeposit', {
36
+ charge: '0',
37
+ }),
38
+ };
39
+ });
40
+ const mockContractPromise = {
41
+ query: {
42
+ get: getFlipper,
43
+ },
44
+ };
45
+ describe('ContractsInkService', () => {
46
+ it('fetchContractCall', async () => {
47
+ const address = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
48
+ const result = await contractInkService.fetchContractCall(mockContractPromise, address, 'get');
49
+ const expectedResponse = {
50
+ debugMessage: '',
51
+ gasConsumed: '7437907045',
52
+ gasRequired: '74999922688',
53
+ output: true,
54
+ result: {
55
+ ok: {
56
+ flags: [],
57
+ data: '0x01',
58
+ },
59
+ },
60
+ storageDeposit: {
61
+ charge: '0',
62
+ },
63
+ };
64
+ expect((0, sanitizeNumbers_1.sanitizeNumbers)(result)).toStrictEqual(expectedResponse);
65
+ });
66
+ });
67
+ //# sourceMappingURL=ContractsInkService.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractsInkService.spec.js","sourceRoot":"","sources":["../../../../src/services/contracts/ContractsInkService.spec.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;AAIxE,oEAAiE;AACjE,8DAAsE;AACtE,+CAAsD;AACtD,wBAAwC;AAExC,MAAM,kBAAkB,GAAG,IAAI,sBAAmB,CAAC,qBAAc,CAAC,CAAC;AAEnE,MAAM,UAAU,GAAG,GAAG,EAAE,CACvB,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG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AAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './ContractsInkService';
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ // Copyright 2017-2022 Parity Technologies (UK) Ltd.
3
+ // This file is part of Substrate API Sidecar.
4
+ //
5
+ // Substrate API Sidecar is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ __exportStar(require("./ContractsInkService"), exports);
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/contracts/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;;;;;;;;;;;AAExE,wDAAsC"}
@@ -1,5 +1,6 @@
1
1
  export * from './accounts';
2
2
  export * from './blocks';
3
+ export * from './contracts';
3
4
  export * from './node';
4
5
  export * from './pallets';
5
6
  export * from './paras';
@@ -31,6 +31,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  __exportStar(require("./accounts"), exports);
33
33
  __exportStar(require("./blocks"), exports);
34
+ __exportStar(require("./contracts"), exports);
34
35
  __exportStar(require("./node"), exports);
35
36
  __exportStar(require("./pallets"), exports);
36
37
  __exportStar(require("./paras"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;;;;;;;;;;;AAExE,6CAA2B;AAC3B,2CAAyB;AACzB,yCAAuB;AACvB,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,wEAAwE;;;;;;;;;;;;;;;;AAExE,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,yCAAuB;AACvB,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,gDAA8B"}
@@ -6,10 +6,14 @@ import { ParamsDictionary, Query } from 'express-serve-static-core';
6
6
  export interface ITx {
7
7
  tx: string;
8
8
  }
9
+ /**
10
+ * Body for the RequestHandlerContract. In other words, the body of the POST route that a message to a contract.
11
+ */
12
+ export declare type IBodyContractMetadata = Record<string, unknown>;
9
13
  /**
10
14
  * Post Request - assuming no url params
11
15
  */
12
- export declare type IPostRequestHandler<T> = RequestHandler<{}, any, T, Query>;
16
+ export declare type IPostRequestHandler<T, P = Query> = RequestHandler<ParamsDictionary, unknown, T, P>;
13
17
  export interface INumberParam extends ParamsDictionary {
14
18
  number: string;
15
19
  }
@@ -25,6 +29,12 @@ export interface IParaIdParam extends ParamsDictionary {
25
29
  export interface IRangeQueryParam extends Query {
26
30
  range: string;
27
31
  }
32
+ export interface IContractQueryParam extends Query {
33
+ method: string;
34
+ args: string[];
35
+ gasLimit: string;
36
+ storageDepositLimit: string;
37
+ }
28
38
  export interface IPalletsStorageParam extends ParamsDictionary {
29
39
  palletId: string;
30
40
  storageItemId: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "14.1.2",
2
+ "version": "14.2.0",
3
3
  "name": "@substrate/api-sidecar",
4
4
  "description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
5
5
  "homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
@@ -36,6 +36,7 @@
36
36
  "dev": "tsc-watch --onSuccess \"yarn run main\"",
37
37
  "test": "NODE_ENV=test substrate-exec-jest --detectOpenHandles",
38
38
  "test:watch": "NODE_ENV=test substrate-exec-jest --watch",
39
+ "test:ci": "NODE_ENV=test substrate-exec-jest --runInBand",
39
40
  "lint:e2e-tests": "cd e2e-tests && substrate-dev-run-lint",
40
41
  "build:e2e-tests": "substrate-exec-tsc --project e2e-tests/tsconfig.json",
41
42
  "test:e2e-tests": "yarn build:e2e-tests && node ./e2e-tests/build/index.js --config=./e2e-tests/jest.config.js",
@@ -45,7 +46,7 @@
45
46
  "test:init-e2e-tests:westend": "yarn test:init-e2e-tests --chain westend",
46
47
  "test:init-e2e-tests:statemine": "yarn test:init-e2e-tests --chain statemine",
47
48
  "test:init-e2e-tests:statemint": "yarn test:init-e2e-tests --chain statemint",
48
- "start:e2e-scripts": "yarn build:scripts && node scripts/build/runChainTests.js",
49
+ "start:e2e-scripts": "yarn build:scripts && node scripts/build/runE2eTests.js",
49
50
  "build:scripts": "substrate-exec-rimraf scripts/build/ && substrate-exec-tsc --project scripts/tsconfig.json",
50
51
  "lint:scripts": "cd scripts && substrate-dev-run-lint",
51
52
  "start:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js",
@@ -53,9 +54,10 @@
53
54
  "update-pjs-deps": "substrate-update-pjs-deps && yarn"
54
55
  },
55
56
  "dependencies": {
56
- "@polkadot/api": "^9.9.1",
57
- "@polkadot/util-crypto": "^10.1.13",
58
- "@substrate/calc": "^0.3.0",
57
+ "@polkadot/api": "^9.10.1",
58
+ "@polkadot/api-contract": "^9.10.1",
59
+ "@polkadot/util-crypto": "^10.2.1",
60
+ "@substrate/calc": "^0.3.1",
59
61
  "argparse": "^2.0.1",
60
62
  "confmgr": "1.0.9",
61
63
  "express": "^4.18.1",