Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: remove noMeta query param from /transaction/materials #1275

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/dist/app.bundle.js

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -879,18 +879,15 @@ paths:
in: query
schema:
type: boolean
description: If true, does not return metadata hex. This is useful when
metadata is not needed and response time is a concern. Defaults to false.
This is due for deprecation in future releases. Please migrate to using the
`metadata` query param.
description: DEPRECATED! This is no longer supported
default: false
- name: metadata
in: query
schema:
type: string
description: Specifies the format of the metadata to be returned. Accepted values are
'json', and 'scale'. 'json' being the decoded metadata, and 'scale' being the SCALE encoded metadata.
When inputted it will override the `noMeta` query parameter.
When `metadata` is not inputted, the `metadata` field will be absent.
responses:
"200":
description: successful operation
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/latest/endpoints/kusama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const kusama: IConfig = {
},
'/transaction/material': {
path: '/transaction/material',
queryParams: ['noMeta=true'],
queryParams: [],
},
'/paras': {
path: '/paras',
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/latest/endpoints/polkadot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const polkadot: IConfig = {
},
'/transaction/material': {
path: '/transaction/material',
queryParams: ['noMeta=true'],
queryParams: [],
},
'/paras': {
path: '/paras',
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/latest/endpoints/westend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const westend: IConfig = {
},
'/transaction/material': {
path: '/transaction/material',
queryParams: ['noMeta=true'],
queryParams: [],
},
'/paras': {
path: '/paras',
Expand Down
29 changes: 5 additions & 24 deletions src/controllers/transaction/TransactionMaterialController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import { ApiPromise } from '@polkadot/api';
import { RequestHandler } from 'express';

import { Log } from '../../logging/Log';
import { validateBoolean } from '../../middleware';
import { TransactionMaterialService } from '../../services';
import AbstractController from '../AbstractController';

Expand Down Expand Up @@ -61,7 +59,6 @@ export default class TransactionMaterialController extends AbstractController<Tr
}

protected initRoutes(): void {
this.router.use(this.path, validateBoolean(['noMeta']));
this.safeMountAsyncGetHandlers([['', this.getTransactionMaterial]]);
}

Expand All @@ -72,12 +69,12 @@ export default class TransactionMaterialController extends AbstractController<Tr
* @param res Express Response
*/
private getTransactionMaterial: RequestHandler = async (
{ query: { noMeta, at, metadata } },
{ query: { at, metadata } },
res
): Promise<void> => {
const hash = await this.getHashFromAt(at);

const metadataArg = this.parseMetadataArgs(noMeta, metadata);
const metadataArg = this.parseMetadataArgs(metadata);

TransactionMaterialController.sanitizedSend(
res,
Expand All @@ -91,10 +88,7 @@ export default class TransactionMaterialController extends AbstractController<Tr
* @param noMeta
* @param metadata
*/
private parseMetadataArgs(
noMeta: unknown,
metadata: unknown
): MetadataOpts | false {
private parseMetadataArgs(metadata: unknown): MetadataOpts | false {
/**
* Checks to see if the `metadata` query param is inputted, if it isnt,
* it will default to the old behavior. This is to be removed once after
Expand All @@ -108,24 +102,11 @@ export default class TransactionMaterialController extends AbstractController<Tr
return 'scale';
default:
throw new Error(
'Invalid inputted value for the `metadata` query param.'
'Invalid inputted value for the `metadata` query param. Options are `scale` or `json`.'
);
}
}

if (noMeta) {
Log.logger.warn(
'`noMeta` query param will be deprecated in sidecar v13, and replaced with `metadata` please migrate'
);
switch (noMeta) {
case 'true':
return false;
case 'false':
return 'scale';
}
}

// default behavior until `noMeta` is deprecated, then false will be default
return 'scale';
return false;
}
}