@substrate/api-sidecar 20.9.1 → 20.10.1
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.
- package/README.md +3 -3
- package/build/package.json +3 -3
- package/build/src/App.js +1 -1
- package/build/src/App.js.map +1 -1
- package/build/src/chains-config/assetHubKusamaControllers.js +4 -0
- package/build/src/chains-config/assetHubKusamaControllers.js.map +1 -1
- package/build/src/chains-config/assetHubNextWestendControllers.js +4 -0
- package/build/src/chains-config/assetHubNextWestendControllers.js.map +1 -1
- package/build/src/chains-config/assetHubPolkadotControllers.js +19 -3
- package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
- package/build/src/chains-config/assetHubWestendControllers.js +4 -0
- package/build/src/chains-config/assetHubWestendControllers.js.map +1 -1
- package/build/src/controllers/blocks/BlocksController.js +4 -32
- package/build/src/controllers/blocks/BlocksController.js.map +1 -1
- package/build/src/controllers/blocks/BlocksExtrinsicsController.js +2 -14
- package/build/src/controllers/blocks/BlocksExtrinsicsController.js.map +1 -1
- package/build/src/controllers/index.d.ts +5 -0
- package/build/src/controllers/index.js +10 -5
- package/build/src/controllers/index.js.map +1 -1
- package/build/src/controllers/rc/blocks/RcBlocksController.js +2 -14
- package/build/src/controllers/rc/blocks/RcBlocksController.js.map +1 -1
- package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js +1 -6
- package/build/src/controllers/rc/blocks/RcBlocksExtrinsicsController.js.map +1 -1
- package/build/src/controllers/rc/index.d.ts +1 -0
- package/build/src/controllers/rc/index.js +1 -0
- package/build/src/controllers/rc/index.js.map +1 -1
- package/build/src/controllers/rc/transaction/RcTransactionDryRunController.d.ts +36 -0
- package/build/src/controllers/rc/transaction/RcTransactionDryRunController.js +85 -0
- package/build/src/controllers/rc/transaction/RcTransactionDryRunController.js.map +1 -0
- package/build/src/controllers/rc/transaction/RcTransactionFeeEstimateController.d.ts +42 -0
- package/build/src/controllers/rc/transaction/RcTransactionFeeEstimateController.js +89 -0
- package/build/src/controllers/rc/transaction/RcTransactionFeeEstimateController.js.map +1 -0
- package/build/src/controllers/rc/transaction/RcTransactionMaterialController.d.ts +63 -0
- package/build/src/controllers/rc/transaction/RcTransactionMaterialController.js +151 -0
- package/build/src/controllers/rc/transaction/RcTransactionMaterialController.js.map +1 -0
- package/build/src/controllers/rc/transaction/RcTransactionSubmitController.d.ts +32 -0
- package/build/src/controllers/rc/transaction/RcTransactionSubmitController.js +78 -0
- package/build/src/controllers/rc/transaction/RcTransactionSubmitController.js.map +1 -0
- package/build/src/controllers/rc/transaction/index.d.ts +4 -0
- package/build/src/controllers/rc/transaction/index.js +30 -0
- package/build/src/controllers/rc/transaction/index.js.map +1 -0
- package/build/src/controllers/transaction/TransactionDryRunController.js +1 -1
- package/build/src/controllers/transaction/TransactionDryRunController.js.map +1 -1
- package/build/src/controllers/transaction/TransactionFeeEstimateController.js +1 -1
- package/build/src/controllers/transaction/TransactionFeeEstimateController.js.map +1 -1
- package/build/src/controllers/transaction/TransactionMaterialController.js +2 -2
- package/build/src/controllers/transaction/TransactionMaterialController.js.map +1 -1
- package/build/src/controllers/transaction/TransactionSubmitController.js +1 -1
- package/build/src/controllers/transaction/TransactionSubmitController.js.map +1 -1
- package/build/src/sanitize/sanitizeNumbers.js +8 -7
- package/build/src/sanitize/sanitizeNumbers.js.map +1 -1
- package/build/src/services/consts.js +8 -0
- package/build/src/services/consts.js.map +1 -1
- package/build/src/services/transaction/TransactionDryRunService.d.ts +2 -1
- package/build/src/services/transaction/TransactionDryRunService.js +1 -2
- package/build/src/services/transaction/TransactionDryRunService.js.map +1 -1
- package/build/src/services/transaction/TransactionDryRunService.spec.js +4 -4
- package/build/src/services/transaction/TransactionDryRunService.spec.js.map +1 -1
- package/build/src/services/transaction/TransactionFeeEstimateService.d.ts +3 -1
- package/build/src/services/transaction/TransactionFeeEstimateService.js +2 -2
- package/build/src/services/transaction/TransactionFeeEstimateService.js.map +1 -1
- package/build/src/services/transaction/TransactionFeeEstimateService.spec.js +4 -4
- package/build/src/services/transaction/TransactionFeeEstimateService.spec.js.map +1 -1
- package/build/src/services/transaction/TransactionMaterialService.d.ts +6 -2
- package/build/src/services/transaction/TransactionMaterialService.js +5 -4
- package/build/src/services/transaction/TransactionMaterialService.js.map +1 -1
- package/build/src/services/transaction/TransactionMaterialService.spec.js +3 -3
- package/build/src/services/transaction/TransactionMaterialService.spec.js.map +1 -1
- package/build/src/services/transaction/TransactionSubmitService.d.ts +3 -1
- package/build/src/services/transaction/TransactionSubmitService.js +2 -2
- package/build/src/services/transaction/TransactionSubmitService.js.map +1 -1
- package/build/src/services/transaction/TransactionSubmitService.spec.js +3 -3
- package/build/src/services/transaction/TransactionSubmitService.spec.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/rc/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,4CAA0B;AAC1B,4CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/rc/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,4CAA0B;AAC1B,4CAA0B;AAC1B,gDAA8B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TransactionDryRunService } from '../../../services';
|
|
2
|
+
import AbstractController from '../../AbstractController';
|
|
3
|
+
/**
|
|
4
|
+
* Dry run a transaction on the relay chain.
|
|
5
|
+
*
|
|
6
|
+
* Returns:
|
|
7
|
+
* - `at`:
|
|
8
|
+
* - `hash`: The block's hash.
|
|
9
|
+
* - `height`: The block's height.
|
|
10
|
+
* - `result`:
|
|
11
|
+
* - Successfull dry run:
|
|
12
|
+
* - `actualWeight`: The actual weight of the transaction.
|
|
13
|
+
* - `paysFee`: The fee to be paid.
|
|
14
|
+
* - Failed dry run:
|
|
15
|
+
* - error reason.
|
|
16
|
+
* - Dry run not possible to run:
|
|
17
|
+
* - `isUnimplemented`: The dry run is not implemented.
|
|
18
|
+
* - `isVersionedConversionFailed`: The versioned conversion failed.
|
|
19
|
+
* - `type`: 'Unimplemented' | 'VersionedConversionFailed';.
|
|
20
|
+
*
|
|
21
|
+
* References:
|
|
22
|
+
* - `DispatchError`: https://docs.rs/sp-runtime/39.0.1/sp_runtime/enum.DispatchError.html
|
|
23
|
+
* - `PostDispatchInfo`: https://docs.rs/frame-support/38.0.0/frame_support/dispatch/struct.PostDispatchInfo.html
|
|
24
|
+
* - `Error Type`: https://paritytech.github.io/polkadot-sdk/master/xcm_runtime_apis/dry_run/enum.Error.html
|
|
25
|
+
*
|
|
26
|
+
* Note: If you get the error `-32601: Method not found` it means that the node sidecar
|
|
27
|
+
* is connected to does not expose the `system_dryRun` RPC. One way to resolve this
|
|
28
|
+
* issue is to pass the `--rpc-external` flag to that node.
|
|
29
|
+
*/
|
|
30
|
+
export default class RcTransactionDryRunController extends AbstractController<TransactionDryRunService> {
|
|
31
|
+
static controllerName: string;
|
|
32
|
+
static requiredPallets: never[];
|
|
33
|
+
constructor(_api: string);
|
|
34
|
+
protected initRoutes(): void;
|
|
35
|
+
private dryRunTransaction;
|
|
36
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2025 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 http_errors_1 = require("http-errors");
|
|
22
|
+
const apiRegistry_1 = require("../../../apiRegistry");
|
|
23
|
+
const services_1 = require("../../../services");
|
|
24
|
+
const AbstractController_1 = __importDefault(require("../../AbstractController"));
|
|
25
|
+
/**
|
|
26
|
+
* Dry run a transaction on the relay chain.
|
|
27
|
+
*
|
|
28
|
+
* Returns:
|
|
29
|
+
* - `at`:
|
|
30
|
+
* - `hash`: The block's hash.
|
|
31
|
+
* - `height`: The block's height.
|
|
32
|
+
* - `result`:
|
|
33
|
+
* - Successfull dry run:
|
|
34
|
+
* - `actualWeight`: The actual weight of the transaction.
|
|
35
|
+
* - `paysFee`: The fee to be paid.
|
|
36
|
+
* - Failed dry run:
|
|
37
|
+
* - error reason.
|
|
38
|
+
* - Dry run not possible to run:
|
|
39
|
+
* - `isUnimplemented`: The dry run is not implemented.
|
|
40
|
+
* - `isVersionedConversionFailed`: The versioned conversion failed.
|
|
41
|
+
* - `type`: 'Unimplemented' | 'VersionedConversionFailed';.
|
|
42
|
+
*
|
|
43
|
+
* References:
|
|
44
|
+
* - `DispatchError`: https://docs.rs/sp-runtime/39.0.1/sp_runtime/enum.DispatchError.html
|
|
45
|
+
* - `PostDispatchInfo`: https://docs.rs/frame-support/38.0.0/frame_support/dispatch/struct.PostDispatchInfo.html
|
|
46
|
+
* - `Error Type`: https://paritytech.github.io/polkadot-sdk/master/xcm_runtime_apis/dry_run/enum.Error.html
|
|
47
|
+
*
|
|
48
|
+
* Note: If you get the error `-32601: Method not found` it means that the node sidecar
|
|
49
|
+
* is connected to does not expose the `system_dryRun` RPC. One way to resolve this
|
|
50
|
+
* issue is to pass the `--rpc-external` flag to that node.
|
|
51
|
+
*/
|
|
52
|
+
class RcTransactionDryRunController extends AbstractController_1.default {
|
|
53
|
+
constructor(_api) {
|
|
54
|
+
var _a;
|
|
55
|
+
const rcApiSpecName = (_a = apiRegistry_1.ApiPromiseRegistry.getSpecNameByType('relay')) === null || _a === void 0 ? void 0 : _a.values();
|
|
56
|
+
const rcSpecName = rcApiSpecName ? Array.from(rcApiSpecName)[0] : undefined;
|
|
57
|
+
if (!rcSpecName) {
|
|
58
|
+
throw new Error('Relay chain API spec name is not defined.');
|
|
59
|
+
}
|
|
60
|
+
super(rcSpecName, '/rc/transaction/dry-run', new services_1.TransactionDryRunService(rcSpecName));
|
|
61
|
+
this.dryRunTransaction = async ({ body: { tx, at, senderAddress, xcmVersion } }, res) => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!tx) {
|
|
64
|
+
throw new http_errors_1.BadRequest('Missing field `tx` on request body.');
|
|
65
|
+
}
|
|
66
|
+
if (!senderAddress) {
|
|
67
|
+
throw new http_errors_1.BadRequest('Missing field `senderAddress` on request body.');
|
|
68
|
+
}
|
|
69
|
+
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
70
|
+
if (!rcApi) {
|
|
71
|
+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
72
|
+
}
|
|
73
|
+
const hash = await this.getHashFromAt(at, { api: rcApi });
|
|
74
|
+
RcTransactionDryRunController.sanitizedSend(res, await this.service.dryRuntExtrinsic(rcApi, senderAddress, tx, hash, xcmVersion));
|
|
75
|
+
};
|
|
76
|
+
this.initRoutes();
|
|
77
|
+
}
|
|
78
|
+
initRoutes() {
|
|
79
|
+
this.router.post(this.path, RcTransactionDryRunController.catchWrap(this.dryRunTransaction));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
RcTransactionDryRunController.controllerName = 'RcTransactionDryRun';
|
|
83
|
+
RcTransactionDryRunController.requiredPallets = [];
|
|
84
|
+
exports.default = RcTransactionDryRunController;
|
|
85
|
+
//# sourceMappingURL=RcTransactionDryRunController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RcTransactionDryRunController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/transaction/RcTransactionDryRunController.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,6CAAyC;AAEzC,sDAA0D;AAC1D,gDAA6D;AAE7D,kFAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAqB,6BAA8B,SAAQ,4BAA4C;IAGtG,YAAY,IAAY;;QACvB,MAAM,aAAa,GAAG,MAAA,gCAAkB,CAAC,iBAAiB,CAAC,OAAO,CAAC,0CAAE,MAAM,EAAE,CAAC;QAC9E,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAA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AE,6BAA6B,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC9F,CAAC;;AAdM,4CAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,6CAAe,GAAG,EAAE,AAAL,CAAM;kBAFR,6BAA6B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TransactionFeeEstimateService } from '../../../services';
|
|
2
|
+
import AbstractController from '../../AbstractController';
|
|
3
|
+
/**
|
|
4
|
+
* POST a serialized transaction and receive a fee estimate for the relay chain.
|
|
5
|
+
*
|
|
6
|
+
* Post info:
|
|
7
|
+
* - `data`: Expects a hex-encoded transaction, e.g. '{"tx": "0x..."}'.
|
|
8
|
+
* - `headers`: Expects 'Content-Type: application/json'.
|
|
9
|
+
*
|
|
10
|
+
* Returns:
|
|
11
|
+
* - Success:
|
|
12
|
+
* - `weight`: Extrinsic weight.
|
|
13
|
+
* - `class`: Extrinsic class, one of 'Normal', 'Operational', or 'Mandatory'.
|
|
14
|
+
* - `partialFee`: _Expected_ inclusion fee for the transaction. Note that the fee rate changes
|
|
15
|
+
* up to 30% in a 24 hour period and this will not be the exact fee.
|
|
16
|
+
* - Failure:
|
|
17
|
+
* - `error`: Error description.
|
|
18
|
+
* - `extrinsic`: The extrinsic and reference block hash.
|
|
19
|
+
* - `cause`: Error message from the client.
|
|
20
|
+
*
|
|
21
|
+
* Note: `partialFee` does not include any tips that you may add to increase a transaction's
|
|
22
|
+
* priority. See the reference on `compute_fee`.
|
|
23
|
+
*
|
|
24
|
+
* Substrate Reference:
|
|
25
|
+
* - `RuntimeDispatchInfo`: https://crates.parity.io/pallet_transaction_payment_rpc_runtime_api/struct.RuntimeDispatchInfo.html
|
|
26
|
+
* - `query_info`: https://crates.parity.io/pallet_transaction_payment/struct.Module.html#method.query_info
|
|
27
|
+
* - `compute_fee`: https://crates.parity.io/pallet_transaction_payment/struct.Module.html#method.compute_fee
|
|
28
|
+
*/
|
|
29
|
+
export default class RcTransactionFeeEstimateController extends AbstractController<TransactionFeeEstimateService> {
|
|
30
|
+
static controllerName: string;
|
|
31
|
+
static requiredPallets: never[];
|
|
32
|
+
constructor(_api: string);
|
|
33
|
+
protected initRoutes(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Submit a serialized transaction in order to receive an estimate for its
|
|
36
|
+
* partial fees.
|
|
37
|
+
*
|
|
38
|
+
* @param req Sidecar TxRequest
|
|
39
|
+
* @param res Express Response
|
|
40
|
+
*/
|
|
41
|
+
private txFeeEstimate;
|
|
42
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2025 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 apiRegistry_1 = require("../../../apiRegistry");
|
|
22
|
+
const services_1 = require("../../../services");
|
|
23
|
+
const AbstractController_1 = __importDefault(require("../../AbstractController"));
|
|
24
|
+
/**
|
|
25
|
+
* POST a serialized transaction and receive a fee estimate for the relay chain.
|
|
26
|
+
*
|
|
27
|
+
* Post info:
|
|
28
|
+
* - `data`: Expects a hex-encoded transaction, e.g. '{"tx": "0x..."}'.
|
|
29
|
+
* - `headers`: Expects 'Content-Type: application/json'.
|
|
30
|
+
*
|
|
31
|
+
* Returns:
|
|
32
|
+
* - Success:
|
|
33
|
+
* - `weight`: Extrinsic weight.
|
|
34
|
+
* - `class`: Extrinsic class, one of 'Normal', 'Operational', or 'Mandatory'.
|
|
35
|
+
* - `partialFee`: _Expected_ inclusion fee for the transaction. Note that the fee rate changes
|
|
36
|
+
* up to 30% in a 24 hour period and this will not be the exact fee.
|
|
37
|
+
* - Failure:
|
|
38
|
+
* - `error`: Error description.
|
|
39
|
+
* - `extrinsic`: The extrinsic and reference block hash.
|
|
40
|
+
* - `cause`: Error message from the client.
|
|
41
|
+
*
|
|
42
|
+
* Note: `partialFee` does not include any tips that you may add to increase a transaction's
|
|
43
|
+
* priority. See the reference on `compute_fee`.
|
|
44
|
+
*
|
|
45
|
+
* Substrate Reference:
|
|
46
|
+
* - `RuntimeDispatchInfo`: https://crates.parity.io/pallet_transaction_payment_rpc_runtime_api/struct.RuntimeDispatchInfo.html
|
|
47
|
+
* - `query_info`: https://crates.parity.io/pallet_transaction_payment/struct.Module.html#method.query_info
|
|
48
|
+
* - `compute_fee`: https://crates.parity.io/pallet_transaction_payment/struct.Module.html#method.compute_fee
|
|
49
|
+
*/
|
|
50
|
+
class RcTransactionFeeEstimateController extends AbstractController_1.default {
|
|
51
|
+
constructor(_api) {
|
|
52
|
+
var _a;
|
|
53
|
+
const rcApiSpecName = (_a = apiRegistry_1.ApiPromiseRegistry.getSpecNameByType('relay')) === null || _a === void 0 ? void 0 : _a.values();
|
|
54
|
+
const rcSpecName = rcApiSpecName ? Array.from(rcApiSpecName)[0] : undefined;
|
|
55
|
+
if (!rcSpecName) {
|
|
56
|
+
throw new Error('Relay chain API spec name is not defined.');
|
|
57
|
+
}
|
|
58
|
+
super(rcSpecName, '/rc/transaction/fee-estimate', new services_1.TransactionFeeEstimateService(rcSpecName));
|
|
59
|
+
/**
|
|
60
|
+
* Submit a serialized transaction in order to receive an estimate for its
|
|
61
|
+
* partial fees.
|
|
62
|
+
*
|
|
63
|
+
* @param req Sidecar TxRequest
|
|
64
|
+
* @param res Express Response
|
|
65
|
+
*/
|
|
66
|
+
this.txFeeEstimate = async ({ body: { tx } }, res) => {
|
|
67
|
+
var _a;
|
|
68
|
+
if (!tx) {
|
|
69
|
+
throw {
|
|
70
|
+
error: 'Missing field `tx` on request body.',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
74
|
+
if (!rcApi) {
|
|
75
|
+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
76
|
+
}
|
|
77
|
+
const hash = await rcApi.rpc.chain.getFinalizedHead();
|
|
78
|
+
RcTransactionFeeEstimateController.sanitizedSend(res, await this.service.fetchTransactionFeeEstimate(rcApi, hash, tx));
|
|
79
|
+
};
|
|
80
|
+
this.initRoutes();
|
|
81
|
+
}
|
|
82
|
+
initRoutes() {
|
|
83
|
+
this.router.post(this.path, RcTransactionFeeEstimateController.catchWrap(this.txFeeEstimate));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
RcTransactionFeeEstimateController.controllerName = 'RcTransactionFeeEstimate';
|
|
87
|
+
RcTransactionFeeEstimateController.requiredPallets = [];
|
|
88
|
+
exports.default = RcTransactionFeeEstimateController;
|
|
89
|
+
//# sourceMappingURL=RcTransactionFeeEstimateController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RcTransactionFeeEstimateController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/transaction/RcTransactionFeeEstimateController.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,8CAA8C;AAC9C,EAAE;AACF,gFAAgF;AAChF,uEAAuE;AACvE,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aAAa,CAC/C,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAC/D,CAAC;QACH,CAAC,CAAC;QAjCD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,kCAAkC,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/F,CAAC;;AAdM,iDAAc,GAAG,0BAA0B,AAA7B,CAA8B;AAC5C,kDAAe,GAAG,EAAE,AAAL,CAAM;kBAFR,kCAAkC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { TransactionMaterialService } from '../../../services';
|
|
2
|
+
import AbstractController from '../../AbstractController';
|
|
3
|
+
/**
|
|
4
|
+
* GET all the network information needed to construct a transaction offline for the relay chain.
|
|
5
|
+
*
|
|
6
|
+
* Path params:
|
|
7
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
8
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
9
|
+
*
|
|
10
|
+
* Query
|
|
11
|
+
* - (Optional) `metadata`: It accepts `json`, or `scale` values. If it is not present,
|
|
12
|
+
* the metadata field will not be included.
|
|
13
|
+
* - (Optional) `at`: Block hash or number at which to query. If not provided, queries
|
|
14
|
+
* finalized head.
|
|
15
|
+
*
|
|
16
|
+
* Returns:
|
|
17
|
+
* - `at`: Block number and hash at which the call was made.
|
|
18
|
+
* - `genesisHash`: The hash of the chain's genesis block.
|
|
19
|
+
* - `chainName`: The chain's name.
|
|
20
|
+
* - `specName`: The chain's spec.
|
|
21
|
+
* - `specVersion`: The spec version. Always increased in a runtime upgrade.
|
|
22
|
+
* - `txversion`: The transaction version. Common `txVersion` numbers indicate that the
|
|
23
|
+
* transaction encoding format and method indices are the same. Needed for decoding in an
|
|
24
|
+
* offline environment. Adding new transactions does not change `txVersion`.
|
|
25
|
+
* - `metadata`: The chain's metadata in hex format.
|
|
26
|
+
*
|
|
27
|
+
* Note: `chainName`, `specName`, and `specVersion` are used to define a type registry with a set
|
|
28
|
+
* of signed extensions and types. For Polkadot and Kusama, `chainName` is not used in defining
|
|
29
|
+
* this registry, but in other Substrate-based chains that re-launch their network without
|
|
30
|
+
* changing the `specName`, the `chainName` would be needed to create the correct registry.
|
|
31
|
+
*
|
|
32
|
+
* Substrate Reference:
|
|
33
|
+
* - `RuntimeVersion`: https://crates.parity.io/sp_version/struct.RuntimeVersion.html
|
|
34
|
+
* - `SignedExtension`: https://crates.parity.io/sp_runtime/traits/trait.SignedExtension.html
|
|
35
|
+
* - FRAME Support: https://crates.parity.io/frame_support/metadata/index.html
|
|
36
|
+
*/
|
|
37
|
+
export default class RcTransactionMaterialController extends AbstractController<TransactionMaterialService> {
|
|
38
|
+
static controllerName: string;
|
|
39
|
+
static requiredPallets: never[];
|
|
40
|
+
constructor(_api: string);
|
|
41
|
+
protected initRoutes(): void;
|
|
42
|
+
/**
|
|
43
|
+
* GET all the network information needed to construct a transaction offline.
|
|
44
|
+
*
|
|
45
|
+
* @param _req Express Request
|
|
46
|
+
* @param res Express Response
|
|
47
|
+
*/
|
|
48
|
+
private getTransactionMaterial;
|
|
49
|
+
/**
|
|
50
|
+
* The metadata args have two options. `json`, and `scale`.
|
|
51
|
+
*
|
|
52
|
+
* @param metadata
|
|
53
|
+
*/
|
|
54
|
+
private parseMetadataArgs;
|
|
55
|
+
/**
|
|
56
|
+
* Get the chain's metadata at the requested version in JSON or scale format
|
|
57
|
+
* depending on the `metadata` query param.
|
|
58
|
+
*
|
|
59
|
+
* @param _req Express Request
|
|
60
|
+
* @param res Express Response
|
|
61
|
+
*/
|
|
62
|
+
private getTransactionMaterialwithVersionedMetadata;
|
|
63
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2025 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 apiRegistry_1 = require("../../../apiRegistry");
|
|
22
|
+
const services_1 = require("../../../services");
|
|
23
|
+
const AbstractController_1 = __importDefault(require("../../AbstractController"));
|
|
24
|
+
/**
|
|
25
|
+
* GET all the network information needed to construct a transaction offline for the relay chain.
|
|
26
|
+
*
|
|
27
|
+
* Path params:
|
|
28
|
+
* - (Optional) `metadataVersion`: The specific version of the Metadata to query.
|
|
29
|
+
* The input must conform to the `vX` format, where `X` represents the version number (examples: 'v14', 'v15').
|
|
30
|
+
*
|
|
31
|
+
* Query
|
|
32
|
+
* - (Optional) `metadata`: It accepts `json`, or `scale` values. If it is not present,
|
|
33
|
+
* the metadata field will not be included.
|
|
34
|
+
* - (Optional) `at`: Block hash or number at which to query. If not provided, queries
|
|
35
|
+
* finalized head.
|
|
36
|
+
*
|
|
37
|
+
* Returns:
|
|
38
|
+
* - `at`: Block number and hash at which the call was made.
|
|
39
|
+
* - `genesisHash`: The hash of the chain's genesis block.
|
|
40
|
+
* - `chainName`: The chain's name.
|
|
41
|
+
* - `specName`: The chain's spec.
|
|
42
|
+
* - `specVersion`: The spec version. Always increased in a runtime upgrade.
|
|
43
|
+
* - `txversion`: The transaction version. Common `txVersion` numbers indicate that the
|
|
44
|
+
* transaction encoding format and method indices are the same. Needed for decoding in an
|
|
45
|
+
* offline environment. Adding new transactions does not change `txVersion`.
|
|
46
|
+
* - `metadata`: The chain's metadata in hex format.
|
|
47
|
+
*
|
|
48
|
+
* Note: `chainName`, `specName`, and `specVersion` are used to define a type registry with a set
|
|
49
|
+
* of signed extensions and types. For Polkadot and Kusama, `chainName` is not used in defining
|
|
50
|
+
* this registry, but in other Substrate-based chains that re-launch their network without
|
|
51
|
+
* changing the `specName`, the `chainName` would be needed to create the correct registry.
|
|
52
|
+
*
|
|
53
|
+
* Substrate Reference:
|
|
54
|
+
* - `RuntimeVersion`: https://crates.parity.io/sp_version/struct.RuntimeVersion.html
|
|
55
|
+
* - `SignedExtension`: https://crates.parity.io/sp_runtime/traits/trait.SignedExtension.html
|
|
56
|
+
* - FRAME Support: https://crates.parity.io/frame_support/metadata/index.html
|
|
57
|
+
*/
|
|
58
|
+
class RcTransactionMaterialController extends AbstractController_1.default {
|
|
59
|
+
constructor(_api) {
|
|
60
|
+
var _a;
|
|
61
|
+
const rcApiSpecName = (_a = apiRegistry_1.ApiPromiseRegistry.getSpecNameByType('relay')) === null || _a === void 0 ? void 0 : _a.values();
|
|
62
|
+
const rcSpecName = rcApiSpecName ? Array.from(rcApiSpecName)[0] : undefined;
|
|
63
|
+
if (!rcSpecName) {
|
|
64
|
+
throw new Error('Relay chain API spec name is not defined.');
|
|
65
|
+
}
|
|
66
|
+
super(rcSpecName, '/rc/transaction/material', new services_1.TransactionMaterialService(rcSpecName));
|
|
67
|
+
/**
|
|
68
|
+
* GET all the network information needed to construct a transaction offline.
|
|
69
|
+
*
|
|
70
|
+
* @param _req Express Request
|
|
71
|
+
* @param res Express Response
|
|
72
|
+
*/
|
|
73
|
+
this.getTransactionMaterial = async ({ query: { at, metadata } }, res) => {
|
|
74
|
+
var _a;
|
|
75
|
+
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
76
|
+
if (!rcApi) {
|
|
77
|
+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
78
|
+
}
|
|
79
|
+
const hash = await this.getHashFromAt(at, { api: rcApi });
|
|
80
|
+
const metadataArg = this.parseMetadataArgs(metadata);
|
|
81
|
+
RcTransactionMaterialController.sanitizedSend(res, await this.service.fetchTransactionMaterial(rcApi, hash, metadataArg));
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get the chain's metadata at the requested version in JSON or scale format
|
|
85
|
+
* depending on the `metadata` query param.
|
|
86
|
+
*
|
|
87
|
+
* @param _req Express Request
|
|
88
|
+
* @param res Express Response
|
|
89
|
+
*/
|
|
90
|
+
this.getTransactionMaterialwithVersionedMetadata = async ({ params: { metadataVersion }, query: { at, metadata } }, res) => {
|
|
91
|
+
var _a;
|
|
92
|
+
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
93
|
+
if (!rcApi) {
|
|
94
|
+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
95
|
+
}
|
|
96
|
+
const hash = await this.getHashFromAt(at, { api: rcApi });
|
|
97
|
+
const api = at ? await rcApi.at(hash) : rcApi;
|
|
98
|
+
// Validation of the `metadataVersion` path parameter.
|
|
99
|
+
const metadataV = metadataVersion.slice(1);
|
|
100
|
+
const version = this.parseNumberOrThrow(metadataV, `Version ${metadataV.toString()} of metadata provided is not a number.`);
|
|
101
|
+
const regExPattern = new RegExp('^[vV][0-9]+$');
|
|
102
|
+
if (!regExPattern.test(metadataVersion)) {
|
|
103
|
+
throw new Error(`${metadataVersion} input is not of the expected 'vX' format, where 'X' represents the version number (examples: 'v14', 'v15').`);
|
|
104
|
+
}
|
|
105
|
+
let availableVersions = [];
|
|
106
|
+
try {
|
|
107
|
+
availableVersions = (await api.call.metadata.metadataVersions()).toJSON();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
throw new Error(`Function 'api.call.metadata.metadataVersions()' is not available at this block height.`);
|
|
111
|
+
}
|
|
112
|
+
if (version && !(availableVersions === null || availableVersions === void 0 ? void 0 : availableVersions.includes(version))) {
|
|
113
|
+
throw new Error(`Version ${version} of Metadata is not available.`);
|
|
114
|
+
}
|
|
115
|
+
const metadataArg = this.parseMetadataArgs(metadata);
|
|
116
|
+
RcTransactionMaterialController.sanitizedSend(res, await this.service.fetchTransactionMaterialwithVersionedMetadata(rcApi, api, hash, metadataArg, version));
|
|
117
|
+
};
|
|
118
|
+
this.initRoutes();
|
|
119
|
+
}
|
|
120
|
+
initRoutes() {
|
|
121
|
+
this.safeMountAsyncGetHandlers([
|
|
122
|
+
['/', this.getTransactionMaterial],
|
|
123
|
+
['/:metadataVersion', this.getTransactionMaterialwithVersionedMetadata],
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The metadata args have two options. `json`, and `scale`.
|
|
128
|
+
*
|
|
129
|
+
* @param metadata
|
|
130
|
+
*/
|
|
131
|
+
parseMetadataArgs(metadata) {
|
|
132
|
+
/**
|
|
133
|
+
* Checks to see if the `metadata` query param is inputted.
|
|
134
|
+
*/
|
|
135
|
+
if (metadata) {
|
|
136
|
+
switch (metadata) {
|
|
137
|
+
case 'json':
|
|
138
|
+
return 'json';
|
|
139
|
+
case 'scale':
|
|
140
|
+
return 'scale';
|
|
141
|
+
default:
|
|
142
|
+
throw new Error('Invalid inputted value for the `metadata` query param. Options are `scale` or `json`.');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
RcTransactionMaterialController.controllerName = 'RcTransactionMaterial';
|
|
149
|
+
RcTransactionMaterialController.requiredPallets = [];
|
|
150
|
+
exports.default = RcTransactionMaterialController;
|
|
151
|
+
//# sourceMappingURL=RcTransactionMaterialController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RcTransactionMaterialController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/transaction/RcTransactionMaterialController.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,sDAA0D;AAC1D,gDAA+D;AAC/D,kFAA0D;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAqB,+BAAgC,SAAQ,4BAA8C;IAG1G,YAAY,IAAY;;QACvB,MAAM,aAAa,GAAG,MAAA,gCAAkB,CAAC,iBAAiB,CAAC,OAAO,CAAC,0CAAE,MAAM,EAAE,CAAC;QAC9E,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CAAC,UAAU,EAAE,0BAA0B,EAAE,IAAI,qCAA0B,CAAC,UAAU,CAAC,CAAC,CAAC;QAW3F;;;;;WAKG;QACK,2BAAsB,GAAmB,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAiB,EAAE;;YAC1G,MAAM,KAAK,GAAG,M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;;;OAIG;IACK,iBAAiB,CAAC,QAAiB;QAC1C;;WAEG;QACH,IAAI,QAAQ,EAAE,CAAC;YACd,QAAQ,QAAQ,EAAE,CAAC;gBAClB,KAAK,MAAM;oBACV,OAAO,MAAM,CAAC;gBACf,KAAK,OAAO;oBACX,OAAO,OAAO,CAAC;gBAChB;oBACC,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;YAC3G,CAAC;QACF,CAAC;QAED,OAAO,KAAK,CAAC;IACd,CAAC;;AA/DM,8CAAc,GAAG,uBAAuB,AAA1B,CAA2B;AACzC,+CAAe,GAAG,EAAE,AAAL,CAAM;kBAFR,+BAA+B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TransactionSubmitService } from '../../../services';
|
|
2
|
+
import AbstractController from '../../AbstractController';
|
|
3
|
+
/**
|
|
4
|
+
* POST a serialized transaction to submit to the relay chain transaction queue.
|
|
5
|
+
*
|
|
6
|
+
* Post info:
|
|
7
|
+
* - `data`: Expects a hex-encoded transaction, e.g. '{"tx": "0x..."}'.
|
|
8
|
+
* - `headers`: Expects 'Content-Type: application/json'.
|
|
9
|
+
*
|
|
10
|
+
* Returns:
|
|
11
|
+
* - Success:
|
|
12
|
+
* - `hash`: The hash of the encoded transaction.
|
|
13
|
+
* - Failure:
|
|
14
|
+
* - `error`: 'Failed to parse transaction' or 'Failed to submit transaction'. In the case of the former,
|
|
15
|
+
* Sidecar was unable to parse the transaction and never submitted it to the client. In
|
|
16
|
+
* the case of the latter, the transaction queue rejected the transaction.
|
|
17
|
+
* - `extrinsic`: The hex-encoded extrinsic. Only present if Sidecar fails to parse a transaction.
|
|
18
|
+
* - `cause`: The error message from parsing or from the client.
|
|
19
|
+
*/
|
|
20
|
+
export default class RcTransactionSubmitController extends AbstractController<TransactionSubmitService> {
|
|
21
|
+
static controllerName: string;
|
|
22
|
+
static requiredPallets: never[];
|
|
23
|
+
constructor(_api: string);
|
|
24
|
+
protected initRoutes(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Submit a serialized transaction to the transaction queue.
|
|
27
|
+
*
|
|
28
|
+
* @param req Sidecar TxRequest
|
|
29
|
+
* @param res Express Response
|
|
30
|
+
*/
|
|
31
|
+
private txSubmit;
|
|
32
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2025 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 apiRegistry_1 = require("../../../apiRegistry");
|
|
22
|
+
const services_1 = require("../../../services");
|
|
23
|
+
const AbstractController_1 = __importDefault(require("../../AbstractController"));
|
|
24
|
+
/**
|
|
25
|
+
* POST a serialized transaction to submit to the relay chain transaction queue.
|
|
26
|
+
*
|
|
27
|
+
* Post info:
|
|
28
|
+
* - `data`: Expects a hex-encoded transaction, e.g. '{"tx": "0x..."}'.
|
|
29
|
+
* - `headers`: Expects 'Content-Type: application/json'.
|
|
30
|
+
*
|
|
31
|
+
* Returns:
|
|
32
|
+
* - Success:
|
|
33
|
+
* - `hash`: The hash of the encoded transaction.
|
|
34
|
+
* - Failure:
|
|
35
|
+
* - `error`: 'Failed to parse transaction' or 'Failed to submit transaction'. In the case of the former,
|
|
36
|
+
* Sidecar was unable to parse the transaction and never submitted it to the client. In
|
|
37
|
+
* the case of the latter, the transaction queue rejected the transaction.
|
|
38
|
+
* - `extrinsic`: The hex-encoded extrinsic. Only present if Sidecar fails to parse a transaction.
|
|
39
|
+
* - `cause`: The error message from parsing or from the client.
|
|
40
|
+
*/
|
|
41
|
+
class RcTransactionSubmitController extends AbstractController_1.default {
|
|
42
|
+
constructor(_api) {
|
|
43
|
+
var _a;
|
|
44
|
+
const rcApiSpecName = (_a = apiRegistry_1.ApiPromiseRegistry.getSpecNameByType('relay')) === null || _a === void 0 ? void 0 : _a.values();
|
|
45
|
+
const rcSpecName = rcApiSpecName ? Array.from(rcApiSpecName)[0] : undefined;
|
|
46
|
+
if (!rcSpecName) {
|
|
47
|
+
throw new Error('Relay chain API spec name is not defined.');
|
|
48
|
+
}
|
|
49
|
+
super(rcSpecName, '/rc/transaction', new services_1.TransactionSubmitService(rcSpecName));
|
|
50
|
+
/**
|
|
51
|
+
* Submit a serialized transaction to the transaction queue.
|
|
52
|
+
*
|
|
53
|
+
* @param req Sidecar TxRequest
|
|
54
|
+
* @param res Express Response
|
|
55
|
+
*/
|
|
56
|
+
this.txSubmit = async ({ body: { tx } }, res) => {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!tx) {
|
|
59
|
+
throw {
|
|
60
|
+
error: 'Missing field `tx` on request body.',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const rcApi = (_a = apiRegistry_1.ApiPromiseRegistry.getApiByType('relay')[0]) === null || _a === void 0 ? void 0 : _a.api;
|
|
64
|
+
if (!rcApi) {
|
|
65
|
+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
|
|
66
|
+
}
|
|
67
|
+
res.send(await this.service.submitTransaction(rcApi, tx));
|
|
68
|
+
};
|
|
69
|
+
this.initRoutes();
|
|
70
|
+
}
|
|
71
|
+
initRoutes() {
|
|
72
|
+
this.router.post(this.path, RcTransactionSubmitController.catchWrap(this.txSubmit));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
RcTransactionSubmitController.controllerName = 'RcTransactionSubmit';
|
|
76
|
+
RcTransactionSubmitController.requiredPallets = [];
|
|
77
|
+
exports.default = RcTransactionSubmitController;
|
|
78
|
+
//# sourceMappingURL=RcTransactionSubmitController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RcTransactionSubmitController.js","sourceRoot":"","sources":["../../../../../src/controllers/rc/transaction/RcTransactionSubmitController.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,sDAA0D;AAC1D,gDAA6D;AAE7D,kFAA0D;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAqB,6BAA8B,SAAQ,4BAA4C;IAGtG,YAAY,IAAY;;QACvB,MAAM,aAAa,GAAG,MAAA,gCAAkB,CAAC,iBAAiB,CAAC,OAAO,CAAC,0CAAE,MAAM,EAAE,CAAC;QAC9E,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CAAC,UAAU,EAAE,iBAAiB,EAAE,IAAI,mCAAwB,CAAC,UAAU,CAAC,CAAC,CAAC;QAQhF;;;;;WAKG;QACK,aAAQ,GAA6B,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAiB,EAAE;;YAC3F,IAAI,CAAC,EAAE,EAAE,CAAC;gBACT,MAAM;oBACL,KAAK,EAAE,qCAAqC;iBAC5C,CAAC;YACH,CAAC;YAED,MAAM,KAAK,GAAG,MAAA,gCAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,0CAAE,GAAG,CAAC;YAE/D,IAAI,CAAC,KAAK,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;YACrG,CAAC;YAED,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC;QA3BD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,6BAA6B,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrF,CAAC;;AAdM,4CAAc,GAAG,qBAAqB,AAAxB,CAAyB;AACvC,6CAAe,GAAG,EAAE,AAAL,CAAM;kBAFR,6BAA6B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as RcTransactionDryRun } from './RcTransactionDryRunController';
|
|
2
|
+
export { default as RcTransactionFeeEstimate } from './RcTransactionFeeEstimateController';
|
|
3
|
+
export { default as RcTransactionMaterial } from './RcTransactionMaterialController';
|
|
4
|
+
export { default as RcTransactionSubmit } from './RcTransactionSubmitController';
|