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: cleanup pallets docs, and naming #713

Merged
merged 1 commit into from
Oct 13, 2021
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.

15 changes: 8 additions & 7 deletions docs/src/openapi-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,9 @@ paths:
type: string
- name: adjustMetadataV13
in: query
description: This gives the option to set historic blocks to use V13 metadata as oppose to V14. There are some
type differences between V14 and V13 when it comes to `StorageEntryType`. Specifally the 'map' key.
In turn this gives the ability to receive both older and newer storage responses while transitioning to V14.
description: Instruct sidecar to return `StorageEntryType` in the V13 metadata
format rather than V14. This is a **temporary** flag to allow existing systems to migrate.
It will be deprecated and then removed in the future.
required: false
schema:
type: boolean
Expand Down Expand Up @@ -895,9 +895,9 @@ paths:
type: string
- name: adjustMetadataV13
in: query
description: This gives the option to set historic blocks to use V13 metadata as oppose to V14. There are some
type differences between V14 and V13 when it comes to `StorageEntryType`. Specifally the 'map' key.
In turn this gives the ability to receive both older and newer storage responses while transitioning to V14.
description: Instruct sidecar to return `StorageEntryType` in the V13 metadata
format rather than V14. This is a **temporary** flag to allow existing systems to migrate.
It will be deprecated and then removed in the future.
required: false
schema:
type: boolean
Expand Down Expand Up @@ -2064,7 +2064,8 @@ components:
type: object
description: If the query parameter 'adjustMetadataV13' is set to true, all historic blocks that are
pre v9110 will have the return type `StorageEntryTypeV13`, and all present and post v9110 blocks will
have a return type of `StorageEntryTypeV14`. Please check those types to see potential responses.
have a return type of `StorageEntryTypeV14`. Please check those types to see potential responses. This
will be deprecated and removed in the future, and will only live as `StorageEntryTypeV14`.
Para:
type: object
properties:
Expand Down
18 changes: 9 additions & 9 deletions src/services/pallets/PalletsStorageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export class PalletsStorageService extends AbstractService {
adjustMetadataV13Arg,
}: IFetchStorageItemArgs
): Promise<IPalletStorageItem> {
const adjustedMetadata = await this.adjustMetadata(
const chosenMetadata = await this.chooseMetadataVersion(
hash,
adjustMetadataV13Arg
);
const [palletMeta, palletMetaIdx] = this.findPalletMeta(
adjustedMetadata,
chosenMetadata,
historicApi,
palletId
);
Expand Down Expand Up @@ -106,12 +106,12 @@ export class PalletsStorageService extends AbstractService {
adjustMetadataV13Arg,
}: IFetchPalletArgs & { onlyIds: boolean }
): Promise<IPalletStorage> {
const adjustedMetadata = await this.adjustMetadata(
const chosenMetadata = await this.chooseMetadataVersion(
hash,
adjustMetadataV13Arg
);
const [palletMeta, palletMetaIdx] = this.findPalletMeta(
adjustedMetadata,
chosenMetadata,
historicApi,
palletId
);
Expand Down Expand Up @@ -150,7 +150,7 @@ export class PalletsStorageService extends AbstractService {
*
* @param hash BlockHash to query
*/
private adjustMetadata = async (
private chooseMetadataVersion = async (
hash: BlockHash,
adjustMetadataV13Arg: boolean
): Promise<MetadataV13 | MetadataV14> => {
Expand All @@ -162,17 +162,17 @@ export class PalletsStorageService extends AbstractService {

const blockNumber = blockHeader.number.toNumber();

let adjustedMetadata;
let chosenMetadata;
if (
blockNumber < upgradeBlocks[specName.toString()] &&
adjustMetadataV13Arg
) {
adjustedMetadata = historicMetadata.asV13;
chosenMetadata = historicMetadata.asV13;
} else {
adjustedMetadata = historicMetadata.asV14;
chosenMetadata = historicMetadata.asV14;
}

return adjustedMetadata;
return chosenMetadata;
};

/**
Expand Down