Skip to content

Commit 715c8e8

Browse files
authored
feat: Remove authorId query param; Bump version in package (#303)
* feat: Remove authorId query param; Bump version in package * Build docs * Add a contributing note
1 parent 55c19b6 commit 715c8e8

File tree

7 files changed

+16
-59
lines changed

7 files changed

+16
-59
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ where reviewers will be able to review your changes made.
2020
- `yarn lint`: Make sure your code follows our linting rules. You can also run `yarn lint --fix` to
2121
automatically fix some of those errors.
2222
- `yarn test`: Make sure all tests pass.
23+
- `yarn build:docs`: If any changes are made to the OpenApi specs make sure to rebuild the UI.
2324

2425
## Rules
2526

docs/dist/app.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/openapi-v1.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,6 @@ paths:
251251
schema:
252252
type: boolean
253253
default: false
254-
- name: authorId
255-
in: query
256-
description: When set to `false`, there will be no `authorId` in the response
257-
object. This eliminates an expensive RPC call to the node and thus
258-
recommended that this query param be set to `false` if the consumer is
259-
not using the `authorId`.
260-
required: false
261-
schema:
262-
type: boolean
263-
default: true
264254
responses:
265255
"200":
266256
description: successful operation
@@ -308,16 +298,6 @@ paths:
308298
schema:
309299
type: boolean
310300
default: false
311-
- name: authorId
312-
in: query
313-
description: When set to `false`, there will be no `authorId` in the response
314-
object. This eliminates an expensive RPC call to the node and thus
315-
recommended that this query param be set to `false` if the consumer is
316-
not using the `authorId`.
317-
required: false
318-
schema:
319-
type: boolean
320-
default: true
321301
responses:
322302
"200":
323303
description: successful operation

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "substrate-api-sidecar",
3-
"version": "0.18.0",
3+
"version": "v1.0.0-rc1",
44
"description": "REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.",
55
"scripts": {
66
"preinstall": "yarn build:calc",

src/controllers/blocks/BlocksController.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ export default class BlocksController extends AbstractController<
8484
* @param res Express Response
8585
*/
8686
private getLatestBlock: RequestHandler = async (
87-
{ query: { eventDocs, extrinsicDocs, finalized, authorId } },
87+
{ query: { eventDocs, extrinsicDocs, finalized } },
8888
res
8989
) => {
9090
const eventDocsArg = eventDocs === 'true';
9191
const extrsinsicDocsArg = extrinsicDocs === 'true';
92-
const includeAuthorId = authorId !== 'false';
9392

9493
const hash =
9594
finalized === 'false'
@@ -98,12 +97,7 @@ export default class BlocksController extends AbstractController<
9897

9998
BlocksController.sanitizedSend(
10099
res,
101-
await this.service.fetchBlock(
102-
hash,
103-
eventDocsArg,
104-
extrsinsicDocsArg,
105-
includeAuthorId
106-
)
100+
await this.service.fetchBlock(hash, eventDocsArg, extrsinsicDocsArg)
107101
);
108102
};
109103

@@ -114,22 +108,20 @@ export default class BlocksController extends AbstractController<
114108
* @param res Express Response
115109
*/
116110
private getBlockById: RequestHandler<INumberParam> = async (
117-
{ params: { number }, query: { eventDocs, extrinsicDocs, authorId } },
111+
{ params: { number }, query: { eventDocs, extrinsicDocs } },
118112
res
119113
): Promise<void> => {
120114
const hash = await this.getHashForBlock(number);
121115

122116
const eventDocsArg = eventDocs === 'true';
123117
const extrinsinsicDocsArg = extrinsicDocs === 'true';
124-
const includeAuthorId = authorId !== 'false';
125118

126119
BlocksController.sanitizedSend(
127120
res,
128121
await this.service.fetchBlock(
129122
hash,
130123
eventDocsArg,
131-
extrinsinsicDocsArg,
132-
includeAuthorId
124+
extrinsinsicDocsArg
133125
)
134126
);
135127
};

src/services/blocks/BlocksService.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ describe('BlocksService', () => {
3737
it('works when ApiPromise works (block 789629)', async () => {
3838
expect(
3939
sanitizeNumbers(
40-
await blocksService.fetchBlock(
41-
blockHash789629,
42-
true,
43-
true,
44-
true
45-
)
40+
await blocksService.fetchBlock(blockHash789629, true, true)
4641
)
4742
).toMatchObject(blocks789629Response);
4843
});
@@ -66,7 +61,7 @@ describe('BlocksService', () => {
6661
}) as unknown) as GetBlock;
6762

6863
await expect(
69-
blocksService.fetchBlock(blockHash789629, false, false, true)
64+
blocksService.fetchBlock(blockHash789629, false, false)
7065
).rejects.toThrow(
7166
new Error(
7267
`Cannot destructure property 'method' of 'extrinsic' as it is undefined.`

src/services/blocks/BlocksService.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,15 @@ export class BlocksService extends AbstractService {
4242
async fetchBlock(
4343
hash: BlockHash,
4444
eventDocs: boolean,
45-
extrinsicDocs: boolean,
46-
includeAuthorId: boolean
45+
extrinsicDocs: boolean
4746
): Promise<IBlock> {
4847
const { api } = this;
4948

50-
let block, events, validators;
51-
if (includeAuthorId) {
52-
[{ block }, events, validators] = await Promise.all([
53-
api.rpc.chain.getBlock(hash),
54-
this.fetchEvents(api, hash),
55-
api.query.session.validators.at(hash),
56-
]);
57-
} else {
58-
[{ block }, events] = await Promise.all([
59-
api.rpc.chain.getBlock(hash),
60-
this.fetchEvents(api, hash),
61-
]);
62-
}
49+
const [{ block }, events, validators] = await Promise.all([
50+
api.rpc.chain.getBlock(hash),
51+
this.fetchEvents(api, hash),
52+
api.query.session.validators.at(hash),
53+
]);
6354

6455
const {
6556
parentHash,
@@ -69,9 +60,7 @@ export class BlocksService extends AbstractService {
6960
digest,
7061
} = block.header;
7162

72-
const authorId = validators
73-
? this.extractAuthor(validators, digest)
74-
: undefined;
63+
const authorId = this.extractAuthor(validators, digest);
7564

7665
const logs = digest.logs.map((log) => {
7766
const { type, index, value } = log;

0 commit comments

Comments
 (0)