Allow extensions on typesBundle (#3142)

* Allow extensions on typesBundle

* User extension take precedence
This commit is contained in:
Jaco Greeff
2021-02-06 08:49:11 +01:00
committed by GitHub
parent f643426067
commit 1e87f58f36
7 changed files with 33 additions and 15 deletions
+14
View File
@@ -3,6 +3,7 @@
import type BN from 'bn.js';
import type { Text } from '@polkadot/types';
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { ChainUpgradeVersion, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
@@ -37,6 +38,19 @@ export function getModuleTypes ({ knownTypes }: Registry, section: string): Over
};
}
/**
* @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration)
*/
export function getSpecExtensions ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): ExtDef {
const _chainName = chainName.toString();
const _specName = specName.toString();
return {
...(knownTypes.typesBundle?.spec?.[_specName]?.signedExtensions || {}),
...(knownTypes.typesBundle?.chain?.[_chainName]?.signedExtensions || {})
};
}
/**
* @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
*/