Skip to content

Commit 1376c35

Browse files
authored
feat: Add remaining Accounts endpoints with /rc prefix (#1704)
1 parent 00f8311 commit 1376c35

15 files changed

Lines changed: 218 additions & 15 deletions

docs/src/openapi-v1.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,50 @@ paths:
774774
application/json:
775775
schema:
776776
$ref: '#/components/schemas/Error'
777+
/rc/accounts/{address}/proxy-info:
778+
get:
779+
tags:
780+
- rc
781+
summary: Get proxy information for an account on the relay chain.
782+
description: Returns information about an account's proxy configuration on the relay chain. This endpoint is specifically for Asset Hub and queries the relay chain (Polkadot/Kusama) for proxy information.
783+
operationId: getRcAccountProxyInfo
784+
parameters:
785+
- name: address
786+
in: path
787+
description: SS58 address of the account.
788+
required: true
789+
schema:
790+
type: string
791+
format: SS58
792+
- name: at
793+
in: query
794+
description: Block at which to query proxy info for the
795+
specified account.
796+
required: false
797+
schema:
798+
type: string
799+
description: Block height (as a non-negative integer) or hash
800+
(as a hex string).
801+
format: unsignedInteger or $hex
802+
responses:
803+
"200":
804+
description: successful operation
805+
content:
806+
application/json:
807+
schema:
808+
$ref: '#/components/schemas/AccountProxyInfo'
809+
"400":
810+
description: Invalid Address
811+
content:
812+
application/json:
813+
schema:
814+
$ref: '#/components/schemas/Error'
815+
"404":
816+
description: account not found
817+
content:
818+
application/json:
819+
schema:
820+
$ref: '#/components/schemas/Error'
777821
/blocks:
778822
get:
779823
tags:

src/chains-config/assetHubKusamaControllers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const assetHubKusamaControllers: ControllerConfig = {
3939
'PalletsEvents',
4040
'PalletsForeignAssets',
4141
'RcAccountsBalanceInfo',
42+
'RcAccountsProxyInfo',
4243
'RuntimeCode',
4344
'RuntimeMetadata',
4445
'RuntimeSpec',

src/chains-config/assetHubNextWestendControllers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const assetHubNextWestendControllers: ControllerConfig = {
5050
'PalletsStorage',
5151
'PalletsPoolAssets',
5252
'RcAccountsBalanceInfo',
53+
'RcAccountsProxyInfo',
5354
'RuntimeCode',
5455
'RuntimeMetadata',
5556
'RuntimeSpec',

src/chains-config/assetHubPolkadotControllers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const assetHubPolkadotControllers: ControllerConfig = {
4141
'PalletsErrors',
4242
'PalletsForeignAssets',
4343
'RcAccountsBalanceInfo',
44+
'RcAccountsProxyInfo',
4445
'RuntimeCode',
4546
'RuntimeMetadata',
4647
'RuntimeSpec',

src/chains-config/assetHubWestendControllers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const assetHubWestendControllers: ControllerConfig = {
5050
'PalletsStorage',
5151
'PalletsPoolAssets',
5252
'RcAccountsBalanceInfo',
53+
'RcAccountsProxyInfo',
5354
'RuntimeCode',
5455
'RuntimeMetadata',
5556
'RuntimeSpec',

src/controllers/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
PalletsStorage,
4747
} from './pallets';
4848
import { Paras } from './paras';
49-
import { RcAccountsBalanceInfo } from './rc';
49+
import { RcAccountsBalanceInfo, RcAccountsProxyInfo } from './rc/accounts';
5050
import { RuntimeCode, RuntimeMetadata, RuntimeSpec } from './runtime';
5151
import { TransactionDryRun, TransactionFeeEstimate, TransactionMaterial, TransactionSubmit } from './transaction';
5252

@@ -86,6 +86,7 @@ export const controllers = {
8686
NodeTransactionPool,
8787
NodeVersion,
8888
RcAccountsBalanceInfo,
89+
RcAccountsProxyInfo,
8990
RuntimeCode,
9091
RuntimeMetadata,
9192
RuntimeSpec,

src/controllers/rc/RcAccountsBalanceInfoController.ts renamed to src/controllers/rc/accounts/RcAccountsBalanceInfoController.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import { RequestHandler } from 'express';
1818
import { IAddressParam } from 'src/types/requests';
1919

20-
import { ApiPromiseRegistry } from '../../apiRegistry';
21-
import { validateAddress, validateBoolean } from '../../middleware';
22-
import { RcAccountsBalanceInfoService } from '../../services';
23-
import AbstractController from '../AbstractController';
20+
import { ApiPromiseRegistry } from '../../../apiRegistry';
21+
import { validateAddress, validateBoolean } from '../../../middleware';
22+
import { RcAccountsBalanceInfoService } from '../../../services';
23+
import AbstractController from '../../AbstractController';
2424

2525
export default class AccountsBalanceController extends AbstractController<RcAccountsBalanceInfoService> {
2626
static controllerName = 'RcAccountsBalanceInfo';
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2017-2025 Parity Technologies (UK) Ltd.
2+
// This file is part of Substrate API Sidecar.
3+
//
4+
// Substrate API Sidecar is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import { RequestHandler } from 'express';
18+
import { IAddressParam } from 'src/types/requests';
19+
20+
import { ApiPromiseRegistry } from '../../../apiRegistry';
21+
import { validateAddress } from '../../../middleware';
22+
import { RcAccountsProxyInfoService } from '../../../services';
23+
import AbstractController from '../../AbstractController';
24+
25+
export default class RcAccountsProxyInfoController extends AbstractController<RcAccountsProxyInfoService> {
26+
static controllerName = 'RcAccountsProxyInfo';
27+
static requiredPallets = [['Proxy']];
28+
constructor(api: string) {
29+
super(api, '/rc/accounts/:address/proxy-info', new RcAccountsProxyInfoService(api));
30+
this.initRoutes();
31+
}
32+
33+
protected initRoutes(): void {
34+
this.router.use(this.path, validateAddress);
35+
36+
this.safeMountAsyncGetHandlers([['', this.getAccountProxyInfo]]);
37+
}
38+
39+
/**
40+
* Get the latest account proxy info of `address` from the relay chain.
41+
*
42+
* @param req Express Request
43+
* @param res Express Response
44+
*/
45+
private getAccountProxyInfo: RequestHandler<IAddressParam> = async (
46+
{ params: { address }, query: { at } },
47+
res,
48+
): Promise<void> => {
49+
const rcApi = ApiPromiseRegistry.getApiByType('relay')[0]?.api;
50+
51+
if (!rcApi) {
52+
throw new Error('Relay chain API not found, please use SAS_SUBSTRATE_MULTI_CHAIN_URL env variable');
53+
}
54+
55+
const hash = await this.getHashFromAt(at, { api: rcApi });
56+
const historicApi = await rcApi.at(hash);
57+
58+
RcAccountsProxyInfoController.sanitizedSend(
59+
res,
60+
await this.service.fetchAccountProxyInfo(hash, rcApi, historicApi, address),
61+
);
62+
};
63+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017-2025 Parity Technologies (UK) Ltd.
2+
// This file is part of Substrate API Sidecar.
3+
//
4+
// Substrate API Sidecar is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
export { default as RcAccountsBalanceInfo } from './RcAccountsBalanceInfoController';
18+
export { default as RcAccountsProxyInfo } from './RcAccountsProxyInfoController';

src/controllers/rc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
export { default as RcAccountsBalanceInfo } from './RcAccountsBalanceInfoController';
17+
export * from './accounts';

0 commit comments

Comments
 (0)