Ensure metadata.toJSON applies type aliasses (#3243)

This commit is contained in:
Jaco Greeff
2021-02-28 13:35:25 +01:00
committed by GitHub
parent 09bbd5f6c9
commit 04f656cafa
2 changed files with 14 additions and 1 deletions
+1
View File
@@ -19,6 +19,7 @@ Changes:
- Add types for the new gilt module
- Upgrade to the latest Substrate metadata
- Adjust package detection to check for local monorepo dependencies
- Ensure that metadata `.toJSON()` does apply type aliasses
## 3.10.2 Feb 23, 2021
+13 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { MetadataAll, MetadataLatest, MetadataV9, MetadataV10, MetadataV11, MetadataV12 } from '@polkadot/types/interfaces/metadata';
import type { Registry } from '@polkadot/types/types';
import type { AnyJson, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types/codec';
import { assert } from '@polkadot/util';
@@ -126,4 +126,16 @@ export class MetadataVersioned extends Struct {
public getUniqTypes (throwError: boolean): string[] {
return getUniqTypes(this.registry, this.asLatest, throwError);
}
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): Record<string, AnyJson> {
// HACK(y): ensure that we apply the aliasses if we have not done so already, this is
// needed to ensure we have the overrides as intended (only applied in toLatest)
// eslint-disable-next-line no-unused-expressions
this.asLatest;
return super.toJSON();
}
}