Allow for CodecHash override & hasher option (#3206)
* Allow for CodecHash override & hasher option * Adjust * CodecHash maps to Hash
This commit is contained in:
@@ -5,7 +5,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';
|
||||
import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, OverrideModuleType, OverrideVersionedType, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
|
||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||
|
||||
@@ -74,6 +74,13 @@ export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string
|
||||
};
|
||||
}
|
||||
|
||||
export function getSpecHasher ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): CodecHasher | null {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
|
||||
return knownTypes.hasher || knownTypes.typesBundle?.chain?.[_chainName]?.hasher || knownTypes.typesBundle?.spec?.[_specName]?.hasher || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user