@substrate/api-sidecar 20.10.2 → 20.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/build/package.json +13 -13
  2. package/build/src/chains-config/assetHubKusamaControllers.js +1 -0
  3. package/build/src/chains-config/assetHubKusamaControllers.js.map +1 -1
  4. package/build/src/chains-config/assetHubNextWestendControllers.js +1 -0
  5. package/build/src/chains-config/assetHubNextWestendControllers.js.map +1 -1
  6. package/build/src/chains-config/assetHubPolkadotControllers.js +1 -0
  7. package/build/src/chains-config/assetHubPolkadotControllers.js.map +1 -1
  8. package/build/src/chains-config/assetHubWestendControllers.js +1 -0
  9. package/build/src/chains-config/assetHubWestendControllers.js.map +1 -1
  10. package/build/src/controllers/AbstractController.d.ts +1 -0
  11. package/build/src/controllers/AbstractController.js +1 -1
  12. package/build/src/controllers/AbstractController.js.map +1 -1
  13. package/build/src/controllers/accounts/AccountsAssetsController.js +4 -2
  14. package/build/src/controllers/accounts/AccountsAssetsController.js.map +1 -1
  15. package/build/src/controllers/accounts/AccountsBalanceInfoController.d.ts +1 -0
  16. package/build/src/controllers/accounts/AccountsBalanceInfoController.js +3 -1
  17. package/build/src/controllers/accounts/AccountsBalanceInfoController.js.map +1 -1
  18. package/build/src/controllers/accounts/AccountsForeignAssetsController.d.ts +50 -0
  19. package/build/src/controllers/accounts/AccountsForeignAssetsController.js +110 -0
  20. package/build/src/controllers/accounts/AccountsForeignAssetsController.js.map +1 -0
  21. package/build/src/controllers/accounts/AccountsPoolAssetsController.js +4 -2
  22. package/build/src/controllers/accounts/AccountsPoolAssetsController.js.map +1 -1
  23. package/build/src/controllers/accounts/AccountsProxyInfoController.js +2 -1
  24. package/build/src/controllers/accounts/AccountsProxyInfoController.js.map +1 -1
  25. package/build/src/controllers/accounts/AccountsStakingInfoController.js +2 -1
  26. package/build/src/controllers/accounts/AccountsStakingInfoController.js.map +1 -1
  27. package/build/src/controllers/accounts/AccountsStakingPayoutsController.js +2 -1
  28. package/build/src/controllers/accounts/AccountsStakingPayoutsController.js.map +1 -1
  29. package/build/src/controllers/accounts/AccountsVestingInfoController.js +2 -1
  30. package/build/src/controllers/accounts/AccountsVestingInfoController.js.map +1 -1
  31. package/build/src/controllers/accounts/index.d.ts +1 -0
  32. package/build/src/controllers/accounts/index.js +3 -1
  33. package/build/src/controllers/accounts/index.js.map +1 -1
  34. package/build/src/controllers/blocks/BlocksController.js +10 -4
  35. package/build/src/controllers/blocks/BlocksController.js.map +1 -1
  36. package/build/src/controllers/blocks/BlocksExtrinsicsController.js +2 -1
  37. package/build/src/controllers/blocks/BlocksExtrinsicsController.js.map +1 -1
  38. package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js +2 -1
  39. package/build/src/controllers/blocks/BlocksRawExtrinsicsController.js.map +1 -1
  40. package/build/src/controllers/controllerInjection.spec.js +10 -10
  41. package/build/src/controllers/controllerInjection.spec.js.map +1 -1
  42. package/build/src/controllers/index.d.ts +2 -1
  43. package/build/src/controllers/index.js +1 -0
  44. package/build/src/controllers/index.js.map +1 -1
  45. package/build/src/controllers/pallets/PalletsAssetConversionController.js +4 -2
  46. package/build/src/controllers/pallets/PalletsAssetConversionController.js.map +1 -1
  47. package/build/src/controllers/pallets/PalletsAssetsController.js +2 -1
  48. package/build/src/controllers/pallets/PalletsAssetsController.js.map +1 -1
  49. package/build/src/controllers/pallets/PalletsConstsController.js +4 -2
  50. package/build/src/controllers/pallets/PalletsConstsController.js.map +1 -1
  51. package/build/src/controllers/pallets/PalletsDispatchablesController.js +4 -2
  52. package/build/src/controllers/pallets/PalletsDispatchablesController.js.map +1 -1
  53. package/build/src/controllers/pallets/PalletsErrorsController.js +4 -2
  54. package/build/src/controllers/pallets/PalletsErrorsController.js.map +1 -1
  55. package/build/src/controllers/pallets/PalletsEventsController.js +4 -2
  56. package/build/src/controllers/pallets/PalletsEventsController.js.map +1 -1
  57. package/build/src/controllers/pallets/PalletsForeignAssetsController.js +2 -1
  58. package/build/src/controllers/pallets/PalletsForeignAssetsController.js.map +1 -1
  59. package/build/src/controllers/pallets/PalletsNominationPoolsController.js +4 -2
  60. package/build/src/controllers/pallets/PalletsNominationPoolsController.js.map +1 -1
  61. package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js +2 -1
  62. package/build/src/controllers/pallets/PalletsOnGoingReferendaController.js.map +1 -1
  63. package/build/src/controllers/pallets/PalletsPoolAssetsController.js +2 -1
  64. package/build/src/controllers/pallets/PalletsPoolAssetsController.js.map +1 -1
  65. package/build/src/controllers/pallets/PalletsStakingProgressController.js +2 -1
  66. package/build/src/controllers/pallets/PalletsStakingProgressController.js.map +1 -1
  67. package/build/src/controllers/pallets/PalletsStakingValidatorsController.js +2 -1
  68. package/build/src/controllers/pallets/PalletsStakingValidatorsController.js.map +1 -1
  69. package/build/src/controllers/pallets/PalletsStorageController.js +4 -2
  70. package/build/src/controllers/pallets/PalletsStorageController.js.map +1 -1
  71. package/build/src/controllers/rc/blocks/RcBlocksController.js +2 -0
  72. package/build/src/controllers/rc/blocks/RcBlocksController.js.map +1 -1
  73. package/build/src/services/accounts/AccountsForeignAssetsService.d.ts +45 -0
  74. package/build/src/services/accounts/AccountsForeignAssetsService.js +181 -0
  75. package/build/src/services/accounts/AccountsForeignAssetsService.js.map +1 -0
  76. package/build/src/services/accounts/index.d.ts +1 -0
  77. package/build/src/services/accounts/index.js +1 -0
  78. package/build/src/services/accounts/index.js.map +1 -1
  79. package/build/src/services/consts.js +8 -0
  80. package/build/src/services/consts.js.map +1 -1
  81. package/build/src/types/responses/AccountAssets.d.ts +35 -0
  82. package/build/src/types/responses/AccountBalanceInfo.d.ts +1 -0
  83. package/build/src/types/responses/AccountPoolAssets.d.ts +2 -0
  84. package/build/src/types/responses/AccountProxyInfo.d.ts +1 -0
  85. package/build/src/types/responses/AccountStakingInfo.d.ts +1 -0
  86. package/build/src/types/responses/AccountStakingPayouts.d.ts +1 -0
  87. package/build/src/types/responses/AccountVestingInfo.d.ts +1 -0
  88. package/build/src/types/responses/PalletStakingProgress.d.ts +1 -0
  89. package/package.json +13 -13
@@ -0,0 +1,181 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AccountsForeignAssetsService = void 0;
19
+ const http_errors_1 = require("http-errors");
20
+ const AbstractService_1 = require("../AbstractService");
21
+ class AccountsForeignAssetsService extends AbstractService_1.AbstractService {
22
+ /**
23
+ * Fetch all the `ForeignAssetBalance`s for a given account address.
24
+ * If specific foreign assets are queried via multilocations, only those will be returned.
25
+ * Otherwise, all foreign asset balances for the account will be returned.
26
+ *
27
+ * @param hash `BlockHash` to make call at
28
+ * @param address `AccountId` associated with the balances
29
+ * @param foreignAssets An array of multilocation objects to be queried as JSON strings. If the length is zero
30
+ * all foreign assets associated to the account will be queried
31
+ */
32
+ async fetchForeignAssetBalances(hash, address, foreignAssets) {
33
+ const { api } = this;
34
+ const [historicApi, { number }] = await Promise.all([api.at(hash), api.rpc.chain.getHeader(hash)]);
35
+ // Check if this runtime has the foreignAssets pallet
36
+ this.checkForeignAssetsError(historicApi);
37
+ let response;
38
+ if (foreignAssets.length === 0) {
39
+ /**
40
+ * This will query all foreign assets and then filter for the account's holdings
41
+ * We need to get all foreign assets first, then check which ones the account holds
42
+ */
43
+ const foreignAssetEntries = await historicApi.query.foreignAssets.asset.entries();
44
+ const multiLocations = this.extractMultiLocationsFromAssetEntries(foreignAssetEntries);
45
+ response = await this.queryForeignAssets(historicApi, multiLocations, address);
46
+ }
47
+ else {
48
+ /**
49
+ * This will query all foreign assets by the requested multilocations
50
+ */
51
+ const parsedMultiLocations = foreignAssets.map((ml) => {
52
+ try {
53
+ const parsed = JSON.parse(ml);
54
+ return historicApi.registry.createType('XcmVersionedLocation', parsed);
55
+ }
56
+ catch (err) {
57
+ throw new http_errors_1.BadRequest(`Invalid JSON format for multilocation: ${ml}`);
58
+ }
59
+ });
60
+ response = await this.queryForeignAssets(historicApi, parsedMultiLocations, address);
61
+ }
62
+ const at = {
63
+ hash,
64
+ height: number.unwrap().toString(10),
65
+ };
66
+ return {
67
+ at,
68
+ foreignAssets: response,
69
+ };
70
+ }
71
+ /**
72
+ * Takes in an array of multilocations and an `AccountId` and returns
73
+ * all balances tied to those foreign assets.
74
+ *
75
+ * Uses batch queries (.multi()) for better performance instead of individual queries.
76
+ *
77
+ * @param historicApi ApiPromise at a specific block
78
+ * @param multiLocations An Array of multilocation objects
79
+ * @param address An `AccountId` associated with the queried path
80
+ */
81
+ async queryForeignAssets(historicApi, multiLocations, address) {
82
+ // Prepare all queries for batch call
83
+ const queries = multiLocations.map((multiLocation) => [multiLocation, address]);
84
+ // Single batched RPC call instead of N individual calls
85
+ const assetBalances = await historicApi.query.foreignAssets.account
86
+ .multi(queries)
87
+ .catch((err) => {
88
+ throw this.createHttpErrorForAddr(address, err);
89
+ });
90
+ // Process all results
91
+ const results = multiLocations.map((multiLocation, index) => {
92
+ const assetBalance = assetBalances[index];
93
+ /**
94
+ * The following checks for three different cases:
95
+ */
96
+ // 1. Via runtime v9160 the updated storage introduces a `reason` field,
97
+ // and polkadot-js wraps the newly returned `PalletAssetsAssetAccount` in an `Option`.
98
+ if (assetBalance.isSome) {
99
+ const balanceProps = assetBalance.unwrap();
100
+ let isFrozen;
101
+ if ('isFrozen' in balanceProps) {
102
+ isFrozen = balanceProps.isFrozen;
103
+ }
104
+ else {
105
+ isFrozen = historicApi.registry.createType('bool', false);
106
+ }
107
+ return {
108
+ multiLocation,
109
+ balance: balanceProps.balance,
110
+ isFrozen: isFrozen,
111
+ isSufficient: balanceProps.reason.isSufficient,
112
+ };
113
+ }
114
+ // 2. `query.foreignAssets.account()` return `PalletAssetsAssetBalance` which excludes `reasons` but has
115
+ // `sufficient` as a key.
116
+ const balanceStruct = assetBalance;
117
+ if ('sufficient' in balanceStruct) {
118
+ const balanceProps = assetBalance;
119
+ return {
120
+ multiLocation,
121
+ balance: balanceProps.balance,
122
+ isFrozen: balanceProps.isFrozen,
123
+ isSufficient: balanceProps.sufficient,
124
+ };
125
+ }
126
+ // 3. The older legacy type of `PalletAssetsAssetBalance` has a key of `isSufficient` instead
127
+ // of `sufficient`.
128
+ if ('isSufficient' in balanceStruct) {
129
+ const balanceProps = assetBalance;
130
+ return {
131
+ multiLocation,
132
+ balance: balanceProps.balance,
133
+ isFrozen: balanceProps.isFrozen,
134
+ isSufficient: balanceProps.isSufficient,
135
+ };
136
+ }
137
+ /**
138
+ * This return value wont ever be reached as polkadot-js defaults the
139
+ * `balance` value to `0`, `isFrozen` to false, and `isSufficient` to false.
140
+ * This ensures that the typescript compiler is happy, but we also follow along
141
+ * with polkadot-js/substrate convention.
142
+ */
143
+ return {
144
+ multiLocation,
145
+ balance: historicApi.registry.createType('u128', 0),
146
+ isFrozen: historicApi.registry.createType('bool', false),
147
+ isSufficient: historicApi.registry.createType('bool', false),
148
+ };
149
+ });
150
+ // Filter out assets with zero balance
151
+ // We filter here because querying all foreign assets will return many zeros
152
+ // for assets the account doesn't hold
153
+ return results.filter((asset) => asset.balance.isZero() === false);
154
+ }
155
+ /**
156
+ * Extract multilocations from foreign asset entries
157
+ * The storage key for foreignAssets.asset is just the multilocation
158
+ *
159
+ * @param entries Foreign asset storage entries
160
+ */
161
+ extractMultiLocationsFromAssetEntries(entries) {
162
+ const multiLocations = [];
163
+ for (const [storageKey] of entries) {
164
+ multiLocations.push(storageKey.args[0]);
165
+ }
166
+ return multiLocations;
167
+ }
168
+ /**
169
+ * Checks if the historicApi has the foreignAssets pallet. If not
170
+ * it will throw a BadRequest error.
171
+ *
172
+ * @param historicApi Decorated historic api
173
+ */
174
+ checkForeignAssetsError(historicApi) {
175
+ if (!historicApi.query.foreignAssets) {
176
+ throw new http_errors_1.BadRequest(`The runtime does not include the foreignAssets pallet at this block.`);
177
+ }
178
+ }
179
+ }
180
+ exports.AccountsForeignAssetsService = AccountsForeignAssetsService;
181
+ //# sourceMappingURL=AccountsForeignAssetsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountsForeignAssetsService.js","sourceRoot":"","sources":["../../../../src/services/accounts/AccountsForeignAssetsService.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;;;AAQxE,6CAAyC;AAGzC,wDAAqD;AA6BrD,MAAa,4BAA6B,SAAQ,iCAAe;IAChE;;;;;;;;;OASG;IACH,KAAK,CAAC,yBAAyB,CAC9B,IAAe,EACf,OAAe,EACf,aAAuB;QAEvB,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACrB,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAEnG,qDAAqD;QACrD,IAAI,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,QAAQ,CAAC;QACb,IAAI,aAAa,CA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C,sEAAsE,CAAC,CAAC;QAC9F,CAAC;IACF,CAAC;CACD;AA9LD,oEA8LC"}
@@ -2,6 +2,7 @@ export * from './AccountsAssetsService';
2
2
  export * from './AccountsBalanceInfoService';
3
3
  export * from './AccountsCompareService';
4
4
  export * from './AccountsConvertService';
5
+ export * from './AccountsForeignAssetsService';
5
6
  export * from './AccountsPoolAssetsService';
6
7
  export * from './AccountsProxyInfoService';
7
8
  export * from './AccountsStakingInfoService';
@@ -33,6 +33,7 @@ __exportStar(require("./AccountsAssetsService"), exports);
33
33
  __exportStar(require("./AccountsBalanceInfoService"), exports);
34
34
  __exportStar(require("./AccountsCompareService"), exports);
35
35
  __exportStar(require("./AccountsConvertService"), exports);
36
+ __exportStar(require("./AccountsForeignAssetsService"), exports);
36
37
  __exportStar(require("./AccountsPoolAssetsService"), exports);
37
38
  __exportStar(require("./AccountsProxyInfoService"), exports);
38
39
  __exportStar(require("./AccountsStakingInfoService"), 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,2DAAyC;AACzC,8DAA4C;AAC5C,6DAA2C;AAC3C,+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,2DAAyC;AACzC,iEAA+C;AAC/C,8DAA4C;AAC5C,6DAA2C;AAC3C,+DAA6C;AAC7C,kEAAgD;AAChD,4DAA0C;AAC1C,+DAA6C"}
@@ -41,6 +41,14 @@ exports.MIGRATION_BOUNDARIES = {
41
41
  relayMigrationStartedAt: 30423691,
42
42
  relayMigrationEndedAt: 30425590,
43
43
  },
44
+ statemint: {
45
+ relayChainLastEra: 1981,
46
+ assetHubFirstEra: 1981,
47
+ assetHubMigrationStartedAt: 10254470,
48
+ assetHubMigrationEndedAt: 10259208,
49
+ relayMigrationStartedAt: 28490502,
50
+ relayMigrationEndedAt: 28495696,
51
+ },
44
52
  };
45
53
  exports.relayToSpecMapping = new Map([
46
54
  ['polkadot', 'statemint'],
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/services/consts.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;;;AAe3D,QAAA,oBAAoB,GAAyC;IACzE,QAAQ,EAAE;QACT,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,0BAA0B,EAAE,QAAQ;QACpC,wBAAwB,EAAE,QAAQ;QAClC,uBAAuB,EAAE,QAAQ;QACjC,qBAAqB,EAAE,QAAQ;KAC/B;IACD,iBAAiB,EAAE;QAClB,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,0BAA0B,E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;QACvB,gBAAgB,EAAE,IAAI;QACtB,0BAA0B,EAAE,QAAQ;QACpC,wBAAwB,EAAE,QAAQ;QAClC,uBAAuB,EAAE,QAAQ;QACjC,qBAAqB,EAAE,QAAQ;KAC/B;IACD,SAAS,EAAE;QACV,iBAAiB,EAAE,IAAI;QACvB,gBAAgB,EAAE,IAAI;QACtB,0BAA0B,EAAE,QAAQ;QACpC,wBAAwB,EAAE,QAAQ;QAClC,uBAAuB,EAAE,QAAQ;QACjC,qBAAqB,EAAE,QAAQ;KAC/B;CACD,CAAC;AAEW,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACzC,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,QAAQ,EAAE,WAAW,CAAC;IACvB,CAAC,SAAS,EAAE,UAAU,CAAC;IACvB,CAAC,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC,CAAC"}
@@ -30,6 +30,7 @@ export interface IAssetBalance {
30
30
  export interface IAccountAssetsBalances {
31
31
  at: IAt;
32
32
  assets: IAssetBalance[];
33
+ rcBlockHash?: string;
33
34
  rcBlockNumber?: string;
34
35
  ahTimestamp?: string;
35
36
  }
@@ -42,6 +43,40 @@ export interface IAccountAssetApproval {
42
43
  at: IAt;
43
44
  amount: u128 | null;
44
45
  deposit: TAssetDepositBalance | null;
46
+ rcBlockHash?: string;
47
+ rcBlockNumber?: string;
48
+ ahTimestamp?: string;
49
+ }
50
+ export interface IForeignAssetBalance {
51
+ /**
52
+ * The multilocation identifier for the foreign asset.
53
+ */
54
+ multiLocation: unknown;
55
+ /**
56
+ * The units in which substrate records balances.
57
+ */
58
+ balance: u128;
59
+ /**
60
+ * Whether this asset class is frozen except for permissioned/admin instructions.
61
+ * Returns false if the pallet doesn't support isFrozen.
62
+ */
63
+ isFrozen: bool;
64
+ /**
65
+ * Whether a non-zero balance of this asset is deposit of sufficient
66
+ * value to account for the state bloat associated with its balance storage. If set to
67
+ * `true`, then non-zero balances may be stored without a `consumer` reference (and thus
68
+ * an ED in the Balances pallet or whatever else is used to control user-account state
69
+ * growth).
70
+ */
71
+ isSufficient: bool | boolean;
72
+ }
73
+ /**
74
+ * Response from `/accounts/{accountId}/foreign-asset-balances?foreignAssets=<multilocations>`
75
+ */
76
+ export interface IAccountForeignAssetsBalances {
77
+ at: IAt;
78
+ foreignAssets: IForeignAssetBalance[];
79
+ rcBlockHash?: string;
45
80
  rcBlockNumber?: string;
46
81
  ahTimestamp?: string;
47
82
  }
@@ -20,6 +20,7 @@ export interface IAccountBalanceInfo {
20
20
  */
21
21
  transferable: Balance | string;
22
22
  locks: Vec<BalanceLock> | IBalanceLock[];
23
+ rcBlockHash?: string;
23
24
  rcBlockNumber?: string;
24
25
  ahTimestamp?: string;
25
26
  }
@@ -30,6 +30,7 @@ export interface IPoolAssetBalance {
30
30
  export interface IAccountPoolAssetsBalances {
31
31
  at: IAt;
32
32
  poolAssets: IPoolAssetBalance[];
33
+ rcBlockHash?: string;
33
34
  rcBlockNumber?: string;
34
35
  ahTimestamp?: string;
35
36
  }
@@ -42,6 +43,7 @@ export interface IAccountPoolAssetApproval {
42
43
  at: IAt;
43
44
  amount: u128 | null;
44
45
  deposit: TAssetDepositBalance | null;
46
+ rcBlockHash?: string;
45
47
  rcBlockNumber?: string;
46
48
  ahTimestamp?: string;
47
49
  }
@@ -5,6 +5,7 @@ export interface AccountsProxyInfo {
5
5
  at: IAt;
6
6
  delegatedAccounts: Vec<PalletProxyProxyDefinition>;
7
7
  depositHeld: u128;
8
+ rcBlockHash?: string;
8
9
  rcBlockNumber?: string;
9
10
  ahTimestamp?: string;
10
11
  }
@@ -23,6 +23,7 @@ export interface IAccountStakingInfo {
23
23
  numSlashingSpans: number;
24
24
  nominations: PalletStakingNominations | null;
25
25
  staking: IStakingLedger | null;
26
+ rcBlockHash?: string;
26
27
  rcBlockNumber?: string;
27
28
  ahTimestamp?: string;
28
29
  }
@@ -4,6 +4,7 @@ export interface IAccountStakingPayouts {
4
4
  erasPayouts: (IEraPayouts | {
5
5
  message: string;
6
6
  })[];
7
+ rcBlockHash?: string;
7
8
  rcBlockNumber?: string;
8
9
  ahTimestamp?: string;
9
10
  }
@@ -4,6 +4,7 @@ import { IAt } from '.';
4
4
  export interface IAccountVestingInfo {
5
5
  at: IAt;
6
6
  vesting: Option<VestingInfo> | {};
7
+ rcBlockHash?: string;
7
8
  rcBlockNumber?: string;
8
9
  ahTimestamp?: string;
9
10
  }
@@ -13,6 +13,7 @@ export interface IPalletStakingProgress {
13
13
  toggleEstimate: string | null;
14
14
  } | string;
15
15
  validatorSet?: string[] | null;
16
+ rcBlockHash?: string;
16
17
  rcBlockNumber?: string;
17
18
  ahTimestamp?: string;
18
19
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "20.10.2",
2
+ "version": "20.12.0",
3
3
  "name": "@substrate/api-sidecar",
4
4
  "description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
5
5
  "homepage": "https://github.com/paritytech/substrate-api-sidecar#readme",
@@ -51,30 +51,30 @@
51
51
  "test:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js"
52
52
  },
53
53
  "dependencies": {
54
- "@polkadot/api": "^16.4.7",
55
- "@polkadot/api-augment": "^16.4.7",
56
- "@polkadot/api-contract": "^16.4.7",
57
- "@polkadot/types": "^16.4.7",
58
- "@polkadot/types-codec": "^16.4.7",
59
- "@polkadot/util": "^13.5.6",
60
- "@polkadot/util-crypto": "^13.5.6",
54
+ "@polkadot/api": "^16.5.2",
55
+ "@polkadot/api-augment": "^16.5.2",
56
+ "@polkadot/api-contract": "^16.5.2",
57
+ "@polkadot/types": "^16.5.2",
58
+ "@polkadot/types-codec": "^16.5.2",
59
+ "@polkadot/util": "^13.5.8",
60
+ "@polkadot/util-crypto": "^13.5.8",
61
61
  "@substrate/calc": "0.3.1",
62
62
  "argparse": "^2.0.1",
63
63
  "confmgr": "^1.1.0",
64
64
  "express": "^5.1.0",
65
65
  "express-winston": "^4.2.0",
66
- "http-errors": "^2.0.0",
67
- "lru-cache": "^11.1.0",
66
+ "http-errors": "^2.0.1",
67
+ "lru-cache": "^11.2.2",
68
68
  "prom-client": "^15.1.3",
69
69
  "rxjs": "^7.8.2",
70
- "winston": "^3.17.0",
70
+ "winston": "^3.18.3",
71
71
  "winston-loki": "^6.1.3"
72
72
  },
73
73
  "devDependencies": {
74
- "@acala-network/chopsticks-testing": "^1.1.0",
74
+ "@acala-network/chopsticks-testing": "^1.2.4",
75
75
  "@substrate/dev": "^0.9.0",
76
76
  "@types/argparse": "2.0.17",
77
- "@types/express": "^5.0.3",
77
+ "@types/express": "^5.0.5",
78
78
  "@types/express-serve-static-core": "^5.0.6",
79
79
  "@types/http-errors": "2.0.5",
80
80
  "@types/lru-cache": "^7.10.10",