|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|