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

Loading…
Cancel
Save