@substrate/api-sidecar
Version:
REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
502 lines • 27.3 kB
JavaScript
;
// Copyright 2017-2025 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.payee22939322 = exports.ledgerAt22939322 = exports.bondedAt22939322 = exports.payee21157800 = exports.ledgerAt21157800 = exports.bondedAt21157800 = exports.ledgerAt = exports.bondedAt = void 0;
const http_errors_1 = require("http-errors");
const apiRegistry_1 = require("../../apiRegistry");
const sanitizeNumbers_1 = require("../../sanitize/sanitizeNumbers");
const registries_1 = require("../../test-helpers/registries");
const mock_1 = require("../test-helpers/mock");
const stakingInfo_1 = require("../test-helpers/mock/accounts/stakingInfo");
const validators789629Hex_1 = require("../test-helpers/mock/data/validators789629Hex");
const validators21157800Hex_1 = require("../test-helpers/mock/data/validators21157800Hex");
const validators22939322Hex_1 = require("../test-helpers/mock/data/validators22939322Hex");
const stakingInfo789629_json_1 = __importDefault(require("../test-helpers/responses/accounts/stakingInfo789629.json"));
const stakingInfo21157800_json_1 = __importDefault(require("../test-helpers/responses/accounts/stakingInfo21157800.json"));
const stakingInfo21157800nominator_json_1 = __importDefault(require("../test-helpers/responses/accounts/stakingInfo21157800nominator.json"));
const stakingInfo22939322_json_1 = __importDefault(require("../test-helpers/responses/accounts/stakingInfo22939322.json"));
const stakingInfo22939322ClaimedFalse_json_1 = __importDefault(require("../test-helpers/responses/accounts/stakingInfo22939322ClaimedFalse.json"));
const AccountsStakingInfoService_1 = require("./AccountsStakingInfoService");
const bondedAt = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<AccountId>', mock_1.testAddressController));
exports.bondedAt = bondedAt;
const ledgerAt = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<StakingLedger>', '0x2c2a55b5e0d28cc772b47bb9b25981cbb69eca73f7c3388fb6464e7d24be470e0700e87648170700e8764817008c000000000100000002000000030000000400000005000000060000000700000008000000090000001700000018000000190000001a0000001b0000001c0000001d0000001e0000001f000000200000002100000022000000230000002400000025000000260000002700000028000000290000002a0000002b0000002c0000002d0000002e0000002f000000'));
exports.ledgerAt = ledgerAt;
const payeeAt = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('RewardDestination', 'Controller'));
const slashingSpansAt = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('SlashingSpans'));
const validatorsAt789629 = () => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Vec<AccountId32>', validators789629Hex_1.validators789629Hex));
const historicApi = {
query: {
staking: {
bonded: exports.bondedAt,
ledger: exports.ledgerAt,
payee: payeeAt,
slashingSpans: slashingSpansAt,
currentEra: mock_1.currentEraAt,
},
session: {
validators: validatorsAt789629,
},
},
};
const mockApi = {
...mock_1.defaultMockApi,
at: (_hash) => historicApi,
};
const mockRCNextAHMApiPromise = {
...mock_1.defaultMockApi,
consts: {
...mock_1.defaultMockApi.consts,
staking: null,
},
query: {
...mock_1.defaultMockApi.query,
staking: null,
},
at: (_hash) => ({
...historicApi,
consts: {
...historicApi.query,
staking: null,
},
query: {
...historicApi.query,
staking: null,
},
}),
};
const mockAHNextAHMApiPromise = {
...mock_1.defaultMockApi,
consts: {
...mock_1.defaultMockApi.consts,
session: null,
},
query: {
...mock_1.defaultMockApi.query,
session: null,
},
at: (_hash) => ({
...historicApi,
consts: {
...historicApi.query,
session: null,
},
query: {
...historicApi.query,
session: null,
},
}),
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('mock');
const bondedAt21157800 = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistryV1002000.createType('Option<AccountId>', mock_1.testAddressControllerPolkadot));
exports.bondedAt21157800 = bondedAt21157800;
const ledgerAt21157800 = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistryV1002000.createType('Option<StakingLedger>', '0x005fa73637062be3fbfb972174a5bc85a2f6cc0350cb84aa9d657422796bfdf10b119b01640c070b119b01640c070088690500006a0500006b0500006c0500006d0500006e0500006f050000700500007105000072050000730500007405000075050000760500007705000078050000790500007a0500007b0500007c0500007d0500007e0500007f050000800500008105000082050000830500008405000085050000860500008705000088050000890500008a050000'));
exports.ledgerAt21157800 = ledgerAt21157800;
const payee21157800 = (_hash, _address) => Promise.resolve().then(() => registries_1.polkadotRegistryV1002000.createType('Option<AccountId>', mock_1.testAddressPayeePolkadot));
exports.payee21157800 = payee21157800;
const validatorsAt21157800 = () => Promise.resolve().then(() => registries_1.polkadotRegistryV1002000.createType('Vec<AccountId32>', validators21157800Hex_1.validators21157800Hex));
const nominations21157800 = (_hash) => Promise.resolve().then(() => registries_1.polkadotRegistryV1002000.createType('Option<PalletStakingNominations>', '0x04005fa73637062be3fbfb972174a5bc85a2f6cc0350cb84aa9d657422796bfdf16705000000'));
const historicApi21157800 = {
query: {
staking: {
bonded: exports.bondedAt21157800,
ledger: exports.ledgerAt21157800,
payee: stakingInfo_1.polkadotPayeeMockedCall,
slashingSpans: stakingInfo_1.polkadotSlashingSpansMockedCall,
claimedRewards: stakingInfo_1.polkadotClaimedRewardsMockedCall,
activeEra: mock_1.activeEraAt21157800,
currentEra: mock_1.currentEraAt21157800,
erasStakersOverview: stakingInfo_1.polkadotErasStakersOverviewMockedCall,
erasStakers: stakingInfo_1.polkadotErasStakersMockedCall,
nominators: null,
},
session: {
validators: validatorsAt21157800,
},
},
};
const mockApiPolkadot21157800val = {
...mock_1.defaultMockApi21157800,
at: (_hash) => historicApi21157800,
};
const mockValPolkadotRCNextAHMApiPromise = {
...mock_1.defaultMockApi21157800,
consts: {
...mock_1.defaultMockApi21157800.consts,
staking: null,
},
query: {
...mock_1.defaultMockApi21157800.query,
staking: null,
},
at: (_hash) => ({
...historicApi21157800,
consts: {
...historicApi21157800.query,
staking: null,
},
query: {
...historicApi21157800.query,
staking: null,
},
}),
};
const mockValPolkadotAHNextAHMApiPromise = {
...mock_1.defaultMockApi21157800,
consts: {
...mock_1.defaultMockApi21157800.consts,
session: null,
},
query: {
...mock_1.defaultMockApi21157800.query,
session: null,
},
at: (_hash) => ({
...historicApi21157800,
consts: {
...historicApi21157800.query,
session: null,
},
query: {
...historicApi21157800.query,
session: null,
},
}),
};
const accountStakingInfoService21157800val = new AccountsStakingInfoService_1.AccountsStakingInfoService('mock');
const mockApiPolkadot21157800nom = {
...mock_1.defaultMockApi21157800,
at: (_hash) => ({
...historicApi21157800,
query: {
...historicApi21157800.query,
staking: {
...historicApi21157800.query.staking,
nominators: nominations21157800,
erasStakersPaged: stakingInfo_1.polkadotErasStakersPagedMockedCall,
},
},
}),
};
const mockRCNextAHMApiPromise21157800nom = {
...mock_1.defaultMockApi21157800,
consts: {
...mock_1.defaultMockApi21157800.consts,
staking: null,
},
query: {
...mock_1.defaultMockApi21157800.query,
staking: null,
},
at: (_hash) => ({
...historicApi21157800,
consts: {
...historicApi21157800.query,
staking: null,
},
query: {
...historicApi21157800.query,
staking: null,
},
}),
};
const mockAHNextAHMApiPromise21157800nom = {
...mock_1.defaultMockApi21157800,
consts: {
...mock_1.defaultMockApi21157800.consts,
session: null,
},
query: {
...mock_1.defaultMockApi21157800.query,
session: null,
},
at: (_hash) => ({
...historicApi21157800,
consts: {
...historicApi21157800.query,
session: null,
},
query: {
...historicApi21157800.query,
session: null,
},
}),
};
const accountStakingInfoService21157800nom = new AccountsStakingInfoService_1.AccountsStakingInfoService('mock');
const bondedAt22939322 = (_hash, _address) => Promise.resolve().then(() => registries_1.kusamaRegistryV1002000.createType('Option<AccountId>', mock_1.testAddressControllerKusama));
exports.bondedAt22939322 = bondedAt22939322;
const ledgerAt22939322 = (_hash, _address) => Promise.resolve().then(() => registries_1.kusamaRegistryV1002000.createType('Option<StakingLedger>', '0x6c6ed8531e6c0b882af0a42f2f23ef0a102b5d49cb5f5a24ede72d53ffce83170b7962e569db040b7962e569db0400a84719000048190000491900004a1900004b1900004c1900004d1900004e1900004f190000501900005119000052190000531900005419000055190000561900005719000058190000591900005a1900005b1900005c1900005d1900005e1900005f190000601900006119000062190000631900006419000065190000661900006719000068190000691900006a1900006b1900006c1900006d1900006e1900006f19000070190000'));
exports.ledgerAt22939322 = ledgerAt22939322;
const payee22939322 = (_hash, _address) => Promise.resolve().then(() => registries_1.kusamaRegistryV1002000.createType('Option<AccountId>', mock_1.testAddressPayeeKusama));
exports.payee22939322 = payee22939322;
const validatorsAt22939322 = () => Promise.resolve().then(() => registries_1.kusamaRegistryV1002000.createType('Vec<AccountId32>', validators22939322Hex_1.validators22939322Hex));
const historicApi22939322 = {
query: {
staking: {
bonded: exports.bondedAt22939322,
ledger: exports.ledgerAt22939322,
payee: stakingInfo_1.stakingPayeeMockedCall,
slashingSpans: stakingInfo_1.stakingslashingSpansMockedCall,
claimedRewards: stakingInfo_1.stakingClaimedRewardsMockedCall,
activeEra: mock_1.activeEraAt22939322,
currentEra: mock_1.currentEraAt22939322,
erasStakersOverview: stakingInfo_1.stakingerasStakersOverviewMockedCall,
erasStakers: stakingInfo_1.kusamaErasStakersMockedCall,
},
session: {
validators: validatorsAt22939322,
},
},
};
const mockApiKusama22939322 = {
...mock_1.defaultMockApi22939322,
at: (_hash) => historicApi22939322,
};
const RCNextAHMApiPromise22939322 = {
...mock_1.defaultMockApi22939322,
consts: {
...mock_1.defaultMockApi22939322.consts,
staking: null,
},
query: {
...mock_1.defaultMockApi22939322.query,
staking: null,
},
at: (_hash) => ({
...historicApi22939322,
consts: {
...historicApi22939322.query,
staking: null,
},
query: {
...historicApi22939322.query,
staking: null,
},
}),
};
const AHNextAHMApiPromise22939322 = {
...mock_1.defaultMockApi22939322,
consts: {
...mock_1.defaultMockApi22939322.consts,
session: null,
},
query: {
...mock_1.defaultMockApi22939322.query,
session: null,
},
at: (_hash) => ({
...historicApi22939322,
consts: {
...historicApi22939322.query,
session: null,
},
query: {
...historicApi22939322.query,
session: null,
},
}),
};
const accountStakingInfoService22939322 = new AccountsStakingInfoService_1.AccountsStakingInfoService('mock');
describe('AccountsStakingInfoService', () => {
describe('fetchAccountStakingInfo before AHM', () => {
it('works with a valid stash address (block 789629)', async () => {
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApi);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, mock_1.testAddress))).toStrictEqual(stakingInfo789629_json_1.default);
});
it('throws a 400 when the given address is not a stash', async () => {
historicApi.query.staking.bonded = () => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<AccountId>', null));
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApi);
await expect(accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, 'NotStash')).rejects.toStrictEqual(new http_errors_1.BadRequest('The address NotStash is not a stash address.'));
historicApi.query.staking.bonded = exports.bondedAt;
});
it('throws a 404 when the staking ledger cannot be found', async () => {
historicApi.query.staking.ledger = () => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<StakingLedger>', null));
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApi);
await expect(accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, mock_1.testAddress)).rejects.toStrictEqual(new http_errors_1.InternalServerError(`Staking ledger could not be found for controller address "${mock_1.testAddressController.toString()}"`));
historicApi.query.staking.ledger = exports.ledgerAt;
});
it('works when `includeClaimedRewards` is set to `false` hence claimedRewards field is not returned in the response', async () => {
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiKusama22939322);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService22939322.fetchAccountStakingInfo(mock_1.blockHash22939322, false, mock_1.testAddressKusama))).toStrictEqual(stakingInfo22939322ClaimedFalse_json_1.default);
});
it('works with a valid stash account (block 22939322) and returns eras claimed that include era 6514 (when the migration occurred in Kusama)', async () => {
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiKusama22939322);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService22939322.fetchAccountStakingInfo(mock_1.blockHash22939322, true, mock_1.testAddressKusama))).toStrictEqual(stakingInfo22939322_json_1.default);
});
it('works with a validator account (block 21157800) & returns an array of claimed (including case erasStakersOverview=null & erasStakers>0, era 1419), partially claimed & unclaimed eras (Polkadot)', async () => {
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiPolkadot21157800val);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService21157800val.fetchAccountStakingInfo(mock_1.blockHash21157800, true, mock_1.testAddressPolkadot))).toStrictEqual(stakingInfo21157800_json_1.default);
});
it('works with a nominator account (block 21157800) & returns claimed & unclaimed eras (Polkadot)', async () => {
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiPolkadot21157800nom);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService21157800nom.fetchAccountStakingInfo(mock_1.blockHash21157800, true, mock_1.testNominatorAddressPolkadot))).toStrictEqual(stakingInfo21157800nominator_json_1.default);
});
});
describe('fetchAccountStakingInfo after AHM', () => {
it('works with a valid stash address (block 789629)', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return mockAHNextAHMApiPromise;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: mockRCNextAHMApiPromise,
},
];
});
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, mock_1.testAddress))).toStrictEqual(stakingInfo789629_json_1.default);
});
it('throws a 400 when the given address is not a stash', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return mockAHNextAHMApiPromise;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: mockRCNextAHMApiPromise,
},
];
});
historicApi.query.staking.bonded = () => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<AccountId>', null));
await expect(accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, 'NotStash')).rejects.toStrictEqual(new http_errors_1.BadRequest('The address NotStash is not a stash address.'));
historicApi.query.staking.bonded = exports.bondedAt;
});
it('throws a 404 when the staking ledger cannot be found', async () => {
historicApi.query.staking.ledger = () => Promise.resolve().then(() => registries_1.polkadotRegistry.createType('Option<StakingLedger>', null));
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return mockAHNextAHMApiPromise;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: mockRCNextAHMApiPromise,
},
];
});
await expect(accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash789629, true, mock_1.testAddress)).rejects.toStrictEqual(new http_errors_1.InternalServerError(`Staking ledger could not be found for controller address "${mock_1.testAddressController.toString()}"`));
historicApi.query.staking.ledger = exports.ledgerAt;
});
it('works when `includeClaimedRewards` is set to `false` hence claimedRewards field is not returned in the response', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return AHNextAHMApiPromise22939322;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: RCNextAHMApiPromise22939322,
},
];
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiKusama22939322);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash22939322, false, mock_1.testAddressKusama))).toStrictEqual(stakingInfo22939322ClaimedFalse_json_1.default);
});
it('works with a valid stash account (block 22939322) and returns eras claimed that include era 6514 (when the migration occurred in Kusama)', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return AHNextAHMApiPromise22939322;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: RCNextAHMApiPromise22939322,
},
];
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiKusama22939322);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService.fetchAccountStakingInfo(mock_1.blockHash22939322, true, mock_1.testAddressKusama))).toStrictEqual(stakingInfo22939322_json_1.default);
});
it('works with a validator account (block 21157800) & returns an array of claimed (including case erasStakersOverview=null & erasStakers>0, era 1419), partially claimed & unclaimed eras (Polkadot)', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService21157800val = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return mockValPolkadotAHNextAHMApiPromise;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: mockValPolkadotRCNextAHMApiPromise,
},
];
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiPolkadot21157800val);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService21157800val.fetchAccountStakingInfo(mock_1.blockHash21157800, true, mock_1.testAddressPolkadot))).toStrictEqual(stakingInfo21157800_json_1.default);
});
it('works with a nominator account (block 21157800) & returns claimed & unclaimed eras (Polkadot)', async () => {
apiRegistry_1.ApiPromiseRegistry.assetHubInfo = {
isAssetHub: true,
isAssetHubMigrated: true,
};
const accountStakingInfoService21157800nom = new AccountsStakingInfoService_1.AccountsStakingInfoService('statemine');
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => {
return mockAHNextAHMApiPromise21157800nom;
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getAllAvailableSpecNames').mockReturnValue(['kusama', 'statemine']);
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApiByType').mockImplementation(() => {
return [
{
specName: 'kusama',
api: mockRCNextAHMApiPromise21157800nom,
},
];
});
jest.spyOn(apiRegistry_1.ApiPromiseRegistry, 'getApi').mockImplementation(() => mockApiPolkadot21157800nom);
expect((0, sanitizeNumbers_1.sanitizeNumbers)(await accountStakingInfoService21157800nom.fetchAccountStakingInfo(mock_1.blockHash21157800, true, mock_1.testNominatorAddressPolkadot))).toStrictEqual(stakingInfo21157800nominator_json_1.default);
});
});
});
//# sourceMappingURL=AccountsStakingInfoService.spec.js.map