@substrate/api-sidecar 17.1.2 → 17.3.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.
- package/build/package.json +7 -7
- package/build/src/chains-config/acalaControllers.js +1 -0
- package/build/src/chains-config/acalaControllers.js.map +1 -1
- package/build/src/chains-config/assetHubKusamaControllers.js +2 -0
- package/build/src/chains-config/assetHubKusamaControllers.js.map +1 -1
- package/build/src/chains-config/assetHubPolkadotControllers.js +2 -0
- package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
- package/build/src/chains-config/assetHubWestendControllers.d.ts +5 -0
- package/build/src/chains-config/assetHubWestendControllers.js +57 -0
- package/build/src/chains-config/assetHubWestendControllers.js.map +1 -0
- package/build/src/chains-config/astarControllers.js +1 -0
- package/build/src/chains-config/astarControllers.js.map +1 -1
- package/build/src/chains-config/bifrostControllers.js +1 -0
- package/build/src/chains-config/bifrostControllers.js.map +1 -1
- package/build/src/chains-config/bifrostPolkadotControllers.js +1 -0
- package/build/src/chains-config/bifrostPolkadotControllers.js.map +1 -1
- package/build/src/chains-config/calamariControllers.js +1 -0
- package/build/src/chains-config/calamariControllers.js.map +1 -1
- package/build/src/chains-config/crustControllers.js +1 -0
- package/build/src/chains-config/crustControllers.js.map +1 -1
- package/build/src/chains-config/defaultControllers.js +2 -0
- package/build/src/chains-config/defaultControllers.js.map +1 -1
- package/build/src/chains-config/dockMainnetControllers.js +1 -0
- package/build/src/chains-config/dockMainnetControllers.js.map +1 -1
- package/build/src/chains-config/dockPoSMainnetControllers.js +1 -0
- package/build/src/chains-config/dockPoSMainnetControllers.js.map +1 -1
- package/build/src/chains-config/dockPoSTestnetControllers.js +1 -0
- package/build/src/chains-config/dockPoSTestnetControllers.js.map +1 -1
- package/build/src/chains-config/heikoControllers.js +1 -0
- package/build/src/chains-config/heikoControllers.js.map +1 -1
- package/build/src/chains-config/index.js +3 -1
- package/build/src/chains-config/index.js.map +1 -1
- package/build/src/chains-config/karuraControllers.js +1 -0
- package/build/src/chains-config/karuraControllers.js.map +1 -1
- package/build/src/chains-config/kiltControllers.js +1 -0
- package/build/src/chains-config/kiltControllers.js.map +1 -1
- package/build/src/chains-config/kulupuControllers.js +1 -0
- package/build/src/chains-config/kulupuControllers.js.map +1 -1
- package/build/src/chains-config/kusamaControllers.js +1 -0
- package/build/src/chains-config/kusamaControllers.js.map +1 -1
- package/build/src/chains-config/mandalaControllers.js +1 -0
- package/build/src/chains-config/mandalaControllers.js.map +1 -1
- package/build/src/chains-config/mantaControllers.js +1 -0
- package/build/src/chains-config/mantaControllers.js.map +1 -1
- package/build/src/chains-config/parallelControllers.js +1 -0
- package/build/src/chains-config/parallelControllers.js.map +1 -1
- package/build/src/chains-config/polkadotControllers.js +1 -0
- package/build/src/chains-config/polkadotControllers.js.map +1 -1
- package/build/src/chains-config/polymeshControllers.js +1 -0
- package/build/src/chains-config/polymeshControllers.js.map +1 -1
- package/build/src/chains-config/shidenControllers.js +1 -0
- package/build/src/chains-config/shidenControllers.js.map +1 -1
- package/build/src/chains-config/soraControllers.js +1 -0
- package/build/src/chains-config/soraControllers.js.map +1 -1
- package/build/src/chains-config/westendControllers.js +1 -0
- package/build/src/chains-config/westendControllers.js.map +1 -1
- package/build/src/controllers/accounts/AccountsAssetsController.d.ts +1 -1
- package/build/src/controllers/accounts/AccountsAssetsController.js +3 -3
- package/build/src/controllers/accounts/AccountsAssetsController.js.map +1 -1
- package/build/src/controllers/accounts/AccountsBalanceInfoController.js +1 -1
- package/build/src/controllers/accounts/AccountsPoolAssetsController.d.ts +52 -0
- package/build/src/controllers/accounts/AccountsPoolAssetsController.js +97 -0
- package/build/src/controllers/accounts/AccountsPoolAssetsController.js.map +1 -0
- package/build/src/controllers/accounts/index.d.ts +1 -0
- package/build/src/controllers/accounts/index.js +4 -2
- package/build/src/controllers/accounts/index.js.map +1 -1
- package/build/src/controllers/blocks/BlocksController.js +1 -1
- package/build/src/controllers/blocks/BlocksRawExtrinsicsController.d.ts +14 -0
- package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js +42 -0
- package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js.map +1 -0
- package/build/src/controllers/blocks/index.d.ts +1 -0
- package/build/src/controllers/blocks/index.js +3 -1
- package/build/src/controllers/blocks/index.js.map +1 -1
- package/build/src/controllers/index.d.ts +8 -3
- package/build/src/controllers/index.js +6 -1
- package/build/src/controllers/index.js.map +1 -1
- package/build/src/controllers/pallets/PalletsAssetConversionController.d.ts +9 -0
- package/build/src/controllers/pallets/PalletsAssetConversionController.js +44 -0
- package/build/src/controllers/pallets/PalletsAssetConversionController.js.map +1 -0
- package/build/src/controllers/pallets/PalletsForeignAssetsController.d.ts +23 -0
- package/build/src/controllers/pallets/PalletsForeignAssetsController.js +52 -0
- package/build/src/controllers/pallets/PalletsForeignAssetsController.js.map +1 -0
- package/build/src/controllers/pallets/PalletsPoolAssetsController.d.ts +49 -0
- package/build/src/controllers/pallets/PalletsPoolAssetsController.js +83 -0
- package/build/src/controllers/pallets/PalletsPoolAssetsController.js.map +1 -0
- package/build/src/controllers/pallets/index.d.ts +3 -0
- package/build/src/controllers/pallets/index.js +8 -2
- package/build/src/controllers/pallets/index.js.map +1 -1
- package/build/src/services/AbstractPalletsService.d.ts +3 -3
- package/build/src/services/AbstractPalletsService.js +2 -1
- package/build/src/services/AbstractPalletsService.js.map +1 -1
- package/build/src/services/accounts/AccountsPoolAssetsService.d.ts +47 -0
- package/build/src/services/accounts/AccountsPoolAssetsService.js +185 -0
- package/build/src/services/accounts/AccountsPoolAssetsService.js.map +1 -0
- package/build/src/services/accounts/AccountsPoolAssetsService.spec.d.ts +1 -0
- package/build/src/services/accounts/AccountsPoolAssetsService.spec.js +108 -0
- package/build/src/services/accounts/AccountsPoolAssetsService.spec.js.map +1 -0
- package/build/src/services/accounts/index.d.ts +1 -0
- package/build/src/services/accounts/index.js +2 -1
- package/build/src/services/accounts/index.js.map +1 -1
- package/build/src/services/blocks/BlocksService.d.ts +7 -1
- package/build/src/services/blocks/BlocksService.js +22 -0
- package/build/src/services/blocks/BlocksService.js.map +1 -1
- package/build/src/services/blocks/BlocksService.spec.js +6 -0
- package/build/src/services/blocks/BlocksService.spec.js.map +1 -1
- package/build/src/services/pallets/PalletsAssetConversionService.d.ts +10 -0
- package/build/src/services/pallets/PalletsAssetConversionService.js +64 -0
- package/build/src/services/pallets/PalletsAssetConversionService.js.map +1 -0
- package/build/src/services/pallets/PalletsAssetConversionService.spec.d.ts +1 -0
- package/build/src/services/pallets/PalletsAssetConversionService.spec.js +443 -0
- package/build/src/services/pallets/PalletsAssetConversionService.spec.js.map +1 -0
- package/build/src/services/pallets/PalletsAssetsService.js +1 -1
- package/build/src/services/pallets/PalletsAssetsService.spec.js +6 -6
- package/build/src/services/pallets/PalletsAssetsService.spec.js.map +1 -1
- package/build/src/services/pallets/PalletsDispatchablesService.js +2 -2
- package/build/src/services/pallets/PalletsDispatchablesService.spec.js +1 -1
- package/build/src/services/pallets/PalletsErrorsService.js +1 -1
- package/build/src/services/pallets/PalletsForeignAssetsService.d.ts +13 -0
- package/build/src/services/pallets/PalletsForeignAssetsService.js +76 -0
- package/build/src/services/pallets/PalletsForeignAssetsService.js.map +1 -0
- package/build/src/services/pallets/PalletsForeignAssetsService.spec.d.ts +1 -0
- package/build/src/services/pallets/PalletsForeignAssetsService.spec.js +99 -0
- package/build/src/services/pallets/PalletsForeignAssetsService.spec.js.map +1 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.d.ts +14 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.js +49 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.js.map +1 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.spec.d.ts +1 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.spec.js +69 -0
- package/build/src/services/pallets/PalletsPoolAssetsService.spec.js.map +1 -0
- package/build/src/services/pallets/PalletsStakingValidatorsService.js +0 -15
- package/build/src/services/pallets/PalletsStakingValidatorsService.js.map +1 -1
- package/build/src/services/pallets/index.d.ts +3 -0
- package/build/src/services/pallets/index.js +4 -1
- package/build/src/services/pallets/index.js.map +1 -1
- package/build/src/services/runtime/RuntimeMetadataService.js +1 -1
- package/build/src/services/runtime/RuntimeMetadataService.spec.js +1 -1
- package/build/src/services/runtime/index.js +1 -1
- package/build/src/types/polkadot-js/Codec.js +1 -1
- package/build/src/types/responses/AccountPoolAssets.d.ts +43 -0
- package/build/src/types/responses/AccountPoolAssets.js +18 -0
- package/build/src/types/responses/AccountPoolAssets.js.map +1 -0
- package/build/src/types/responses/Block.d.ts +1 -1
- package/build/src/types/responses/BlockRaw.d.ts +16 -0
- package/build/src/types/responses/BlockRaw.js +3 -0
- package/build/src/types/responses/BlockRaw.js.map +1 -0
- package/build/src/types/responses/ForeignAssets.d.ts +11 -0
- package/build/src/types/responses/ForeignAssets.js +18 -0
- package/build/src/types/responses/ForeignAssets.js.map +1 -0
- package/build/src/types/responses/PalletAssetConversion.d.ts +20 -0
- package/build/src/types/responses/PalletAssetConversion.js +18 -0
- package/build/src/types/responses/PalletAssetConversion.js.map +1 -0
- package/build/src/types/responses/PoolAssets.d.ts +9 -0
- package/build/src/types/responses/PoolAssets.js +18 -0
- package/build/src/types/responses/PoolAssets.js.map +1 -0
- package/build/src/types/responses/index.d.ts +5 -0
- package/build/src/types/responses/index.js +6 -1
- package/build/src/types/responses/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2023 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 services_1 = require("../../services");
|
|
22
|
+
const AbstractController_1 = __importDefault(require("../AbstractController"));
|
|
23
|
+
/**
|
|
24
|
+
* GET asset information for a single pool asset.
|
|
25
|
+
*
|
|
26
|
+
* Paths:
|
|
27
|
+
* - `assetId`: The identifier of the pool asset.
|
|
28
|
+
*
|
|
29
|
+
* Query:
|
|
30
|
+
* - (Optional)`at`: Block at which to retrieve runtime version information at. Block
|
|
31
|
+
* identifier, as the block height or block hash. Defaults to most recent block.
|
|
32
|
+
*
|
|
33
|
+
* `/pallets/pool-assets/:assetId/asset-info`
|
|
34
|
+
* Returns:
|
|
35
|
+
* - `at`: Block number and hash at which the call was made.
|
|
36
|
+
* - `poolAssetInfo`: All details concering a pool asset.
|
|
37
|
+
* - `owner`: Owner of the assets privileges.
|
|
38
|
+
* - `issuer`: The `AccountId` able to mint tokens.
|
|
39
|
+
* - `admin`: The `AccountId` can that thaw tokens, force transfers and burn token from
|
|
40
|
+
* any account.
|
|
41
|
+
* - `freezer`: The `AccountId` that can freeze tokens.
|
|
42
|
+
* - `supply`: The total supply across accounts.
|
|
43
|
+
* - `deposit`: The balance deposited for this. This pays for the data stored.
|
|
44
|
+
* - `minBalance`: The ED for virtual accounts.
|
|
45
|
+
* - `isSufficient`: If `true`, then any account with this asset is given a provider reference. Otherwise, it
|
|
46
|
+
* requires a consumer reference.
|
|
47
|
+
* - `accounts`: The total number of accounts.
|
|
48
|
+
* - `sufficients`: The total number of accounts for which is placed a self-sufficient reference.
|
|
49
|
+
* - `approvals`: The total number of approvals.
|
|
50
|
+
* - `status`: The status of the asset.
|
|
51
|
+
* - `poolAssetMetadata`: All metadata concerning a pool asset.
|
|
52
|
+
* - `deposit`: The balance deposited for this metadata. This pays for the data
|
|
53
|
+
* stored in this struct.
|
|
54
|
+
* - `name`: The user friendly name of this pool asset.
|
|
55
|
+
* - `symbol`: The ticker symbol for this pool asset.
|
|
56
|
+
* - `decimals`: The number of decimals this pool asset uses to represent one unit.
|
|
57
|
+
* - `isFrozen`: Whether the pool asset metadata may be changed by a non Force origin.
|
|
58
|
+
*
|
|
59
|
+
* Substrate References:
|
|
60
|
+
* - PoolAssets Pallet: instance of Assets Pallet https://crates.parity.io/pallet_assets/index.html
|
|
61
|
+
* - `AssetMetadata`: https://crates.parity.io/pallet_assets/struct.AssetMetadata.html
|
|
62
|
+
* - `AssetDetails`: https://crates.parity.io/pallet_assets/struct.AssetDetails.html
|
|
63
|
+
*/
|
|
64
|
+
class PalletsPoolAssetsController extends AbstractController_1.default {
|
|
65
|
+
constructor(api) {
|
|
66
|
+
super(api, '/pallets/pool-assets/:assetId', new services_1.PalletsPoolAssetsService(api));
|
|
67
|
+
this.getPoolAssetById = async ({ params: { assetId }, query: { at } }, res) => {
|
|
68
|
+
const hash = await this.getHashFromAt(at);
|
|
69
|
+
/**
|
|
70
|
+
* Verify our param `assetId` is an integer represented as a string, and return
|
|
71
|
+
* it as an integer
|
|
72
|
+
*/
|
|
73
|
+
const index = this.parseNumberOrThrow(assetId, '`assetId` path param is not a number');
|
|
74
|
+
PalletsPoolAssetsController.sanitizedSend(res, await this.service.fetchPoolAssetById(hash, index));
|
|
75
|
+
};
|
|
76
|
+
this.initRoutes();
|
|
77
|
+
}
|
|
78
|
+
initRoutes() {
|
|
79
|
+
this.safeMountAsyncGetHandlers([['/asset-info', this.getPoolAssetById]]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = PalletsPoolAssetsController;
|
|
83
|
+
//# sourceMappingURL=PalletsPoolAssetsController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PalletsPoolAssetsController.js","sourceRoot":"","sources":["../../../../src/controllers/pallets/PalletsPoolAssetsController.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,6CAA0D;AAC1D,+EAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAqB,2BAA4B,SAAQ,4BAA4C;IACpG,YAAY,GAAe;QAC1B,KAAK,CACJ,GAAG,EACH,+BAA+B,EAC/B,IAAI,mCAAwB,CAAC,GAAG,CAAC,CACjC,CAAC;QAQK,qBAAgB,GAAmB,KAAK,EAC/C,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EACtC,GAAG,EACa,EAAE;YAClB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAC1C;;;eAGG;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CACpC,OAAO,EACP,sCAAsC,CACtC,CAAC;YACF,2BAA2B,CAAC,aAAa,CACxC,GAAG,EACH,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAClD,CAAC;QACH,CAAC,CAAC;QAxBD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;IAES,UAAU;QACnB,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;CAoBD;AAhCD,8CAgCC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
export { default as PalletsAssetConversion } from './PalletsAssetConversionController';
|
|
1
2
|
export { default as PalletsAssets } from './PalletsAssetsController';
|
|
2
3
|
export { default as PalletsConsts } from './PalletsConstsController';
|
|
3
4
|
export { default as PalletsDispatchables } from './PalletsDispatchablesController';
|
|
4
5
|
export { default as PalletsErrors } from './PalletsErrorsController';
|
|
5
6
|
export { default as PalletsEvents } from './PalletsEventsController';
|
|
7
|
+
export { default as PalletsForeignAssets } from './PalletsForeignAssetsController';
|
|
6
8
|
export { default as PalletsNominationPools } from './PalletsNominationPoolsController';
|
|
9
|
+
export { default as PalletsPoolAssets } from './PalletsPoolAssetsController';
|
|
7
10
|
export { default as PalletsStakingProgress } from './PalletsStakingProgressController';
|
|
8
11
|
export { default as PalletsStakingValidators } from './PalletsStakingValidatorsController';
|
|
9
12
|
export { default as PalletsStorage } from './PalletsStorageController';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -18,7 +18,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PalletsStorage = exports.PalletsStakingValidators = exports.PalletsStakingProgress = exports.PalletsNominationPools = exports.PalletsEvents = exports.PalletsErrors = exports.PalletsDispatchables = exports.PalletsConsts = exports.PalletsAssets = void 0;
|
|
21
|
+
exports.PalletsStorage = exports.PalletsStakingValidators = exports.PalletsStakingProgress = exports.PalletsPoolAssets = exports.PalletsNominationPools = exports.PalletsForeignAssets = exports.PalletsEvents = exports.PalletsErrors = exports.PalletsDispatchables = exports.PalletsConsts = exports.PalletsAssets = exports.PalletsAssetConversion = void 0;
|
|
22
|
+
var PalletsAssetConversionController_1 = require("./PalletsAssetConversionController");
|
|
23
|
+
Object.defineProperty(exports, "PalletsAssetConversion", { enumerable: true, get: function () { return __importDefault(PalletsAssetConversionController_1).default; } });
|
|
22
24
|
var PalletsAssetsController_1 = require("./PalletsAssetsController");
|
|
23
25
|
Object.defineProperty(exports, "PalletsAssets", { enumerable: true, get: function () { return __importDefault(PalletsAssetsController_1).default; } });
|
|
24
26
|
var PalletsConstsController_1 = require("./PalletsConstsController");
|
|
@@ -29,8 +31,12 @@ var PalletsErrorsController_1 = require("./PalletsErrorsController");
|
|
|
29
31
|
Object.defineProperty(exports, "PalletsErrors", { enumerable: true, get: function () { return __importDefault(PalletsErrorsController_1).default; } });
|
|
30
32
|
var PalletsEventsController_1 = require("./PalletsEventsController");
|
|
31
33
|
Object.defineProperty(exports, "PalletsEvents", { enumerable: true, get: function () { return __importDefault(PalletsEventsController_1).default; } });
|
|
34
|
+
var PalletsForeignAssetsController_1 = require("./PalletsForeignAssetsController");
|
|
35
|
+
Object.defineProperty(exports, "PalletsForeignAssets", { enumerable: true, get: function () { return __importDefault(PalletsForeignAssetsController_1).default; } });
|
|
32
36
|
var PalletsNominationPoolsController_1 = require("./PalletsNominationPoolsController");
|
|
33
37
|
Object.defineProperty(exports, "PalletsNominationPools", { enumerable: true, get: function () { return __importDefault(PalletsNominationPoolsController_1).default; } });
|
|
38
|
+
var PalletsPoolAssetsController_1 = require("./PalletsPoolAssetsController");
|
|
39
|
+
Object.defineProperty(exports, "PalletsPoolAssets", { enumerable: true, get: function () { return __importDefault(PalletsPoolAssetsController_1).default; } });
|
|
34
40
|
var PalletsStakingProgressController_1 = require("./PalletsStakingProgressController");
|
|
35
41
|
Object.defineProperty(exports, "PalletsStakingProgress", { enumerable: true, get: function () { return __importDefault(PalletsStakingProgressController_1).default; } });
|
|
36
42
|
var PalletsStakingValidatorsController_1 = require("./PalletsStakingValidatorsController");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/pallets/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,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,mFAAmF;AAA1E,uJAAA,OAAO,OAAwB;AACxC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,uFAAuF;AAA9E,2JAAA,OAAO,OAA0B;AAC1C,uFAAuF;AAA9E,2JAAA,OAAO,OAA0B;AAC1C,2FAA2F;AAAlF,+JAAA,OAAO,OAA4B;AAC5C,uEAAuE;AAA9D,2IAAA,OAAO,OAAkB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/pallets/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,uFAAuF;AAA9E,2JAAA,OAAO,OAA0B;AAC1C,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,mFAAmF;AAA1E,uJAAA,OAAO,OAAwB;AACxC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,qEAAqE;AAA5D,yIAAA,OAAO,OAAiB;AACjC,mFAAmF;AAA1E,uJAAA,OAAO,OAAwB;AACxC,uFAAuF;AAA9E,2JAAA,OAAO,OAA0B;AAC1C,6EAA6E;AAApE,iJAAA,OAAO,OAAqB;AACrC,uFAAuF;AAA9E,2JAAA,OAAO,OAA0B;AAC1C,2FAA2F;AAAlF,+JAAA,OAAO,OAA4B;AAC5C,uEAAuE;AAA9D,2IAAA,OAAO,OAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiDecoration } from '@polkadot/api/types';
|
|
2
|
-
import { ErrorMetadataLatest, EventMetadataLatest, FunctionMetadataLatest, MetadataV14, PalletConstantMetadataLatest, PalletMetadataV14, StorageEntryMetadataV14 } from '@polkadot/types/interfaces';
|
|
2
|
+
import { ErrorMetadataLatest, EventMetadataLatest, FunctionMetadataLatest, MetadataV14, MetadataV15, PalletConstantMetadataLatest, PalletMetadataV14, PalletMetadataV15, StorageEntryMetadataV14 } from '@polkadot/types/interfaces';
|
|
3
3
|
import { AbstractService } from './AbstractService';
|
|
4
4
|
type IPalletFieldMeta = ErrorMetadataLatest | EventMetadataLatest | FunctionMetadataLatest | PalletConstantMetadataLatest | StorageEntryMetadataV14;
|
|
5
5
|
type IMetadataFieldType = 'calls' | 'constants' | 'events' | 'storage' | 'errors';
|
|
@@ -11,7 +11,7 @@ export declare abstract class AbstractPalletsService extends AbstractService {
|
|
|
11
11
|
*
|
|
12
12
|
* @param palletId identifier for a FRAME pallet as a pallet name or index.
|
|
13
13
|
*/
|
|
14
|
-
protected findPalletMeta(adjustedMetadata: MetadataV14, palletId: string, metadataFieldType: IMetadataFieldType): [PalletMetadataV14, number];
|
|
14
|
+
protected findPalletMeta(adjustedMetadata: MetadataV14 | MetadataV15, palletId: string, metadataFieldType: IMetadataFieldType): [PalletMetadataV14 | PalletMetadataV15, number];
|
|
15
15
|
private validPalletId;
|
|
16
16
|
/**
|
|
17
17
|
* Identify if a pallet Identifier should be an index or a string. If it should
|
|
@@ -29,7 +29,7 @@ export declare abstract class AbstractPalletsService extends AbstractService {
|
|
|
29
29
|
* @param metadataFieldType name of the metadata field to be queried
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
|
-
protected findPalletFieldItemMeta(historicApi: ApiDecoration<'promise'>, palletMeta: PalletMetadataV14, palletItemId: string, metadataFieldType: IMetadataFieldType): IPalletFieldMeta;
|
|
32
|
+
protected findPalletFieldItemMeta(historicApi: ApiDecoration<'promise'>, palletMeta: PalletMetadataV14 | PalletMetadataV15, palletItemId: string, metadataFieldType: IMetadataFieldType): IPalletFieldMeta;
|
|
33
33
|
private getDispatchablesItemMeta;
|
|
34
34
|
private getConstItemMeta;
|
|
35
35
|
private getErrorItemMeta;
|
|
@@ -142,7 +142,8 @@ class AbstractPalletsService extends AbstractService_1.AbstractService {
|
|
|
142
142
|
getDispatchablesItemMeta(palletMeta, dispatchableItemMetaIdx, dispatchableItemId) {
|
|
143
143
|
const palletName = (0, util_1.stringCamelCase)(palletMeta.name);
|
|
144
144
|
const dispatchables = this.api.tx[palletName];
|
|
145
|
-
if (palletMeta.calls
|
|
145
|
+
if (palletMeta.calls
|
|
146
|
+
.isEmpty) {
|
|
146
147
|
throw new http_errors_2.InternalServerError(`No dispatchable items found in ${palletMeta.name.toString()}'s metadata`);
|
|
147
148
|
}
|
|
148
149
|
for (const [, val] of Object.entries(dispatchables)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractPalletsService.js","sourceRoot":"","sources":["../../../src/services/AbstractPalletsService.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;;;
|
|
1
|
+
{"version":3,"file":"AbstractPalletsService.js","sourceRoot":"","sources":["../../../src/services/AbstractPalletsService.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;;;AAoBxE,yCAAiD;AACjD,6CAAyC;AACzC,6CAAkD;AAElD,uDAAoD;AAuBpD,MAAsB,sBAAuB,SAAQ,iCAAe;IAC3D,qBAAqB,CAC5B,IAA2C,EAC3C,iBAAqC;QAErC,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAEO,WAAW,CAAuB,GAAM,EAAE,GAAM;QACvD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACO,cAAc,CACvB,gBAA2C,EAC3C,QAAgB,EAChB,iBAAqC;QAErC,MAAM,OAAO,GACZ,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC7B,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAChD,OAAO,CAAC,CAAC,CAAC,EACV,iBAAiB,CACjB,CAAC;QAEF,MAAM,QAAQ,GAA8C,OAAO,CAAC,MAAM,CACzE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAE,GAAG,CAAC,iBAAiB,CAA2B,CAAC,OAAO,CACnE,CAAC;QAEF,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAC9D,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEvC,IAAI,UAA6D,CAAC;QAClE,IAAI,SAA6B,CAAC;QAElC,IAAI,kBAAkB,EAAE;YACvB,SAAS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CAAC,MAAM,CAAC,CACrB,gBAAgB,CACkB;SACnC,CAAC;IACH,CAAC;IAEO,kBAAkB,CACzB,UAAiD,EACjD,kBAA0B,EAC1B,aAAqB;QAErB,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE;YAC9B,MAAM,IAAI,iCAAmB,CAC5B,6BAA6B,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CACpE,CAAC;SACF;QACD,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;QAC5D,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAC/C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,aAAa,CAAC,WAAW,EAAE,CACjE,CAAC;QAEF,OAAO,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpE,CAAC;CACD;AAxUD,wDAwUC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiDecoration } from '@polkadot/api/types';
|
|
2
|
+
import { AssetId, BlockHash } from '@polkadot/types/interfaces';
|
|
3
|
+
import { IAccountPoolAssetApproval, IAccountPoolAssetsBalances, IPoolAssetBalance } from '../../types/responses';
|
|
4
|
+
import { AbstractService } from '../AbstractService';
|
|
5
|
+
export declare class AccountsPoolAssetsService extends AbstractService {
|
|
6
|
+
/**
|
|
7
|
+
* Fetch all the `PoolAssetBalance`s alongside their `AssetId`'s for a given array of queried `AssetId`'s.
|
|
8
|
+
* If none are queried the function will get all `AssetId`'s associated with the
|
|
9
|
+
* given `AccountId`, and send back all the `PoolAssetsBalance`s.
|
|
10
|
+
*
|
|
11
|
+
* @param hash `BlockHash` to make call at
|
|
12
|
+
* @param address `AccountId` associated with the balances
|
|
13
|
+
* @param assets An array of `assetId`'s to be queried. If the length is zero
|
|
14
|
+
* all assetId's associated to the account will be queried
|
|
15
|
+
*/
|
|
16
|
+
fetchPoolAssetBalances(hash: BlockHash, address: string, assets: number[]): Promise<IAccountPoolAssetsBalances>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch all `AccountApproval`'s with a given `AssetId` and a `AssetApprovalKey`
|
|
19
|
+
* which consists of a `delegate` and an `owner`
|
|
20
|
+
*
|
|
21
|
+
* @param hash `BlockHash` to make call at
|
|
22
|
+
* @param address `AccountId` or owner associated with the approvals
|
|
23
|
+
* @param assetId `AssetId` associated with the `AssetApproval`
|
|
24
|
+
* @param delegate `delegate`
|
|
25
|
+
*/
|
|
26
|
+
fetchPoolAssetApprovals(hash: BlockHash, address: string, assetId: number, delegate: string): Promise<IAccountPoolAssetApproval>;
|
|
27
|
+
/**
|
|
28
|
+
* Takes in an array of `AssetId`s, and an `AccountId` and returns
|
|
29
|
+
* all balances tied to those `AssetId`s.
|
|
30
|
+
*
|
|
31
|
+
* @param api ApiPromise
|
|
32
|
+
* @param assets An Array of `AssetId`s or numbers representing `assetId`s
|
|
33
|
+
* @param address An `AccountId` associated with the queried path
|
|
34
|
+
*/
|
|
35
|
+
queryPoolAssets(historicApi: ApiDecoration<'promise'>, assets: AssetId[] | number[], address: string): Promise<IPoolAssetBalance[]>;
|
|
36
|
+
/**
|
|
37
|
+
* @param keys Extract `assetId`s from an array of storage keys
|
|
38
|
+
*/
|
|
39
|
+
private extractPoolAssetIds;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if the historicApi has the pool assets pallet. If not
|
|
42
|
+
* it will throw a BadRequest error.
|
|
43
|
+
*
|
|
44
|
+
* @param historicApi Decorated historic api
|
|
45
|
+
*/
|
|
46
|
+
private checkPoolAssetsError;
|
|
47
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2017-2023 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.AccountsPoolAssetsService = void 0;
|
|
19
|
+
const http_errors_1 = require("http-errors");
|
|
20
|
+
const AbstractService_1 = require("../AbstractService");
|
|
21
|
+
class AccountsPoolAssetsService extends AbstractService_1.AbstractService {
|
|
22
|
+
/**
|
|
23
|
+
* Fetch all the `PoolAssetBalance`s alongside their `AssetId`'s for a given array of queried `AssetId`'s.
|
|
24
|
+
* If none are queried the function will get all `AssetId`'s associated with the
|
|
25
|
+
* given `AccountId`, and send back all the `PoolAssetsBalance`s.
|
|
26
|
+
*
|
|
27
|
+
* @param hash `BlockHash` to make call at
|
|
28
|
+
* @param address `AccountId` associated with the balances
|
|
29
|
+
* @param assets An array of `assetId`'s to be queried. If the length is zero
|
|
30
|
+
* all assetId's associated to the account will be queried
|
|
31
|
+
*/
|
|
32
|
+
async fetchPoolAssetBalances(hash, address, assets) {
|
|
33
|
+
const { api } = this;
|
|
34
|
+
const historicApi = await api.at(hash);
|
|
35
|
+
// Check if this runtime has the PoolAssets pallet
|
|
36
|
+
this.checkPoolAssetsError(historicApi);
|
|
37
|
+
const { number } = await api.rpc.chain.getHeader(hash);
|
|
38
|
+
let response;
|
|
39
|
+
if (assets.length === 0) {
|
|
40
|
+
/**
|
|
41
|
+
* This will query all pool assets and return them in an array
|
|
42
|
+
*/
|
|
43
|
+
const keys = await historicApi.query.poolAssets.asset.keys();
|
|
44
|
+
const assetIds = this.extractPoolAssetIds(keys);
|
|
45
|
+
response = await this.queryPoolAssets(historicApi, assetIds, address);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
/**
|
|
49
|
+
* This will query all pool assets by the requested AssetIds
|
|
50
|
+
*/
|
|
51
|
+
response = await this.queryPoolAssets(historicApi, assets, address);
|
|
52
|
+
}
|
|
53
|
+
const at = {
|
|
54
|
+
hash,
|
|
55
|
+
height: number.unwrap().toString(10),
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
at,
|
|
59
|
+
poolAssets: response,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Fetch all `AccountApproval`'s with a given `AssetId` and a `AssetApprovalKey`
|
|
64
|
+
* which consists of a `delegate` and an `owner`
|
|
65
|
+
*
|
|
66
|
+
* @param hash `BlockHash` to make call at
|
|
67
|
+
* @param address `AccountId` or owner associated with the approvals
|
|
68
|
+
* @param assetId `AssetId` associated with the `AssetApproval`
|
|
69
|
+
* @param delegate `delegate`
|
|
70
|
+
*/
|
|
71
|
+
async fetchPoolAssetApprovals(hash, address, assetId, delegate) {
|
|
72
|
+
const { api } = this;
|
|
73
|
+
const historicApi = await api.at(hash);
|
|
74
|
+
// Check if this runtime has the assets pallet
|
|
75
|
+
this.checkPoolAssetsError(historicApi);
|
|
76
|
+
const [{ number }, assetApproval] = await Promise.all([
|
|
77
|
+
api.rpc.chain.getHeader(hash),
|
|
78
|
+
historicApi.query.poolAssets.approvals(assetId, address, delegate),
|
|
79
|
+
]).catch((err) => {
|
|
80
|
+
throw this.createHttpErrorForAddr(address, err);
|
|
81
|
+
});
|
|
82
|
+
let amount = null, deposit = null;
|
|
83
|
+
if (assetApproval.isSome) {
|
|
84
|
+
({ amount, deposit } = assetApproval.unwrap());
|
|
85
|
+
}
|
|
86
|
+
const at = {
|
|
87
|
+
hash,
|
|
88
|
+
height: number.unwrap().toString(10),
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
at,
|
|
92
|
+
amount,
|
|
93
|
+
deposit,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Takes in an array of `AssetId`s, and an `AccountId` and returns
|
|
98
|
+
* all balances tied to those `AssetId`s.
|
|
99
|
+
*
|
|
100
|
+
* @param api ApiPromise
|
|
101
|
+
* @param assets An Array of `AssetId`s or numbers representing `assetId`s
|
|
102
|
+
* @param address An `AccountId` associated with the queried path
|
|
103
|
+
*/
|
|
104
|
+
async queryPoolAssets(historicApi, assets, address) {
|
|
105
|
+
return Promise.all(assets.map(async (assetId) => {
|
|
106
|
+
const assetBalance = await historicApi.query.poolAssets.account(assetId, address);
|
|
107
|
+
/**
|
|
108
|
+
* The following checks for three different cases:
|
|
109
|
+
*/
|
|
110
|
+
// 1. Via runtime v9160 the updated storage introduces a `reason` field,
|
|
111
|
+
// and polkadot-js wraps the newly returned `PalletAssetsAssetAccount` in an `Option`.
|
|
112
|
+
if (assetBalance.isSome) {
|
|
113
|
+
const balanceProps = assetBalance.unwrap();
|
|
114
|
+
let isFrozen;
|
|
115
|
+
if ('isFrozen' in balanceProps) {
|
|
116
|
+
isFrozen = balanceProps.isFrozen;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
isFrozen = 'isFrozen does not exist for this runtime';
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
assetId,
|
|
123
|
+
balance: balanceProps.balance,
|
|
124
|
+
isFrozen: isFrozen,
|
|
125
|
+
isSufficient: balanceProps.reason.isSufficient,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
// 2. `query.assets.account()` return `PalletAssetsAssetBalance` which exludes `reasons` but has
|
|
129
|
+
// `sufficient` as a key.
|
|
130
|
+
if (assetBalance.sufficient) {
|
|
131
|
+
const balanceProps = assetBalance;
|
|
132
|
+
return {
|
|
133
|
+
assetId,
|
|
134
|
+
balance: balanceProps.balance,
|
|
135
|
+
isFrozen: balanceProps.isFrozen,
|
|
136
|
+
isSufficient: balanceProps.sufficient,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// 3. The older legacy type of `PalletAssetsAssetBalance` has a key of `isSufficient` instead
|
|
140
|
+
// of `sufficient`.
|
|
141
|
+
if (assetBalance['isSufficient']) {
|
|
142
|
+
const balanceProps = assetBalance;
|
|
143
|
+
return {
|
|
144
|
+
assetId,
|
|
145
|
+
balance: balanceProps.balance,
|
|
146
|
+
isFrozen: balanceProps.isFrozen,
|
|
147
|
+
isSufficient: balanceProps.isSufficient,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* This return value wont ever be reached as polkadot-js defaults the
|
|
152
|
+
* `balance` value to `0`, `isFrozen` to false, and `isSufficient` to false.
|
|
153
|
+
* This ensures that the typescript compiler is happy, but we also follow along
|
|
154
|
+
* with polkadot-js/substrate convention.
|
|
155
|
+
*/
|
|
156
|
+
return {
|
|
157
|
+
assetId,
|
|
158
|
+
balance: historicApi.registry.createType('u128', 0),
|
|
159
|
+
isFrozen: historicApi.registry.createType('bool', false),
|
|
160
|
+
isSufficient: historicApi.registry.createType('bool', false),
|
|
161
|
+
};
|
|
162
|
+
})).catch((err) => {
|
|
163
|
+
throw this.createHttpErrorForAddr(address, err);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @param keys Extract `assetId`s from an array of storage keys
|
|
168
|
+
*/
|
|
169
|
+
extractPoolAssetIds(keys) {
|
|
170
|
+
return keys.map(({ args: [assetId] }) => assetId);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Checks if the historicApi has the pool assets pallet. If not
|
|
174
|
+
* it will throw a BadRequest error.
|
|
175
|
+
*
|
|
176
|
+
* @param historicApi Decorated historic api
|
|
177
|
+
*/
|
|
178
|
+
checkPoolAssetsError(historicApi) {
|
|
179
|
+
if (!historicApi.query.poolAssets) {
|
|
180
|
+
throw new http_errors_1.BadRequest(`The runtime does not include the pool assets pallet at this block.`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.AccountsPoolAssetsService = AccountsPoolAssetsService;
|
|
185
|
+
//# sourceMappingURL=AccountsPoolAssetsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountsPoolAssetsService.js","sourceRoot":"","sources":["../../../../src/services/accounts/AccountsPoolAssetsService.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;;;AAMxE,6CAAyC;AAOzC,wDAAqD;AA6BrD,MAAa,yBAA0B,SAAQ,iCAAe;IAC7D;;;;;;;;;OASG;IACH,KAAK,CAAC,sBAAsB,CAC3B,IAAe,EACf,OAAe,EACf,MAAgB;QAEhB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACrB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAEvC,kDAAkD;QAClD,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAEvC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,QAAQ,CAAC;QACb,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB;;eAEG;YACH,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YAEhD,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idecar.
|
|
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 mock_1 = require("../test-helpers/mock");
|
|
20
|
+
const mockAssetHubWestendData_1 = require("../test-helpers/mock/assets/mockAssetHubWestendData");
|
|
21
|
+
const AccountsPoolAssetsService_1 = require("./AccountsPoolAssetsService");
|
|
22
|
+
const historicApi = {
|
|
23
|
+
query: {
|
|
24
|
+
poolAssets: {
|
|
25
|
+
account: mockAssetHubWestendData_1.poolAssetsAccount,
|
|
26
|
+
approvals: mockAssetHubWestendData_1.poolAssetApprovals,
|
|
27
|
+
asset: (0, mockAssetHubWestendData_1.poolAssetsInfoKeysInjected)(),
|
|
28
|
+
metadata: mockAssetHubWestendData_1.poolAssetsMetadata,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const mockApi = {
|
|
33
|
+
...mock_1.mockAssetHubWestendApi,
|
|
34
|
+
at: (_hash) => historicApi,
|
|
35
|
+
};
|
|
36
|
+
const accountsPoolAssetsService = new AccountsPoolAssetsService_1.AccountsPoolAssetsService(mockApi);
|
|
37
|
+
describe('AccountsPoolAssetsService', () => {
|
|
38
|
+
const at = {
|
|
39
|
+
hash: '0x270c4262eacfd16f05a63ef36eeabf165abbc3a4c53d0480f5460e6d5b2dc8b5',
|
|
40
|
+
height: '5236177',
|
|
41
|
+
};
|
|
42
|
+
describe('AccountsPoolAssetsService.fetchPoolAssetBalances', () => {
|
|
43
|
+
it('Should return the correct response with the pool assets param', async () => {
|
|
44
|
+
const expectedResponse = {
|
|
45
|
+
at,
|
|
46
|
+
poolAssets: [
|
|
47
|
+
{
|
|
48
|
+
assetId: '0',
|
|
49
|
+
balance: '147648230602234',
|
|
50
|
+
isFrozen: 'isFrozen does not exist for this runtime',
|
|
51
|
+
isSufficient: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
assetId: '21',
|
|
55
|
+
balance: '100',
|
|
56
|
+
isFrozen: 'isFrozen does not exist for this runtime',
|
|
57
|
+
isSufficient: false,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
const response = await accountsPoolAssetsService.fetchPoolAssetBalances(mock_1.blockHash5236177, '0xffff', // AccountId arg here does not affect the test results
|
|
62
|
+
[0, 21]);
|
|
63
|
+
expect((0, sanitizeNumbers_1.sanitizeNumbers)(response)).toStrictEqual(expectedResponse);
|
|
64
|
+
});
|
|
65
|
+
it('Should return the correct response without the assets param', async () => {
|
|
66
|
+
const expectedResponse = {
|
|
67
|
+
at,
|
|
68
|
+
poolAssets: [
|
|
69
|
+
{
|
|
70
|
+
assetId: '0',
|
|
71
|
+
balance: '147648230602234',
|
|
72
|
+
isFrozen: 'isFrozen does not exist for this runtime',
|
|
73
|
+
isSufficient: false,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
assetId: '21',
|
|
77
|
+
balance: '100',
|
|
78
|
+
isFrozen: 'isFrozen does not exist for this runtime',
|
|
79
|
+
isSufficient: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
assetId: '29',
|
|
83
|
+
balance: '200000',
|
|
84
|
+
isFrozen: true,
|
|
85
|
+
isSufficient: false,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
const response = await accountsPoolAssetsService.fetchPoolAssetBalances(mock_1.blockHash5236177, '0xffff', // AccountId arg here does not affect the test results
|
|
90
|
+
[]);
|
|
91
|
+
expect((0, sanitizeNumbers_1.sanitizeNumbers)(response)).toStrictEqual(expectedResponse);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('AccountsPoolAssetsService.fetchPoolAssetApprovals', () => {
|
|
95
|
+
it('Should return the correct response', async () => {
|
|
96
|
+
const expectedResponse = {
|
|
97
|
+
at,
|
|
98
|
+
amount: '147648230602234',
|
|
99
|
+
deposit: '2000000',
|
|
100
|
+
};
|
|
101
|
+
const response = await accountsPoolAssetsService.fetchPoolAssetApprovals(mock_1.blockHash5236177, '', // AccountId arg here does not affect the test results
|
|
102
|
+
21, '' // Delegate arg here does not affect the test results
|
|
103
|
+
);
|
|
104
|
+
expect((0, sanitizeNumbers_1.sanitizeNumbers)(response)).toStrictEqual(expectedResponse);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=AccountsPoolAssetsService.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountsPoolAssetsService.spec.js","sourceRoot":"","sources":["../../../../src/services/accounts/AccountsPoolAssetsService.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;;AAMxE,oEAAiE;AACjE,+CAAgF;AAChF,iGAK6D;AAC7D,2EAAwE;AAExE,MAAM,WAAW,GAAG;IACnB,KAAK,EAAE;QACN,UAAU,EAAE;YACX,OAAO,EAAE,2CAAiB;YAC1B,SAAS,EAAE,4CAA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,iBAAiB;wBAC1B,QAAQ,EAAE,0CAA0C;wBACpD,YAAY,EAAE,KAAK;qBACnB;oBACD;wBACC,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,KAAK;wBACd,QAAQ,EAAE,0CAA0C;wBACpD,YAAY,EAAE,KAAK;qBACnB;oBACD;wBACC,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,QAAQ;wBACjB,QAAQ,EAAE,IAAI;wBACd,YAAY,EAAE,KAAK;qBACnB;iBACD;aACD,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAAC,sBAAsB,CACtE,uBAAgB,EAChB,QAAQ,EAAE,sDAAsD;YAChE,EAAE,CACF,CAAC;YAEF,MAAM,CAAC,IAAA,iCAAe,EAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAClE,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;YACnD,MAAM,gBAAgB,GAAG;gBACxB,EAAE;gBACF,MAAM,EAAE,iBAAiB;gBACzB,OAAO,EAAE,SAAS;aAClB,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAAC,uBAAuB,CACvE,uBAAgB,EAChB,EAAE,EAAE,sDAAsD;YAC1D,EAAE,EACF,EAAE,CAAC,qDAAqD;aACxD,CAAC;YAEF,MAAM,CAAC,IAAA,iCAAe,EAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './AccountsAssetsService';
|
|
2
2
|
export * from './AccountsBalanceInfoService';
|
|
3
3
|
export * from './AccountsConvertService';
|
|
4
|
+
export * from './AccountsPoolAssetsService';
|
|
4
5
|
export * from './AccountsStakingInfoService';
|
|
5
6
|
export * from './AccountsStakingPayoutsService';
|
|
6
7
|
export * from './AccountsValidateService';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2017-
|
|
2
|
+
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
|
|
3
3
|
// This file is part of Substrate API Sidecar.
|
|
4
4
|
//
|
|
5
5
|
// Substrate API Sidecar is free software: you can redistribute it and/or modify
|
|
@@ -32,6 +32,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
32
32
|
__exportStar(require("./AccountsAssetsService"), exports);
|
|
33
33
|
__exportStar(require("./AccountsBalanceInfoService"), exports);
|
|
34
34
|
__exportStar(require("./AccountsConvertService"), exports);
|
|
35
|
+
__exportStar(require("./AccountsPoolAssetsService"), exports);
|
|
35
36
|
__exportStar(require("./AccountsStakingInfoService"), exports);
|
|
36
37
|
__exportStar(require("./AccountsStakingPayoutsService"), exports);
|
|
37
38
|
__exportStar(require("./AccountsValidateService"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/accounts/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,0DAAwC;AACxC,+DAA6C;AAC7C,2DAAyC;AACzC,+DAA6C;AAC7C,kEAAgD;AAChD,4DAA0C;AAC1C,+DAA6C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/accounts/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,0DAAwC;AACxC,+DAA6C;AAC7C,2DAAyC;AACzC,8DAA4C;AAC5C,+DAA6C;AAC7C,kEAAgD;AAChD,4DAA0C;AAC1C,+DAA6C"}
|
|
@@ -3,7 +3,7 @@ import { ApiDecoration } from '@polkadot/api/types';
|
|
|
3
3
|
import { BlockHash, Header } from '@polkadot/types/interfaces';
|
|
4
4
|
import LRU from 'lru-cache';
|
|
5
5
|
import { QueryFeeDetailsCache } from '../../chains-config/cache';
|
|
6
|
-
import { IBlock, IExtrinsicIndex } from '../../types/responses';
|
|
6
|
+
import { IBlock, IBlockRaw, IExtrinsicIndex } from '../../types/responses';
|
|
7
7
|
import { IOption } from '../../types/util';
|
|
8
8
|
import { AbstractService } from '../AbstractService';
|
|
9
9
|
/**
|
|
@@ -135,5 +135,11 @@ export declare class BlocksService extends AbstractService {
|
|
|
135
135
|
* @param checkFinalized If the passed in blockId is a hash
|
|
136
136
|
*/
|
|
137
137
|
private isFinalizedBlock;
|
|
138
|
+
/**
|
|
139
|
+
* Fetch a block with raw extrinics values.
|
|
140
|
+
*
|
|
141
|
+
* @param hash `BlockHash` of the block to fetch.
|
|
142
|
+
*/
|
|
143
|
+
fetchBlockRaw(hash: BlockHash): Promise<IBlockRaw>;
|
|
138
144
|
}
|
|
139
145
|
export {};
|