Validator metadata name matches key (#1918)

### Description

If you use a different name, then MP lookup can fail. Thus we should
validate that the key matches the name
pull/1922/head
Nam Chu Hoai 2 years ago committed by GitHub
parent 1cbe5fd0a0
commit 5152da508b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      typescript/sdk/src/providers/MultiProvider.ts

@ -40,9 +40,13 @@ export class MultiProvider {
chainMetadata: ChainMap<ChainMetadata> = defaultChainMetadata,
options: MultiProviderOptions = {},
) {
Object.values(chainMetadata).forEach((cm) => {
Object.entries(chainMetadata).forEach(([key, cm]) => {
if (!isValidChainMetadata(cm))
throw new Error(`Invalid chain metadata for ${cm.chainId}`);
if (key !== cm.name)
throw new Error(
`Chain name mismatch: Key was ${key}, but name is ${cm.name}`,
);
});
this.metadata = chainMetadata;

Loading…
Cancel
Save