Support unknown chains in MultiGenerics (#1669)

pull/1673/head
Asa Oines 2 years ago committed by GitHub
parent 759996b221
commit 366ad751da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      typescript/sdk/src/utils/MultiGeneric.ts

@ -1,4 +1,4 @@
import { AllChains, AllDeprecatedChains } from '../consts/chains';
import { AllDeprecatedChains } from '../consts/chains';
import { ChainMap, ChainName, Remotes } from '../types';
export class MultiGeneric<Chain extends ChainName, Value> {
@ -9,9 +9,6 @@ export class MultiGeneric<Chain extends ChainName, Value> {
* @throws if chain is invalid or has not been set
*/
protected get(chain: Chain): Value {
if (!chain || !AllChains.includes(chain)) {
throw new Error(`Invalid chain ${chain}`);
}
const value = this.chainMap[chain] ?? null;
if (!value) {
throw new Error(`No chain value found for ${chain}`);
@ -24,9 +21,6 @@ export class MultiGeneric<Chain extends ChainName, Value> {
* @returns value or null if chain value has not been set
*/
protected tryGet(chain: Chain): Value | null {
if (!chain || !AllChains.includes(chain)) {
return null;
}
return this.chainMap[chain] ?? null;
}

Loading…
Cancel
Save